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 689-695
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
689 |
item_id => $item_to_auto_renew->{itemnumber}, |
689 |
item_id => $item_to_auto_renew->{itemnumber}, |
690 |
description => "Some fines" |
690 |
description => "Some fines" |
691 |
} |
691 |
} |
692 |
)->accounttype('F')->store; |
692 |
)->status('RETURNED')->store; |
693 |
( $renewokay, $error ) = |
693 |
( $renewokay, $error ) = |
694 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
694 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
695 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
695 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 703-709
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
703 |
item_id => $item_to_auto_renew->{itemnumber}, |
703 |
item_id => $item_to_auto_renew->{itemnumber}, |
704 |
description => "Some fines" |
704 |
description => "Some fines" |
705 |
} |
705 |
} |
706 |
)->accounttype('F')->store; |
706 |
)->status('RETURNED')->store; |
707 |
( $renewokay, $error ) = |
707 |
( $renewokay, $error ) = |
708 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
708 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
709 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
709 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 717-723
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
717 |
item_id => $item_to_auto_renew->{itemnumber}, |
717 |
item_id => $item_to_auto_renew->{itemnumber}, |
718 |
description => "Some fines" |
718 |
description => "Some fines" |
719 |
} |
719 |
} |
720 |
)->accounttype('F')->store; |
720 |
)->status('RETURNED')->store; |
721 |
( $renewokay, $error ) = |
721 |
( $renewokay, $error ) = |
722 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
722 |
CanBookBeRenewed( $renewing_borrowernumber, $item_to_auto_renew->{itemnumber} ); |
723 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
723 |
is( $renewokay, 0, 'Do not renew, renewal is automatic' ); |
Lines 851-857
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
851 |
); |
851 |
); |
852 |
|
852 |
|
853 |
my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next(); |
853 |
my $line = Koha::Account::Lines->search({ borrowernumber => $renewing_borrower->{borrowernumber} })->next(); |
854 |
is( $line->accounttype, 'FU', 'Account line type is FU' ); |
854 |
is( $line->accounttype, 'OVERDUE', 'Account line type is OVERDUE' ); |
|
|
855 |
is( $line->status, 'UNRETURNED', 'Account line status is UNRETURNED' ); |
855 |
is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' ); |
856 |
is( $line->amountoutstanding, '15.000000', 'Account line amount outstanding is 15.00' ); |
856 |
is( $line->amount, '15.000000', 'Account line amount is 15.00' ); |
857 |
is( $line->amount, '15.000000', 'Account line amount is 15.00' ); |
857 |
is( $line->issue_id, $issue->id, 'Account line issue id matches' ); |
858 |
is( $line->issue_id, $issue->id, 'Account line issue id matches' ); |
Lines 866-872
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
866 |
LostItem( $item_1->itemnumber, 'test', 1 ); |
867 |
LostItem( $item_1->itemnumber, 'test', 1 ); |
867 |
|
868 |
|
868 |
$line = Koha::Account::Lines->find($line->id); |
869 |
$line = Koha::Account::Lines->find($line->id); |
869 |
is( $line->accounttype, 'F', 'Account type correctly changed from FU to F' ); |
870 |
is( $line->accounttype, 'OVERDUE', 'Account type remains as OVERDUE' ); |
|
|
871 |
isnt( $line->status, 'UNRETURNED', 'Account status correctly changed from UNRETURNED to RETURNED' ); |
870 |
|
872 |
|
871 |
my $item = Koha::Items->find($item_1->itemnumber); |
873 |
my $item = Koha::Items->find($item_1->itemnumber); |
872 |
ok( !$item->onloan(), "Lost item marked as returned has false onloan value" ); |
874 |
ok( !$item->onloan(), "Lost item marked as returned has false onloan value" ); |
Lines 1975-1981
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
1975 |
# specify dropbox date 5 days later => overdue, or... not |
1977 |
# specify dropbox date 5 days later => overdue, or... not |
1976 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
1978 |
AddIssue( $patron->unblessed, $item->{barcode}, $ten_days_ago ); # date due was 10d ago |
1977 |
AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago ); |
1979 |
AddReturn( $item->{barcode}, $library->{branchcode}, $five_days_ago ); |
1978 |
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 |
1980 |
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 |
1979 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1981 |
Koha::Account::Lines->search({ borrowernumber => $patron->borrowernumber })->delete; |
1980 |
}; |
1982 |
}; |
1981 |
|
1983 |
|
Lines 2357-2363
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
2357 |
|
2359 |
|
2358 |
is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PF - payment (CR)' ); |
2360 |
is( $account->balance, $manual_debit_amount - $payment_amount, 'Balance is PF - payment (CR)' ); |
2359 |
|
2361 |
|
2360 |
my $manual_debit = Koha::Account::Lines->search({ borrowernumber => $patron->id, accounttype => 'FU' })->next; |
2362 |
my $manual_debit = Koha::Account::Lines->search({ borrowernumber => $patron->id, accounttype => 'OVERDUE', status => 'UNRETURNED' })->next; |
2361 |
is( $manual_debit->amountoutstanding + 0, $manual_debit_amount - $payment_amount, 'reconcile_balance was called' ); |
2363 |
is( $manual_debit->amountoutstanding + 0, $manual_debit_amount - $payment_amount, 'reconcile_balance was called' ); |
2362 |
}; |
2364 |
}; |
2363 |
}; |
2365 |
}; |
Lines 2384-2390
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2384 |
my $accountline = Koha::Account::Line->new( |
2386 |
my $accountline = Koha::Account::Line->new( |
2385 |
{ |
2387 |
{ |
2386 |
borrowernumber => $patron->{borrowernumber}, |
2388 |
borrowernumber => $patron->{borrowernumber}, |
2387 |
accounttype => 'FU', |
2389 |
accounttype => 'OVERDUE', |
|
|
2390 |
status => 'UNRETURNED', |
2388 |
itemnumber => $item->itemnumber, |
2391 |
itemnumber => $item->itemnumber, |
2389 |
amount => 99.00, |
2392 |
amount => 99.00, |
2390 |
amountoutstanding => 99.00, |
2393 |
amountoutstanding => 99.00, |
Lines 2397-2409
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2397 |
$accountline->_result()->discard_changes(); |
2400 |
$accountline->_result()->discard_changes(); |
2398 |
|
2401 |
|
2399 |
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); |
2402 |
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); |
2400 |
is( $accountline->accounttype, 'F', 'Open fine ( account type FU ) has been closed out ( account type F )'); |
2403 |
is( $accountline->status, 'RETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status RETURNED )'); |
2401 |
|
2404 |
|
2402 |
|
2405 |
|
2403 |
## Run again, with exemptfine enabled |
2406 |
## Run again, with exemptfine enabled |
2404 |
$accountline->set( |
2407 |
$accountline->set( |
2405 |
{ |
2408 |
{ |
2406 |
accounttype => 'FU', |
2409 |
accounttype => 'OVERDUE', |
|
|
2410 |
status => 'UNRETURNED', |
2407 |
amountoutstanding => 99.00, |
2411 |
amountoutstanding => 99.00, |
2408 |
} |
2412 |
} |
2409 |
)->store(); |
2413 |
)->store(); |
Lines 2414-2420
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2414 |
my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next(); |
2418 |
my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next(); |
2415 |
|
2419 |
|
2416 |
is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' ); |
2420 |
is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' ); |
2417 |
is( $accountline->accounttype, 'FFOR', 'Open fine ( account type FU ) has been set to fine forgiven ( account type FFOR )'); |
2421 |
is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )'); |
2418 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2422 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2419 |
is( $offset->amount, '-99.000000', "Amount of offset is correct" ); |
2423 |
is( $offset->amount, '-99.000000', "Amount of offset is correct" ); |
2420 |
}; |
2424 |
}; |