|
Lines 502-509
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
| 502 |
|
502 |
|
| 503 |
my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } ); |
503 |
my $fines = Koha::Account::Lines->search( { borrowernumber => $renewing_borrower->{borrowernumber}, itemnumber => $item_7->itemnumber } ); |
| 504 |
is( $fines->count, 2 ); |
504 |
is( $fines->count, 2 ); |
| 505 |
is( $fines->next->accounttype, 'F', 'Fine on renewed item is closed out properly' ); |
505 |
isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' ); |
| 506 |
is( $fines->next->accounttype, 'F', 'Fine on renewed item is closed out properly' ); |
506 |
isnt( $fines->next->status, 'UNRETURNED', 'Fine on renewed item is closed out properly' ); |
| 507 |
$fines->delete(); |
507 |
$fines->delete(); |
| 508 |
|
508 |
|
| 509 |
|
509 |
|
|
Lines 688-694
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
| 688 |
item_id => $item_to_auto_renew->{itemnumber}, |
688 |
item_id => $item_to_auto_renew->{itemnumber}, |
| 689 |
description => "Some fines" |
689 |
description => "Some fines" |
| 690 |
} |
690 |
} |
| 691 |
)->accounttype('F')->store; |
691 |
)->status('RETURNED')->store; |
| 692 |
( $renewokay, $error ) = |
692 |
( $renewokay, $error ) = |
| 693 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
693 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 694 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
694 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
|
Lines 701-707
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
| 701 |
item_id => $item_to_auto_renew->{itemnumber}, |
701 |
item_id => $item_to_auto_renew->{itemnumber}, |
| 702 |
description => "Some fines" |
702 |
description => "Some fines" |
| 703 |
} |
703 |
} |
| 704 |
)->accounttype('F')->store; |
704 |
)->status('RETURNED')->store; |
| 705 |
( $renewokay, $error ) = |
705 |
( $renewokay, $error ) = |
| 706 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
706 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 707 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
707 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
|
Lines 714-720
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
| 714 |
item_id => $item_to_auto_renew->{itemnumber}, |
714 |
item_id => $item_to_auto_renew->{itemnumber}, |
| 715 |
description => "Some fines" |
715 |
description => "Some fines" |
| 716 |
} |
716 |
} |
| 717 |
)->accounttype('F')->store; |
717 |
)->status('RETURNED')->store; |
| 718 |
( $renewokay, $error ) = |
718 |
( $renewokay, $error ) = |
| 719 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
719 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
| 720 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
720 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
|
Lines 848-854
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
| 848 |
); |
848 |
); |
| 849 |
|
849 |
|
| 850 |
my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next(); |
850 |
my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next(); |
| 851 |
is( $line->accounttype, 'FU', 'Account line type is FU' ); |
851 |
is( $line->accounttype, 'OVERDUE', 'Account line type is OVERDUE' ); |
|
|
852 |
is( $line->status, 'UNRETURNED', 'Account line status is UNRETURNED' ); |
| 852 |
is( $line->lastincrement, '15.000000', 'Account line last increment is 15.00' ); |
853 |
is( $line->lastincrement, '15.000000', 'Account line last increment is 15.00' ); |
| 853 |
is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' ); |
854 |
is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' ); |
| 854 |
is( $line->amount, '15.000000', 'Account line amount is 15.00' ); |
855 |
is( $line->amount, '15.000000', 'Account line amount is 15.00' ); |
|
Lines 864-870
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
| 864 |
LostItem( $item_1->itemnumber, 'test', 1 ); |
865 |
LostItem( $item_1->itemnumber, 'test', 1 ); |
| 865 |
|
866 |
|
| 866 |
$line = Koha::Account::Lines->find($line->id); |
867 |
$line = Koha::Account::Lines->find($line->id); |
| 867 |
is( $line->accounttype, 'F', 'Account type correctly changed from FU to F' ); |
868 |
is( $line->accounttype, 'OVERDUE', 'Account type remains as OVERDUE' ); |
|
|
869 |
isnt( $line->status, 'UNRETURNED', 'Account status correctly changed from UNRETURNED to RETURNED' ); |
| 868 |
|
870 |
|
| 869 |
my $item = Koha::Items->find($item_1->itemnumber); |
871 |
my $item = Koha::Items->find($item_1->itemnumber); |
| 870 |
ok( !$item->onloan(), "Lost item marked as returned has false onloan value" ); |
872 |
ok( !$item->onloan(), "Lost item marked as returned has false onloan value" ); |
|
Lines 1973-1979
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
| 1973 |
# specify dropbox date 5 days later => overdue, or... not |
1975 |
# specify dropbox date 5 days later => overdue, or... not |
| 1974 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
1976 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
| 1975 |
AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago ); |
1977 |
AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago ); |
| 1976 |
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 |
1978 |
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 |
| 1977 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1979 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
| 1978 |
}; |
1980 |
}; |
| 1979 |
|
1981 |
|
|
Lines 2350-2356
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
| 2350 |
|
2352 |
|
| 2351 |
is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PF - payment (CR)' ); |
2353 |
is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PF - payment (CR)' ); |
| 2352 |
|
2354 |
|
| 2353 |
my $manual_debit = Koha::Account::Lines->search({ borrowernumber => $patron->id, accounttype => 'FU' })->next; |
2355 |
my $manual_debit = Koha::Account::Lines->search({ borrowernumber => $patron->id, accounttype => 'OVERDUE', status => 'UNRETURNED' })->next; |
| 2354 |
is( $manual_debit->amountoutstanding + 0, $manual_debit_amount - $payment_amount, 'reconcile_balance was called' ); |
2356 |
is( $manual_debit->amountoutstanding + 0, $manual_debit_amount - $payment_amount, 'reconcile_balance was called' ); |
| 2355 |
}; |
2357 |
}; |
| 2356 |
}; |
2358 |
}; |
|
Lines 2377-2383
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
| 2377 |
my $accountline = Koha::Account::Line->new( |
2379 |
my $accountline = Koha::Account::Line->new( |
| 2378 |
{ |
2380 |
{ |
| 2379 |
borrowernumber => $patron->{borrowernumber}, |
2381 |
borrowernumber => $patron->{borrowernumber}, |
| 2380 |
accounttype => 'FU', |
2382 |
accounttype => 'OVERDUE', |
|
|
2383 |
status => 'UNRETURNED', |
| 2381 |
itemnumber => $item->itemnumber, |
2384 |
itemnumber => $item->itemnumber, |
| 2382 |
amount => 99.00, |
2385 |
amount => 99.00, |
| 2383 |
amountoutstanding => 99.00, |
2386 |
amountoutstanding => 99.00, |
|
Lines 2390-2402
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
| 2390 |
$accountline->_result()->discard_changes(); |
2393 |
$accountline->_result()->discard_changes(); |
| 2391 |
|
2394 |
|
| 2392 |
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); |
2395 |
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); |
| 2393 |
is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); |
2396 |
is( $accountline->status, 'RETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status RETURNED )'); |
| 2394 |
|
2397 |
|
| 2395 |
|
2398 |
|
| 2396 |
## Run again, with exemptfine enabled |
2399 |
## Run again, with exemptfine enabled |
| 2397 |
$accountline->set( |
2400 |
$accountline->set( |
| 2398 |
{ |
2401 |
{ |
| 2399 |
accounttype => 'FU', |
2402 |
accounttype => 'OVERDUE', |
|
|
2403 |
status => 'UNRETURNED', |
| 2400 |
amountoutstanding => 99.00, |
2404 |
amountoutstanding => 99.00, |
| 2401 |
} |
2405 |
} |
| 2402 |
)->store(); |
2406 |
)->store(); |
|
Lines 2407-2413
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
| 2407 |
my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next(); |
2411 |
my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next(); |
| 2408 |
|
2412 |
|
| 2409 |
is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' ); |
2413 |
is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' ); |
| 2410 |
is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )'); |
2414 |
is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )'); |
| 2411 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2415 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
| 2412 |
is( $offset->amount, '-99.000000', "Amount of offset is correct" ); |
2416 |
is( $offset->amount, '-99.000000', "Amount of offset is correct" ); |
| 2413 |
}; |
2417 |
}; |