use Modern::Perl;
use utf8;
-use Test::More tests => 126;
+use Test::More tests => 45;
use Test::MockModule;
use Data::Dumper;
use DateTime;
+use Time::Fake;
use POSIX qw( floor );
use t::lib::Mocks;
use t::lib::TestBuilder;
use Koha::Account::Offsets;
use Koha::ActionLogs;
+sub set_userenv {
+ my ( $library ) = @_;
+ t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} });
+}
+
+sub str {
+ my ( $error, $question, $alert ) = @_;
+ my $s;
+ $s = %$error ? ' (error: ' . join( ' ', keys %$error ) . ')' : '';
+ $s .= %$question ? ' (question: ' . join( ' ', keys %$question ) . ')' : '';
+ $s .= %$alert ? ' (alert: ' . join( ' ', keys %$alert ) . ')' : '';
+ return $s;
+}
+
+sub test_debarment_on_checkout {
+ my ($params) = @_;
+ my $item = $params->{item};
+ my $library = $params->{library};
+ my $patron = $params->{patron};
+ my $due_date = $params->{due_date} || dt_from_string;
+ my $return_date = $params->{return_date} || dt_from_string;
+ my $expected_expiration_date = $params->{expiration_date};
+
+ $expected_expiration_date = output_pref(
+ {
+ dt => $expected_expiration_date,
+ dateformat => 'sql',
+ dateonly => 1,
+ }
+ );
+ my @caller = caller;
+ my $line_number = $caller[2];
+ AddIssue( $patron, $item->{barcode}, $due_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(
+ { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } );
+ is( scalar(@$debarments), 1, 'Test at line ' . $line_number );
+
+ is( $debarments->[0]->{expiration},
+ $expected_expiration_date, 'Test at line ' . $line_number );
+ Koha::Patron::Debarments::DelUniqueDebarment(
+ { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } );
+};
+
my $schema = Koha::Database->schema;
$schema->storage->txn_begin;
my $builder = t::lib::TestBuilder->new;
my $dbh = C4::Context->dbh;
+# Prevent random failures by mocking ->now
+my $now_value = DateTime->now();
+my $mocked_datetime = Test::MockModule->new('DateTime');
+$mocked_datetime->mock( 'now', sub { return $now_value->clone; } );
+
# Start transaction
$dbh->{RaiseError} = 1;
branchcode => $library2->{branchcode}
};
+t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0);
+
# No userenv, PickupLibrary
t::lib::Mocks::mock_preference('IndependentBranches', '0');
t::lib::Mocks::mock_preference('CircControl', 'PickupLibrary');
);
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
-{
-# CanBookBeRenewed tests
+subtest "CanBookBeRenewed tests" => sub {
+ plan tests => 71;
+
C4::Context->set_preference('ItemsDeniedRenewal','');
# Generate test biblio
my $biblio = $builder->build_sample_biblio();
action => "ISSUE"
);
my $old_log_size = Koha::ActionLogs->count( \%params_renewal );
- AddRenewal( $renewing_borrower->{borrowernumber}, $item_7->itemnumber, $branch );
+ my $dt = dt_from_string();
+ Time::Fake->offset( $dt->epoch );
+ my $datedue1 = AddRenewal( $renewing_borrower->{borrowernumber}, $item_7->itemnumber, $branch );
my $new_log_size = Koha::ActionLogs->count( \%params_renewal );
is ($new_log_size, $old_log_size, 'renew log not added because of the syspref RenewalLog');
+ isnt (DateTime->compare($datedue1, $dt), 0, "AddRenewal returned a good duedate");
+ Time::Fake->reset;
t::lib::Mocks::mock_preference('RenewalLog', 1);
$date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } );
is ($new_log_size, $old_log_size + 1, 'renew log successfully added');
my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } );
- is( $fines->count, 2 );
- is( $fines->next->accounttype, 'F', 'Fine on renewed item is closed out properly' );
- is( $fines->next->accounttype, 'F', 'Fine on renewed item is closed out properly' );
+ is( $fines->count, 2, 'AddRenewal left both fines' );
+ isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' );
+ isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' );
$fines->delete();
C4::Context->set_preference('OPACFineNoRenewalsBlockAutoRenew','1');
C4::Context->set_preference('OPACFineNoRenewals','10');
my $fines_amount = 5;
- C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
+ my $account = Koha::Account->new({patron_id => $renewing_borrowernumber});
+ $account->add_debit(
+ {
+ amount => $fines_amount,
+ interface => 'test',
+ type => 'overdue',
+ item_id => $item_to_auto_renew->{itemnumber},
+ description => "Some fines"
+ }
+ )->status('RETURNED')->store;
( $renewokay, $error ) =
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
is( $renewokay, 0, 'Do not renew, renewal is automatic' );
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 5' );
- C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
+ $account->add_debit(
+ {
+ amount => $fines_amount,
+ interface => 'test',
+ type => 'overdue',
+ item_id => $item_to_auto_renew->{itemnumber},
+ description => "Some fines"
+ }
+ )->status('RETURNED')->store;
( $renewokay, $error ) =
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
is( $renewokay, 0, 'Do not renew, renewal is automatic' );
is( $error, 'auto_renew', 'Can auto renew, OPACFineNoRenewals=10, patron has 10' );
- C4::Accounts::manualinvoice( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber}, "Some fines", 'F', $fines_amount );
+ $account->add_debit(
+ {
+ amount => $fines_amount,
+ interface => 'test',
+ type => 'overdue',
+ item_id => $item_to_auto_renew->{itemnumber},
+ description => "Some fines"
+ }
+ )->status('RETURNED')->store;
( $renewokay, $error ) =
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} );
is( $renewokay, 0, 'Do not renew, renewal is automatic' );
);
my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next();
- is( $line->accounttype, 'FU', 'Account line type is FU' );
- is( $line->lastincrement, '15.000000', 'Account line last increment is 15.00' );
+ is( $line->accounttype, 'OVERDUE', 'Account line type is OVERDUE' );
+ is( $line->status, 'UNRETURNED', 'Account line status is UNRETURNED' );
is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' );
is( $line->amount, '15.000000', 'Account line amount is 15.00' );
is( $line->issue_id, $issue->id, 'Account line issue id matches' );
my $offset = Koha::Account::Offsets->search({ debit_id => $line->id })->next();
- is( $offset->type, 'Fine', 'Account offset type is Fine' );
+ is( $offset->type, 'OVERDUE', 'Account offset type is Fine' );
is( $offset->amount, '15.000000', 'Account offset amount is 15.00' );
t::lib::Mocks::mock_preference('WhenLostForgiveFine','0');
LostItem( $item_1->itemnumber, 'test', 1 );
$line = Koha::Account::Lines->find($line->id);
- is( $line->accounttype, 'F', 'Account type correctly changed from FU to F' );
+ is( $line->accounttype, 'OVERDUE', 'Account type remains as OVERDUE' );
+ isnt( $line->status, 'UNRETURNED', 'Account status correctly changed from UNRETURNED to RETURNED' );
my $item = Koha::Items->find($item_1->itemnumber);
ok( !$item->onloan(), "Lost item marked as returned has false onloan value" );
( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_7->itemnumber);
is( $renewokay, 0, '(Bug 8236), Cannot renew, one of the items is overdue');
+ my $manager = $builder->build_object({ class => "Koha::Patrons" });
+ t::lib::Mocks::mock_userenv({ patron => $manager,branchcode => $manager->branchcode });
t::lib::Mocks::mock_preference('WhenLostChargeReplacementFee','1');
$checkout = Koha::Checkouts->find( { itemnumber => $item_3->itemnumber } );
LostItem( $item_3->itemnumber, 'test', 0 );
my $accountline = Koha::Account::Lines->find( { itemnumber => $item_3->itemnumber } );
is( $accountline->issue_id, $checkout->id, "Issue id added for lost replacement fee charge" );
- }
+ is(
+ $accountline->description,
+ sprintf( "%s %s %s",
+ $item_3->biblio->title || '',
+ $item_3->barcode || '',
+ $item_3->itemcallnumber || '' ),
+ "Account line description must not contain 'Lost Items ', but be title, barcode, itemcallnumber"
+ );
+};
+
+subtest "GetUpcomingDueIssues" => sub {
+ plan tests => 12;
-{
- # GetUpcomingDueIssues tests
my $branch = $library2->{branchcode};
#Create another record
$upcoming_dues = C4::Circulation::GetUpcomingDueIssues();
is ( scalar ( @$upcoming_dues), 2, "days_in_advance is 7 in GetUpcomingDueIssues if not provided" );
-}
+};
-{
+subtest "Bug 13841 - Do not create new 0 amount fines" => sub {
my $branch = $library2->{branchcode};
my $biblio = $builder->build_sample_biblio();
my $count = $hr->{count};
is ( $count, 0, "Calling UpdateFine on non-existant fine with an amount of 0 does not result in an empty fine" );
-}
+};
-{
+subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
$dbh->do('DELETE FROM issues');
$dbh->do('DELETE FROM items');
$dbh->do('DELETE FROM issuingrules');
( $renewokay, $error ) = CanBookBeRenewed( $borrowernumber1, $item_1->itemnumber );
is( $renewokay, 0, 'Bug 14337 - Verify the borrower can not renew with a hold on the record if AllowRenewalIfOtherItemsAvailable is enabled but the only available item is notforloan' );
-}
+};
{
# Don't allow renewing onsite checkout
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} );
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) );
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' );
- is( $error->{branch_to_return}, $holdingbranch->{branchcode} );
+ is( $error->{branch_to_return}, $holdingbranch->{branchcode}, 'branch_to_return matched holdingbranch' );
## Can be issued from holdinbranch
set_userenv($holdingbranch);
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} );
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} );
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) );
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' );
- is( $error->{branch_to_return}, $holdingbranch->{branchcode} );
+ is( $error->{branch_to_return}, $holdingbranch->{branchcode}, 'branch_to_return matches holdingbranch' );
# AllowReturnToBranch == homebranch
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' );
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} );
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) );
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' );
- is( $error->{branch_to_return}, $homebranch->{branchcode} );
+ is( $error->{branch_to_return}, $homebranch->{branchcode}, 'branch_to_return matches homebranch' );
## Cannot be issued from holdinbranch
set_userenv($otherbranch);
( $error, $question, $alerts ) = CanBookBeIssued( $patron_2, $item->{barcode} );
is( keys(%$question) + keys(%$alerts), 0, 'There should not be any errors or alerts (impossible)' . str($error, $question, $alerts) );
is( exists $error->{RETURN_IMPOSSIBLE}, 1, 'RETURN_IMPOSSIBLE must be set' );
- is( $error->{branch_to_return}, $homebranch->{branchcode} );
+ is( $error->{branch_to_return}, $homebranch->{branchcode}, 'branch_to_return matches homebranch' );
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch');
};
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
## Can be issued from homebranch
set_userenv($homebranch);
- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue );
+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from homebranch');
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue
## Can be issued from holdinbranch
set_userenv($holdingbranch);
- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue );
+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from holdingbranch');
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue
## Can be issued from another branch
set_userenv($otherbranch);
- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue );
+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - anywhere | Can be issued from otherbranch');
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue
# AllowReturnToBranch == holdinbranch
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'holdingbranch' );
## Cannot be issued from homebranch
set_userenv($homebranch);
- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' );
+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - holdingbranch | Cannot be issued from homebranch');
## Can be issued from holdingbranch
set_userenv($holdingbranch);
- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue );
+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - holdingbranch | Can be issued from holdingbranch');
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue
## Cannot be issued from another branch
set_userenv($otherbranch);
- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' );
+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - holdingbranch | Cannot be issued from otherbranch');
# AllowReturnToBranch == homebranch
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'homebranch' );
## Can be issued from homebranch
set_userenv($homebranch);
- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue );
+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), $ref_issue, 'AllowReturnToBranch - homebranch | Can be issued from homebranch' );
set_userenv($holdingbranch); AddIssue( $patron_1, $item->{barcode} ); # Reinsert the original issue
## Cannot be issued from holdinbranch
set_userenv($holdingbranch);
- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' );
+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - homebranch | Cannot be issued from holdingbranch' );
## Cannot be issued from another branch
set_userenv($otherbranch);
- is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '' );
+ is ( ref( AddIssue( $patron_2, $item->{barcode} ) ), '', 'AllowReturnToBranch - homebranch | Cannot be issued from otherbranch' );
# TODO t::lib::Mocks::mock_preference('AllowReturnToBranch', 'homeorholdingbranch');
};
; # 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 );
);
};
+subtest 'CanBookBeIssued + AutoReturnCheckedOutItems' => sub {
+ plan tests => 2;
+
+ my $library = $builder->build( { source => 'Branch' } );
+ my $patron1 = $builder->build_object(
+ {
+ class => 'Koha::Patrons',
+ value => {
+ branchcode => $library->{branchcode},
+ firstname => "Happy",
+ surname => "Gilmore",
+ }
+ }
+ );
+ my $patron2 = $builder->build_object(
+ {
+ class => 'Koha::Patrons',
+ value => {
+ branchcode => $library->{branchcode},
+ firstname => "Billy",
+ surname => "Madison",
+ }
+ }
+ );
+
+ C4::Context->_new_userenv('xxx');
+ C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, 'Random Library', '', '', '');
+
+ my $biblioitem = $builder->build( { source => 'Biblioitem' } );
+ my $biblionumber = $biblioitem->{biblionumber};
+ my $item = $builder->build(
+ { source => 'Item',
+ value => {
+ homebranch => $library->{branchcode},
+ holdingbranch => $library->{branchcode},
+ notforloan => 0,
+ itemlost => 0,
+ withdrawn => 0,
+ biblionumber => $biblionumber,
+ }
+ }
+ );
+
+ my ( $error, $question, $alerts );
+ my $issue = AddIssue( $patron1->unblessed, $item->{barcode} );
+
+ t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0);
+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->{barcode} );
+ is( $question->{ISSUED_TO_ANOTHER}, 1, 'ISSUED_TO_ANOTHER question flag should be set if AutoReturnCheckedOutItems is disabled and item is checked out to another' );
+
+ t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 1);
+ ( $error, $question, $alerts ) = CanBookBeIssued( $patron2, $item->{barcode} );
+ is( $alerts->{RETURNED_FROM_ANOTHER}->{patron}->borrowernumber, $patron1->borrowernumber, 'RETURNED_FROM_ANOTHER alert flag should be set if AutoReturnCheckedOutItems is enabled and item is checked out to another' );
+
+ t::lib::Mocks::mock_preference('AutoReturnCheckedOutItems', 0);
+};
+
+
subtest 'AddReturn | is_overdue' => sub {
plan tests => 5;
my $library = $builder->build( { source => 'Branch' } );
my $patron = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
+ my $manager = $builder->build_object({ class => "Koha::Patrons" });
+ t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
my $biblioitem = $builder->build( { source => 'Biblioitem' } );
+ my $item_type = $builder->build_object(
+ { class => 'Koha::ItemTypes',
+ value => {
+ notforloan => undef,
+ rentalcharge => 0,
+ defaultreplacecost => undef,
+ processfee => 0,
+ rentalcharge_daily => 0,
+ }
+ }
+ );
my $item = $builder->build(
{
source => 'Item',
itemlost => 0,
withdrawn => 0,
biblionumber => $biblioitem->{biblionumber},
+ replacementprice => 7,
+ itype => $item_type->itemtype
}
}
);
);
$rule->store();
+ my $now = dt_from_string;
my $one_day_ago = dt_from_string->subtract( days => 1 );
my $five_days_ago = dt_from_string->subtract( days => 5 );
my $ten_days_ago = dt_from_string->subtract( days => 10 );
$patron = Koha::Patrons->find( $patron->{borrowernumber} );
- # No date specify, today will be used
+ # No return date specified, today will be used => 10 days overdue charged
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago
AddReturn( $item->{barcode}, $library->{branchcode} );
is( int($patron->account->balance()), 10, 'Patron should have a charge of 10 (10 days x 1)' );
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete;
- # specify return date 5 days before => no overdue
+ # specify return date 5 days before => no overdue charged
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
+ # specify return date 5 days later => 5 days overdue charged
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 );
+ # specify return date 5 days later, specify exemptfine => no overdue charge
+ AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago
+ AddReturn( $item->{barcode}, $library->{branchcode}, 1, $five_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 );
- 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 'bug 22877' => sub {
+
+ plan tests => 3;
+
+ my $issue = AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago
+
+ # Fake fines cronjob on this checkout
+ my ($fine) =
+ CalcFine( $item, $patron->categorycode, $library->{branchcode},
+ $ten_days_ago, $now );
+ UpdateFine(
+ {
+ issue_id => $issue->issue_id,
+ itemnumber => $item->{itemnumber},
+ borrowernumber => $patron->borrowernumber,
+ amount => $fine,
+ due => output_pref($ten_days_ago)
+ }
+ );
+ is( int( $patron->account->balance() ),
+ 10, "Overdue fine of 10 days overdue" );
+
+ # Fake longoverdue with charge and not marking returned
+ LostItem( $item->{itemnumber}, 'cronjob', 0 );
+ is( int( $patron->account->balance() ),
+ 17, "Lost fine of 7 plus 10 days overdue" );
+
+ # Now we return it today
+ AddReturn( $item->{barcode}, $library->{branchcode} );
+ is( int( $patron->account->balance() ),
+ 17, "Should have a single 10 days overdue fine and lost charge" );
+ }
};
subtest '_FixAccountForLostAndReturned' => sub {
subtest 'Full write-off tests' => sub {
- plan tests => 10;
+ plan tests => 12;
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
+ my $manager = $builder->build_object({ class => "Koha::Patrons" });
+ t::lib::Mocks::mock_userenv({ patron => $manager,branchcode => $manager->branchcode });
my $item = $builder->build_sample_item(
{
$processfee_amount, 'The right PF amountoutstanding is generated' );
my $lost_fee_lines = Koha::Account::Lines->search(
- { borrowernumber => $patron->id, itemnumber => $item->itemnumber, accounttype => 'L' } );
+ { borrowernumber => $patron->id, itemnumber => $item->itemnumber, accounttype => 'LOST' } );
is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' );
my $lost_fee_line = $lost_fee_lines->next;
- is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' );
+ is( $lost_fee_line->amount + 0, $replacement_amount, 'The right LOST amount is generated' );
is( $lost_fee_line->amountoutstanding + 0,
- $replacement_amount, 'The right L amountoutstanding is generated' );
+ $replacement_amount, 'The right LOST amountoutstanding is generated' );
+ is( $lost_fee_line->status,
+ undef, 'The LOST status was not set' );
my $account = $patron->account;
my $debts = $account->outstanding_debits;
# Write off the debt
my $credit = $account->add_credit(
{ amount => $account->balance,
- type => 'writeoff'
+ type => 'writeoff',
+ interface => 'test',
}
);
$credit->apply( { debits => $debts, offset_type => 'Writeoff' } );
my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item->itemnumber, $patron->id );
- is( $credit_return_id, undef, 'No CR account line added' );
+ is( $credit_return_id, undef, 'No LOST_RETURN account line added' );
$lost_fee_line->discard_changes; # reload from DB
is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' );
is( $lost_fee_line->accounttype,
- 'LR', 'Lost fee now has account type of LR ( Lost Returned )' );
+ 'LOST', 'Lost fee now still has account type of LOST' );
+ is( $lost_fee_line->status, 'RETURNED', "Lost fee now has account status of RETURNED");
is( $patron->account->balance, -0, 'The patron balance is 0, everything was written off' );
};
subtest 'Full payment tests' => sub {
- plan tests => 12;
+ plan tests => 13;
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
$processfee_amount, 'The right PF amountoutstanding is generated' );
my $lost_fee_lines = Koha::Account::Lines->search(
- { borrowernumber => $patron->id, itemnumber => $item->itemnumber, accounttype => 'L' } );
+ { borrowernumber => $patron->id, itemnumber => $item->itemnumber, accounttype => 'LOST' } );
is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' );
my $lost_fee_line = $lost_fee_lines->next;
- is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' );
+ is( $lost_fee_line->amount + 0, $replacement_amount, 'The right LOST amount is generated' );
is( $lost_fee_line->amountoutstanding + 0,
- $replacement_amount, 'The right L amountountstanding is generated' );
+ $replacement_amount, 'The right LOST amountountstanding is generated' );
my $account = $patron->account;
my $debts = $account->outstanding_debits;
# Write off the debt
my $credit = $account->add_credit(
{ amount => $account->balance,
- type => 'payment'
+ type => 'payment',
+ interface => 'test',
}
);
$credit->apply( { debits => $debts, offset_type => 'Payment' } );
my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item->itemnumber, $patron->id );
my $credit_return = Koha::Account::Lines->find($credit_return_id);
- is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' );
+ is( $credit_return->accounttype, 'LOST_RETURN', 'An account line of type LOST_RETURN is added' );
is( $credit_return->amount + 0,
- -99.00, 'The account line of type CR has an amount of -99' );
+ -99.00, 'The account line of type LOST_RETURN has an amount of -99' );
is( $credit_return->amountoutstanding + 0,
- -99.00, 'The account line of type CR has an amountoutstanding of -99' );
+ -99.00, 'The account line of type LOST_RETURN has an amountoutstanding of -99' );
$lost_fee_line->discard_changes;
is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' );
is( $lost_fee_line->accounttype,
- 'LR', 'Lost fee now has account type of LR ( Lost Returned )' );
+ 'LOST', 'Lost fee now still has account type of LOST' );
+ is( $lost_fee_line->status, 'RETURNED', "Lost fee now has account status of RETURNED");
is( $patron->account->balance,
-99, 'The patron balance is -99, a credit that equals the lost fee payment' );
subtest 'Test without payment or write off' => sub {
- plan tests => 12;
+ plan tests => 13;
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
$processfee_amount, 'The right PF amountoutstanding is generated' );
my $lost_fee_lines = Koha::Account::Lines->search(
- { borrowernumber => $patron->id, itemnumber => $item->itemnumber, accounttype => 'L' } );
+ { borrowernumber => $patron->id, itemnumber => $item->itemnumber, accounttype => 'LOST' } );
is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' );
my $lost_fee_line = $lost_fee_lines->next;
- is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' );
+ is( $lost_fee_line->amount + 0, $replacement_amount, 'The right LOST amount is generated' );
is( $lost_fee_line->amountoutstanding + 0,
- $replacement_amount, 'The right L amountountstanding is generated' );
+ $replacement_amount, 'The right LOST amountountstanding is generated' );
my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item->itemnumber, $patron->id );
my $credit_return = Koha::Account::Lines->find($credit_return_id);
- is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' );
- is( $credit_return->amount + 0, -99.00, 'The account line of type CR has an amount of -99' );
- is( $credit_return->amountoutstanding + 0, 0, 'The account line of type CR has an amountoutstanding of 0' );
+ is( $credit_return->accounttype, 'LOST_RETURN', 'An account line of type LOST_RETURN is added' );
+ is( $credit_return->amount + 0, -99.00, 'The account line of type LOST_RETURN has an amount of -99' );
+ is( $credit_return->amountoutstanding + 0, 0, 'The account line of type LOST_RETURN has an amountoutstanding of 0' );
$lost_fee_line->discard_changes;
is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' );
- is( $lost_fee_line->accounttype, 'LR', 'Lost fee now has account type of LR ( Lost Returned )' );
+ is( $lost_fee_line->accounttype,
+ 'LOST', 'Lost fee now still has account type of LOST' );
+ is( $lost_fee_line->status, 'RETURNED', "Lost fee now has account status of RETURNED");
is( $patron->account->balance, 20, 'The patron balance is 20, still owes the processing fee' );
};
subtest 'Test with partial payement and write off, and remaining debt' => sub {
- plan tests => 15;
+ plan tests => 16;
my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
my $item = $builder->build_sample_item(
$processfee_amount, 'The right PF amountoutstanding is generated' );
my $lost_fee_lines = Koha::Account::Lines->search(
- { borrowernumber => $patron->id, itemnumber => $item->itemnumber, accounttype => 'L' } );
+ { borrowernumber => $patron->id, itemnumber => $item->itemnumber, accounttype => 'LOST' } );
is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' );
my $lost_fee_line = $lost_fee_lines->next;
- is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' );
+ is( $lost_fee_line->amount + 0, $replacement_amount, 'The right LOST amount is generated' );
is( $lost_fee_line->amountoutstanding + 0,
- $replacement_amount, 'The right L amountountstanding is generated' );
+ $replacement_amount, 'The right LOST amountountstanding is generated' );
my $account = $patron->account;
is( $account->balance, $processfee_amount + $replacement_amount, 'Balance is PF + L' );
my $payment_amount = 27;
my $payment = $account->add_credit(
{ amount => $payment_amount,
- type => 'payment'
+ type => 'payment',
+ interface => 'test',
}
);
my $write_off_amount = 25;
my $write_off = $account->add_credit(
{ amount => $write_off_amount,
- type => 'writeoff'
+ type => 'writeoff',
+ interface => 'test',
}
);
$write_off->apply( { debits => $lost_fee_lines->reset, offset_type => 'Writeoff' } );
my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item->itemnumber, $patron->id );
my $credit_return = Koha::Account::Lines->find($credit_return_id);
- is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PF - payment (CR)' );
+ is( $account->balance, $processfee_amount - $payment_amount, 'Balance is PF - payment (LOST_RETURN)' );
$lost_fee_line->discard_changes;
is( $lost_fee_line->amountoutstanding + 0, 0, 'Lost fee has no outstanding amount' );
is( $lost_fee_line->accounttype,
- 'LR', 'Lost fee now has account type of LR ( Lost Returned )' );
+ 'LOST', 'Lost fee now still has account type of LOST' );
+ is( $lost_fee_line->status, 'RETURNED', "Lost fee now has account status of RETURNED");
- is( $credit_return->accounttype, 'CR', 'An account line of type CR is added' );
+ is( $credit_return->accounttype, 'LOST_RETURN', 'An account line of type LOST_RETURN is added' );
is( $credit_return->amount + 0,
($payment_amount + $outstanding ) * -1,
- 'The account line of type CR has an amount equal to the payment + outstanding'
+ 'The account line of type LOST_RETURN has an amount equal to the payment + outstanding'
);
is( $credit_return->amountoutstanding + 0,
$payment_amount * -1,
- 'The account line of type CR has an amountoutstanding equal to the payment'
+ 'The account line of type LOST_RETURN has an amountoutstanding equal to the payment'
);
is( $account->balance,
LostItem( $item_id, 1 );
my $lost_fee_lines = Koha::Account::Lines->search(
- { borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'L' } );
+ { borrowernumber => $patron->id, itemnumber => $item_id, accounttype => 'LOST' } );
is( $lost_fee_lines->count, 1, 'Only one lost item fee produced' );
my $lost_fee_line = $lost_fee_lines->next;
- is( $lost_fee_line->amount + 0, $replacement_amount, 'The right L amount is generated' );
+ is( $lost_fee_line->amount + 0, $replacement_amount, 'The right LOST amount is generated' );
is( $lost_fee_line->amountoutstanding + 0,
- $replacement_amount, 'The right L amountountstanding is generated' );
+ $replacement_amount, 'The right LOST amountountstanding is generated' );
my $account = $patron->account;
is( $account->balance, $replacement_amount, 'Balance is L' );
my $payment_amount = 27;
my $payment = $account->add_credit(
{ amount => $payment_amount,
- type => 'payment'
+ type => 'payment',
+ interface => 'test',
}
);
$payment->apply({ debits => $lost_fee_lines->reset, offset_type => 'Payment' });
'Payment applied'
);
- # TODO use add_debit when time comes
my $manual_debit_amount = 80;
- C4::Accounts::manualinvoice( $patron->id, undef, undef, 'FU', $manual_debit_amount );
+ $account->add_debit( { amount => $manual_debit_amount, type => 'overdue', interface =>'test' } );
is( $account->balance, $manual_debit_amount + $replacement_amount - $payment_amount, 'Manual debit applied' );
my $credit_return_id = C4::Circulation::_FixAccountForLostAndReturned( $item_id, $patron->id );
my $credit_return = Koha::Account::Lines->find($credit_return_id);
- is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PF - payment (CR)' );
+ is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PF - payment (LOST_RETURN)' );
- my $manual_debit = Koha::Account::Lines->search({ borrowernumber => $patron->id, accounttype => 'FU' })->next;
+ my $manual_debit = Koha::Account::Lines->search({ borrowernumber => $patron->id, accounttype => 'OVERDUE', status => 'UNRETURNED' })->next;
is( $manual_debit->amountoutstanding + 0, $manual_debit_amount - $payment_amount, 'reconcile_balance was called' );
};
};
subtest '_FixOverduesOnReturn' => sub {
- plan tests => 10;
+ plan tests => 11;
+
+ my $manager = $builder->build_object({ class => "Koha::Patrons" });
+ t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
my $biblio = $builder->build_sample_biblio({ author => 'Hall, Kylie' });
my $accountline = Koha::Account::Line->new(
{
borrowernumber => $patron->{borrowernumber},
- accounttype => 'FU',
+ accounttype => 'OVERDUE',
+ status => 'UNRETURNED',
itemnumber => $item->itemnumber,
amount => 99.00,
amountoutstanding => 99.00,
- lastincrement => 9.00,
+ interface => 'test',
}
)->store();
- C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber );
+ C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, undef, 'RETURNED' );
$accountline->_result()->discard_changes();
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' );
- is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )');
-
+ isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )');
+ is( $accountline->status, 'RETURNED', 'Passed status has been used to set as RETURNED )');
## Run again, with exemptfine enabled
$accountline->set(
{
- accounttype => 'FU',
+ accounttype => 'OVERDUE',
+ status => 'UNRETURNED',
amountoutstanding => 99.00,
}
)->store();
- C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 1 );
+ C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 1, 'RETURNED' );
$accountline->_result()->discard_changes();
my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next();
- is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' );
- is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )');
+ is( $accountline->amountoutstanding + 0, 0, 'Fine amountoutstanding has been reduced to 0' );
+ isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )');
+ is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )');
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" );
- is( $offset->amount, '-99.000000', "Amount of offset is correct" );
+ is( $offset->amount + 0, -99, "Amount of offset is correct" );
+ my $credit = $offset->credit;
+ is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" );
+ is( $credit->amount + 0, -99, "Credit amount is set correctly" );
+ is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" );
+};
- ## Run again, with dropbox mode enabled
- $accountline->set(
+subtest '_FixAccountForLostAndReturned returns undef if patron is deleted' => sub {
+ plan tests => 1;
+
+ my $manager = $builder->build_object({ class => "Koha::Patrons" });
+ t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode });
+
+ my $biblio = $builder->build_sample_biblio({ author => 'Hall, Kylie' });
+
+ my $branchcode = $library2->{branchcode};
+
+ my $item = $builder->build_sample_item(
{
- accounttype => 'FU',
+ biblionumber => $biblio->biblionumber,
+ library => $branchcode,
+ replacementprice => 99.00,
+ itype => $itemtype,
+ }
+ );
+
+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
+
+ ## Start with basic call, should just close out the open fine
+ my $accountline = Koha::Account::Line->new(
+ {
+ borrowernumber => $patron->id,
+ accounttype => 'L',
+ status => undef,
+ itemnumber => $item->itemnumber,
+ amount => 99.00,
amountoutstanding => 99.00,
+ interface => 'test',
}
)->store();
- C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 0, 1 );
+ $patron->delete();
- $accountline->_result()->discard_changes();
- $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Dropbox' })->next();
+ my $return_value = C4::Circulation::_FixAccountForLostAndReturned( $patron->id, $item->itemnumber );
+
+ is( $return_value, undef, "_FixAccountForLostAndReturned returns undef if patron is deleted" );
- 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 {
is( $item->onloan, undef, 'AddReturn did clear items.onloan' );
};
-$schema->storage->txn_rollback;
-C4::Context->clear_syspref_cache();
-$cache->clear_from_cache('single_holidays');
subtest 'AddRenewal and AddIssuingCharge tests' => sub {
plan tests => 13;
- $schema->storage->txn_begin;
t::lib::Mocks::mock_preference('item-level_itypes', 1);
# Check the item out
AddIssue( $patron->unblessed, $item->barcode );
t::lib::Mocks::mock_preference( 'RenewalLog', 0 );
- my $date = output_pref( { dt => dt_from_string(), datenonly => 1, dateformat => 'iso' } );
+ my $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } );
my %params_renewal = (
timestamp => { -like => $date . "%" },
module => "CIRCULATION",
unlike ( $checkouts->next->lastreneweddate, qr/00:00:00/, 'AddRenewal should set the renewal date with the time part');
t::lib::Mocks::mock_preference( 'RenewalLog', 1 );
- $date = output_pref( { dt => dt_from_string(), datenonly => 1, dateformat => 'iso' } );
+ $date = output_pref( { dt => dt_from_string(), dateonly => 1, dateformat => 'iso' } );
$old_log_size = Koha::ActionLogs->count( \%params_renewal );
AddRenewal( $patron->id, $item->id, $library->id );
$new_log_size = Koha::ActionLogs->count( \%params_renewal );
is( $line->branchcode, $library->id, 'AddRenewal correctly sets branchcode' );
is( $line->description, "Renewal of Rental Item $title $barcode", 'AddRenewal set a hardcoded description for the accountline' );
- $schema->storage->txn_rollback;
};
subtest 'ProcessOfflinePayment() tests' => sub {
plan tests => 4;
- $schema->storage->txn_begin;
my $amount = 123;
is( $line->amount+0, $amount * -1, 'amount picked from params' );
is( $line->branchcode, $library->id, 'branchcode set correctly' );
- $schema->storage->txn_rollback;
-};
-
-
-
-sub set_userenv {
- my ( $library ) = @_;
- t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} });
-}
-
-sub str {
- my ( $error, $question, $alert ) = @_;
- my $s;
- $s = %$error ? ' (error: ' . join( ' ', keys %$error ) . ')' : '';
- $s .= %$question ? ' (question: ' . join( ' ', keys %$question ) . ')' : '';
- $s .= %$alert ? ' (alert: ' . join( ' ', keys %$alert ) . ')' : '';
- return $s;
-}
-
-sub test_debarment_on_checkout {
- my ($params) = @_;
- my $item = $params->{item};
- my $library = $params->{library};
- my $patron = $params->{patron};
- my $due_date = $params->{due_date} || dt_from_string;
- my $return_date = $params->{return_date} || dt_from_string;
- my $expected_expiration_date = $params->{expiration_date};
-
- $expected_expiration_date = output_pref(
- {
- dt => $expected_expiration_date,
- dateformat => 'sql',
- dateonly => 1,
- }
- );
- my @caller = caller;
- my $line_number = $caller[2];
- AddIssue( $patron, $item->{barcode}, $due_date );
-
- my ( undef, $message ) = AddReturn( $item->{barcode}, $library->{branchcode},
- undef, 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(
- { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } );
- is( scalar(@$debarments), 1, 'Test at line ' . $line_number );
-
- is( $debarments->[0]->{expiration},
- $expected_expiration_date, 'Test at line ' . $line_number );
- Koha::Patron::Debarments::DelUniqueDebarment(
- { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } );
};
subtest 'Incremented fee tests' => sub {
is_deeply( $needsconfirmation, { RENTALCHARGE => '3' }, 'Item needs rentalcharge confirmation to be issued, increment' );
$itemtype->rentalcharge_daily('0')->store;
};
+
+$schema->storage->txn_rollback;
+C4::Context->clear_syspref_cache();
+$cache->clear_from_cache('single_holidays');