Lines 507-514
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
507 |
|
507 |
|
508 |
my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } ); |
508 |
my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } ); |
509 |
is( $fines->count, 2 ); |
509 |
is( $fines->count, 2 ); |
510 |
is( $fines->next->accounttype, 'F', 'Fine on renewed item is closed out properly' ); |
510 |
isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' ); |
511 |
is( $fines->next->accounttype, 'F', 'Fine on renewed item is closed out properly' ); |
511 |
isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' ); |
512 |
$fines->delete(); |
512 |
$fines->delete(); |
513 |
|
513 |
|
514 |
|
514 |
|
Lines 694-700
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
694 |
item_id => $item_to_auto_renew->{itemnumber}, |
694 |
item_id => $item_to_auto_renew->{itemnumber}, |
695 |
description => "Some fines" |
695 |
description => "Some fines" |
696 |
} |
696 |
} |
697 |
)->accounttype('F')->store; |
697 |
)->status('RETURNED')->store; |
698 |
( $renewokay, $error ) = |
698 |
( $renewokay, $error ) = |
699 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
699 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
700 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
700 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 708-714
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
708 |
item_id => $item_to_auto_renew->{itemnumber}, |
708 |
item_id => $item_to_auto_renew->{itemnumber}, |
709 |
description => "Some fines" |
709 |
description => "Some fines" |
710 |
} |
710 |
} |
711 |
)->accounttype('F')->store; |
711 |
)->status('RETURNED')->store; |
712 |
( $renewokay, $error ) = |
712 |
( $renewokay, $error ) = |
713 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
713 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
714 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
714 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 722-728
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
722 |
item_id => $item_to_auto_renew->{itemnumber}, |
722 |
item_id => $item_to_auto_renew->{itemnumber}, |
723 |
description => "Some fines" |
723 |
description => "Some fines" |
724 |
} |
724 |
} |
725 |
)->accounttype('F')->store; |
725 |
)->status('RETURNED')->store; |
726 |
( $renewokay, $error ) = |
726 |
( $renewokay, $error ) = |
727 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
727 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
728 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
728 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 856-862
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
856 |
); |
856 |
); |
857 |
|
857 |
|
858 |
my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next(); |
858 |
my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next(); |
859 |
is( $line->accounttype, 'FU', 'Account line type is FU' ); |
859 |
is( $line->accounttype, 'OVERDUE', 'Account line type is OVERDUE' ); |
|
|
860 |
is( $line->status, 'UNRETURNED', 'Account line status is UNRETURNED' ); |
860 |
is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' ); |
861 |
is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' ); |
861 |
is( $line->amount, '15.000000', 'Account line amount is 15.00' ); |
862 |
is( $line->amount, '15.000000', 'Account line amount is 15.00' ); |
862 |
is( $line->issue_id, $issue->id, 'Account line issue id matches' ); |
863 |
is( $line->issue_id, $issue->id, 'Account line issue id matches' ); |
Lines 871-877
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
871 |
LostItem( $item_1->itemnumber, 'test', 1 ); |
872 |
LostItem( $item_1->itemnumber, 'test', 1 ); |
872 |
|
873 |
|
873 |
$line = Koha::Account::Lines->find($line->id); |
874 |
$line = Koha::Account::Lines->find($line->id); |
874 |
is( $line->accounttype, 'F', 'Account type correctly changed from FU to F' ); |
875 |
is( $line->accounttype, 'OVERDUE', 'Account type remains as OVERDUE' ); |
|
|
876 |
isnt( $line->status, 'UNRETURNED', 'Account status correctly changed from UNRETURNED to RETURNED' ); |
875 |
|
877 |
|
876 |
my $item = Koha::Items->find($item_1->itemnumber); |
878 |
my $item = Koha::Items->find($item_1->itemnumber); |
877 |
ok( !$item->onloan(), "Lost item marked as returned has false onloan value" ); |
879 |
ok( !$item->onloan(), "Lost item marked as returned has false onloan value" ); |
Lines 1988-1994
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
1988 |
# specify dropbox date 5 days later => overdue, or... not |
1990 |
# specify dropbox date 5 days later => overdue, or... not |
1989 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
1991 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
1990 |
AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago ); |
1992 |
AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago ); |
1991 |
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 |
1993 |
is( int($patron->account->balance()), 0, 'AddReturn: pass return_date => no overdue in dropbox mode' ); # FIXME? This is weird, the OVERDUE fine is created ( _CalculateAndUpdateFine > C4::Overdues::UpdateFine ) then remove later (in _FixOverduesOnReturn). Looks like it is a feature |
1992 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1994 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1993 |
}; |
1995 |
}; |
1994 |
|
1996 |
|
Lines 2370-2376
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
2370 |
|
2372 |
|
2371 |
is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PF - payment (CR)' ); |
2373 |
is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PF - payment (CR)' ); |
2372 |
|
2374 |
|
2373 |
my $manual_debit = Koha::Account::Lines->search({ borrowernumber => $patron->id, accounttype => 'FU' })->next; |
2375 |
my $manual_debit = Koha::Account::Lines->search({ borrowernumber => $patron->id, accounttype => 'OVERDUE', status => 'UNRETURNED' })->next; |
2374 |
is( $manual_debit->amountoutstanding + 0, $manual_debit_amount - $payment_amount, 'reconcile_balance was called' ); |
2376 |
is( $manual_debit->amountoutstanding + 0, $manual_debit_amount - $payment_amount, 'reconcile_balance was called' ); |
2375 |
}; |
2377 |
}; |
2376 |
}; |
2378 |
}; |
Lines 2397-2403
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2397 |
my $accountline = Koha::Account::Line->new( |
2399 |
my $accountline = Koha::Account::Line->new( |
2398 |
{ |
2400 |
{ |
2399 |
borrowernumber => $patron->{borrowernumber}, |
2401 |
borrowernumber => $patron->{borrowernumber}, |
2400 |
accounttype => 'FU', |
2402 |
accounttype => 'OVERDUE', |
|
|
2403 |
status => 'UNRETURNED', |
2401 |
itemnumber => $item->itemnumber, |
2404 |
itemnumber => $item->itemnumber, |
2402 |
amount => 99.00, |
2405 |
amount => 99.00, |
2403 |
amountoutstanding => 99.00, |
2406 |
amountoutstanding => 99.00, |
Lines 2410-2422
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2410 |
$accountline->_result()->discard_changes(); |
2413 |
$accountline->_result()->discard_changes(); |
2411 |
|
2414 |
|
2412 |
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); |
2415 |
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); |
2413 |
is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); |
2416 |
is( $accountline->status, 'RETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status RETURNED )'); |
2414 |
|
2417 |
|
2415 |
|
2418 |
|
2416 |
## Run again, with exemptfine enabled |
2419 |
## Run again, with exemptfine enabled |
2417 |
$accountline->set( |
2420 |
$accountline->set( |
2418 |
{ |
2421 |
{ |
2419 |
accounttype => 'FU', |
2422 |
accounttype => 'OVERDUE', |
|
|
2423 |
status => 'UNRETURNED', |
2420 |
amountoutstanding => 99.00, |
2424 |
amountoutstanding => 99.00, |
2421 |
} |
2425 |
} |
2422 |
)->store(); |
2426 |
)->store(); |
Lines 2427-2433
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2427 |
my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next(); |
2431 |
my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next(); |
2428 |
|
2432 |
|
2429 |
is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' ); |
2433 |
is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' ); |
2430 |
is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )'); |
2434 |
is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )'); |
2431 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2435 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2432 |
is( $offset->amount, '-99.000000', "Amount of offset is correct" ); |
2436 |
is( $offset->amount, '-99.000000', "Amount of offset is correct" ); |
2433 |
}; |
2437 |
}; |