Lines 2078-2084
subtest 'AddReturn | is_overdue' => sub {
Link Here
|
2078 |
|
2078 |
|
2079 |
subtest '_FixAccountForLostAndReturned' => sub { |
2079 |
subtest '_FixAccountForLostAndReturned' => sub { |
2080 |
|
2080 |
|
2081 |
plan tests => 5; |
2081 |
plan tests => 14; |
2082 |
|
2082 |
|
2083 |
t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', 1 ); |
2083 |
t::lib::Mocks::mock_preference( 'WhenLostChargeReplacementFee', 1 ); |
2084 |
t::lib::Mocks::mock_preference( 'WhenLostForgiveFine', 0 ); |
2084 |
t::lib::Mocks::mock_preference( 'WhenLostForgiveFine', 0 ); |
Lines 2464-2469
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
2464 |
my $manual_debit = Koha::Account::Lines->search({ borrowernumber => $patron->id, accounttype => 'OVERDUE', status => 'UNRETURNED' })->next; |
2464 |
my $manual_debit = Koha::Account::Lines->search({ borrowernumber => $patron->id, accounttype => 'OVERDUE', status => 'UNRETURNED' })->next; |
2465 |
is( $manual_debit->amountoutstanding + 0, $manual_debit_amount - $payment_amount, 'reconcile_balance was called' ); |
2465 |
is( $manual_debit->amountoutstanding + 0, $manual_debit_amount - $payment_amount, 'reconcile_balance was called' ); |
2466 |
}; |
2466 |
}; |
|
|
2467 |
|
2468 |
|
2469 |
is( $accountline->amountoutstanding, '0.000000', 'Lost fee has no outstanding amount' ); |
2470 |
is( $accountline->accounttype, 'LR', 'Lost fee now has account type of LR ( Lost Returned )' ); |
2471 |
is( $patron->account->balance, 0, 'Account balance should be 0 after return of lost item' ); |
2472 |
|
2473 |
# Tests for only if unpaid |
2474 |
## Unpaid |
2475 |
$accountline->delete(); |
2476 |
$accountline = Koha::Account::Line->new( |
2477 |
{ |
2478 |
borrowernumber => $patron->borrowernumber, |
2479 |
accounttype => 'L', |
2480 |
itemnumber => $itemnumber, |
2481 |
amount => 99.00, |
2482 |
amountoutstanding => 99.00, |
2483 |
} |
2484 |
)->store(); |
2485 |
|
2486 |
C4::Circulation::_FixAccountForLostAndReturned( $itemnumber, $patron->borrowernumber, undef, 1 ); |
2487 |
|
2488 |
$accountline->_result()->discard_changes(); |
2489 |
|
2490 |
is( $accountline->amountoutstanding, '0.000000', 'Lost fee has no outstanding amount, with skip_paid = 1 and unpaid' ); |
2491 |
is( $accountline->accounttype, 'LR', 'Lost fee now has account type of LR ( Lost Returned ), with skip_paid = 1 and unpaid'); |
2492 |
is( $patron->account->balance, 0, 'Account balance should be 0 after return of unpaid lost item' ); |
2493 |
|
2494 |
## Paid |
2495 |
$accountline->delete(); |
2496 |
$accountline = Koha::Account::Line->new( |
2497 |
{ |
2498 |
borrowernumber => $patron->borrowernumber, |
2499 |
accounttype => 'L', |
2500 |
itemnumber => $itemnumber, |
2501 |
amount => 99.00, |
2502 |
amountoutstanding => 0.00, |
2503 |
} |
2504 |
)->store(); |
2505 |
|
2506 |
C4::Circulation::_FixAccountForLostAndReturned( $itemnumber, $patron->borrowernumber, undef, 1 ); |
2507 |
|
2508 |
$accountline->_result()->discard_changes(); |
2509 |
|
2510 |
is( $accountline->amountoutstanding, '0.000000', 'Lost fee still has outstanding amount of 0, with skip_paid = 1 and already paid' ); |
2511 |
is( $accountline->accounttype, 'L', 'Lost fee now has account type of L ( Lost ), with skip_paid = 1 and already paid'); |
2512 |
is( $patron->account->balance, 0, 'Account balance should be 0 after return of partially paid lost item' ); |
2513 |
|
2514 |
## Partially paid |
2515 |
$accountline->delete(); |
2516 |
$accountline = Koha::Account::Line->new( |
2517 |
{ |
2518 |
borrowernumber => $patron->borrowernumber, |
2519 |
accounttype => 'L', |
2520 |
itemnumber => $itemnumber, |
2521 |
amount => 99.00, |
2522 |
amountoutstanding => 33.00, |
2523 |
} |
2524 |
)->store(); |
2525 |
|
2526 |
C4::Circulation::_FixAccountForLostAndReturned( $itemnumber, $patron->borrowernumber, undef, 1 ); |
2527 |
|
2528 |
$accountline->_result()->discard_changes(); |
2529 |
|
2530 |
is( $accountline->amountoutstanding, '0.000000', 'Lost fee has no outstanding amount, with skip_paid = 1 and partially paid' ); |
2531 |
is( $accountline->accounttype, 'LR', 'Lost fee now has account type of L ( Lost ), with skip_paid = 1 and partially paid'); |
2467 |
}; |
2532 |
}; |
2468 |
|
2533 |
|
2469 |
subtest '_FixOverduesOnReturn' => sub { |
2534 |
subtest '_FixOverduesOnReturn' => sub { |