; # Add another overdue
t::lib::Mocks::mock_preference( 'CumulativeRestrictionPeriods', '0' );
- AddReturn( $item_1->{barcode}, $library->{branchcode},
- undef, undef, dt_from_string );
+ AddReturn( $item_1->{barcode}, $library->{branchcode}, undef, dt_from_string );
my $debarments = Koha::Patron::Debarments::GetDebarments(
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } );
is( scalar(@$debarments), 1 );
);
is( $debarments->[0]->{expiration}, $expected_expiration );
- AddReturn( $item_2->{barcode}, $library->{branchcode},
- undef, undef, dt_from_string );
+ AddReturn( $item_2->{barcode}, $library->{branchcode}, undef, dt_from_string );
$debarments = Koha::Patron::Debarments::GetDebarments(
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } );
is( scalar(@$debarments), 1 );
AddIssue( $patron, $item_1->{barcode}, $five_days_ago ); # Add an overdue
AddIssue( $patron, $item_2->{barcode}, $ten_days_ago )
; # Add another overdue
- AddReturn( $item_1->{barcode}, $library->{branchcode},
- undef, undef, dt_from_string );
+ AddReturn( $item_1->{barcode}, $library->{branchcode}, undef, dt_from_string );
$debarments = Koha::Patron::Debarments::GetDebarments(
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } );
is( scalar(@$debarments), 1 );
);
is( $debarments->[0]->{expiration}, $expected_expiration );
- AddReturn( $item_2->{barcode}, $library->{branchcode},
- undef, undef, dt_from_string );
+ AddReturn( $item_2->{barcode}, $library->{branchcode}, undef, dt_from_string );
$debarments = Koha::Patron::Debarments::GetDebarments(
{ borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } );
is( scalar(@$debarments), 1 );
# specify return date 5 days before => no overdue
AddIssue( $patron->unblessed, $item->{barcode}, $five_days_ago ); # date due was 5d ago
- AddReturn( $item->{barcode}, $library->{branchcode}, undef, undef, $ten_days_ago );
+ AddReturn( $item->{barcode}, $library->{branchcode}, undef, $ten_days_ago );
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' );
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete;
# specify return date 5 days later => overdue
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago
- AddReturn( $item->{barcode}, $library->{branchcode}, undef, undef, $five_days_ago );
+ AddReturn( $item->{barcode}, $library->{branchcode}, undef, $five_days_ago );
is( int($patron->account->balance()), 5, 'AddReturn: pass return_date => overdue' );
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete;
# specify dropbox date 5 days before => no overdue
AddIssue( $patron->unblessed, $item->{barcode}, $five_days_ago ); # date due was 5d ago
- AddReturn( $item->{barcode}, $library->{branchcode}, undef, 1, undef, $ten_days_ago );
+ AddReturn( $item->{barcode}, $library->{branchcode}, $ten_days_ago );
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue' );
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete;
# specify dropbox date 5 days later => overdue, or... not
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago
- AddReturn( $item->{barcode}, $library->{branchcode}, undef, 1, undef, $five_days_ago );
+ AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago );
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue in dropbox mode' ); # FIXME? This is weird, the FU fine is created ( _CalculateAndUpdateFine > C4::Overdues::UpdateFine ) then remove later (in _FixOverduesOnReturn). Looks like it is a feature
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete;
};
};
subtest '_FixOverduesOnReturn' => sub {
- plan tests => 10;
+ plan tests => 6;
my $biblio = $builder->build_sample_biblio({ author => 'Hall, Kylie' });
is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )');
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" );
is( $offset->amount, '-99.000000', "Amount of offset is correct" );
-
- ## Run again, with dropbox mode enabled
- $accountline->set(
- {
- accounttype => 'FU',
- amountoutstanding => 99.00,
- }
- )->store();
-
- C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 0, 1 );
-
- $accountline->_result()->discard_changes();
- $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Dropbox' })->next();
-
- is( $accountline->amountoutstanding + 0, 90, 'Fine has been reduced to 90' );
- is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )');
- is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via dropbox" );
- is( $offset->amount, '-9.000000', "Amount of offset is correct" );
};
subtest 'Set waiting flag' => sub {
my $line_number = $caller[2];
AddIssue( $patron, $item->{barcode}, $due_date );
- my ( undef, $message ) = AddReturn( $item->{barcode}, $library->{branchcode},
- undef, undef, $return_date );
+ my ( undef, $message ) = AddReturn( $item->{barcode}, $library->{branchcode}, undef, $return_date );
is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' )
or diag('AddReturn returned message ' . Dumper $message );
my $debarments = Koha::Patron::Debarments::GetDebarments(
use Test::More tests => 1;
-use C4::Context;
use C4::Circulation;
-
+use C4::Context;
use Koha::Database;
+use Koha::DateUtils;
use Koha::Items;
use t::lib::Mocks;
my $patron_object = $item_object->last_returned_by();
is( $patron_object, undef, 'Koha::Item::last_returned_by returned undef' );
- my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, undef, '2010-10-10' );
+ my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, dt_from_string('2010-10-10') );
$item_object = Koha::Items->find( $item->{itemnumber} );
$patron_object = $item_object->last_returned_by();
}
);
- ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, undef, '2010-10-10' );
+ ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, dt_from_string('2010-10-10') );
$item_object = Koha::Items->find( $item->{itemnumber} );
$patron_object = $item_object->last_returned_by();
},
}
);
- ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, undef, '2010-10-10' );
+ ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, $patron->{branchcode}, undef, dt_from_string('2010-10-10') );
$item_object = Koha::Items->find( $item->{itemnumber} );
is( $item_object->last_returned_by, undef, 'Last patron to return item should not be stored if StoreLastBorrower if off' );
}
);
- my ( $returned_1, undef, undef ) = C4::Circulation::AddReturn( $item_1->{barcode}, undef, undef, undef, '2010-10-10' );
- my ( $returned_2, undef, undef ) = C4::Circulation::AddReturn( $item_2->{barcode}, undef, undef, undef, '2011-11-11' );
+ my ( $returned_1, undef, undef ) = C4::Circulation::AddReturn( $item_1->{barcode}, undef, undef, dt_from_string('2010-10-10') );
+ my ( $returned_2, undef, undef ) = C4::Circulation::AddReturn( $item_2->{barcode}, undef, undef, dt_from_string('2011-11-11') );
is( $returned_1 && $returned_2, 1, 'The items should have been returned' );
my $patrons_to_anonymise = Koha::Patrons->search_patrons_to_anonymise( { before => '2010-10-11' } )->search( { 'me.borrowernumber' => $patron->{borrowernumber} } );
}
);
- my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
+ my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, dt_from_string('2010-10-10') );
is( $returned, 1, 'The item should have been returned' );
my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( { before => '2010-10-11' } )->anonymise_issue_history( { before => '2010-10-11' } );
ok( $rows_affected > 0, 'AnonymiseIssueHistory should not return any error if success' );
}
);
- my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
+ my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, dt_from_string('2010-10-10') );
is( $returned, 1, 'The item should have been returned' );
my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( { before => '2010-10-11' } )->anonymise_issue_history( { before => '2010-10-11' } );
ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' );
}
);
- my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
+ my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, dt_from_string('2010-10-10') );
is( Koha::Patrons->search_patrons_to_anonymise( { before => '2010-10-11' } )->count, 0 );
Koha::Patrons->find( $patron->{borrowernumber})->delete;
};