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 1971-1977
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
1971 |
# specify dropbox date 5 days later => overdue, or... not |
1973 |
# specify dropbox date 5 days later => overdue, or... not |
1972 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
1974 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
1973 |
AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago ); |
1975 |
AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago ); |
1974 |
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 |
1976 |
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 |
1975 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1977 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1976 |
}; |
1978 |
}; |
1977 |
|
1979 |
|
Lines 2346-2352
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
2346 |
|
2348 |
|
2347 |
is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PF - payment (CR)' ); |
2349 |
is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PF - payment (CR)' ); |
2348 |
|
2350 |
|
2349 |
my $manual_debit = Koha::Account::Lines->search({ borrowernumber => $patron->id, accounttype => 'FU' })->next; |
2351 |
my $manual_debit = Koha::Account::Lines->search({ borrowernumber => $patron->id, accounttype => 'OVERDUE', status => 'UNRETURNED' })->next; |
2350 |
is( $manual_debit->amountoutstanding + 0, $manual_debit_amount - $payment_amount, 'reconcile_balance was called' ); |
2352 |
is( $manual_debit->amountoutstanding + 0, $manual_debit_amount - $payment_amount, 'reconcile_balance was called' ); |
2351 |
}; |
2353 |
}; |
2352 |
}; |
2354 |
}; |
Lines 2373-2379
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2373 |
my $accountline = Koha::Account::Line->new( |
2375 |
my $accountline = Koha::Account::Line->new( |
2374 |
{ |
2376 |
{ |
2375 |
borrowernumber => $patron->{borrowernumber}, |
2377 |
borrowernumber => $patron->{borrowernumber}, |
2376 |
accounttype => 'FU', |
2378 |
accounttype => 'OVERDUE', |
|
|
2379 |
status => 'UNRETURNED', |
2377 |
itemnumber => $item->itemnumber, |
2380 |
itemnumber => $item->itemnumber, |
2378 |
amount => 99.00, |
2381 |
amount => 99.00, |
2379 |
amountoutstanding => 99.00, |
2382 |
amountoutstanding => 99.00, |
Lines 2386-2398
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2386 |
$accountline->_result()->discard_changes(); |
2389 |
$accountline->_result()->discard_changes(); |
2387 |
|
2390 |
|
2388 |
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); |
2391 |
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); |
2389 |
is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); |
2392 |
is( $accountline->status, 'RETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status RETURNED )'); |
2390 |
|
2393 |
|
2391 |
|
2394 |
|
2392 |
## Run again, with exemptfine enabled |
2395 |
## Run again, with exemptfine enabled |
2393 |
$accountline->set( |
2396 |
$accountline->set( |
2394 |
{ |
2397 |
{ |
2395 |
accounttype => 'FU', |
2398 |
accounttype => 'OVERDUE', |
|
|
2399 |
status => 'UNRETURNED', |
2396 |
amountoutstanding => 99.00, |
2400 |
amountoutstanding => 99.00, |
2397 |
} |
2401 |
} |
2398 |
)->store(); |
2402 |
)->store(); |
Lines 2403-2409
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2403 |
my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next(); |
2407 |
my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next(); |
2404 |
|
2408 |
|
2405 |
is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' ); |
2409 |
is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' ); |
2406 |
is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )'); |
2410 |
is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )'); |
2407 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2411 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2408 |
is( $offset->amount, '-99.000000', "Amount of offset is correct" ); |
2412 |
is( $offset->amount, '-99.000000', "Amount of offset is correct" ); |
2409 |
}; |
2413 |
}; |