Lines 2452-2458
subtest '_FixAccountForLostAndReturned' => sub {
Link Here
|
2452 |
}; |
2452 |
}; |
2453 |
|
2453 |
|
2454 |
subtest '_FixOverduesOnReturn' => sub { |
2454 |
subtest '_FixOverduesOnReturn' => sub { |
2455 |
plan tests => 9; |
2455 |
plan tests => 11; |
2456 |
|
2456 |
|
2457 |
my $manager = $builder->build_object({ class => "Koha::Patrons" }); |
2457 |
my $manager = $builder->build_object({ class => "Koha::Patrons" }); |
2458 |
t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode }); |
2458 |
t::lib::Mocks::mock_userenv({ patron => $manager, branchcode => $manager->branchcode }); |
Lines 2485-2496
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2485 |
} |
2485 |
} |
2486 |
)->store(); |
2486 |
)->store(); |
2487 |
|
2487 |
|
2488 |
C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber ); |
2488 |
C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, undef, 'RETURNED' ); |
2489 |
|
2489 |
|
2490 |
$accountline->_result()->discard_changes(); |
2490 |
$accountline->_result()->discard_changes(); |
2491 |
|
2491 |
|
2492 |
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); |
2492 |
is( $accountline->amountoutstanding, '99.000000', 'Fine has the same amount outstanding as previously' ); |
2493 |
is( $accountline->status, 'RETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status RETURNED )'); |
2493 |
isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )'); |
|
|
2494 |
is( $accountline->status, 'RETURNED', 'Passed status has been used to set as RETURNED )'); |
2494 |
|
2495 |
|
2495 |
## Run again, with exemptfine enabled |
2496 |
## Run again, with exemptfine enabled |
2496 |
$accountline->set( |
2497 |
$accountline->set( |
Lines 2501-2518
subtest '_FixOverduesOnReturn' => sub {
Link Here
|
2501 |
} |
2502 |
} |
2502 |
)->store(); |
2503 |
)->store(); |
2503 |
|
2504 |
|
2504 |
C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 1 ); |
2505 |
C4::Circulation::_FixOverduesOnReturn( $patron->{borrowernumber}, $item->itemnumber, 1, 'RETURNED' ); |
2505 |
|
2506 |
|
2506 |
$accountline->_result()->discard_changes(); |
2507 |
$accountline->_result()->discard_changes(); |
2507 |
my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next(); |
2508 |
my $offset = Koha::Account::Offsets->search({ debit_id => $accountline->id, type => 'Forgiven' })->next(); |
2508 |
|
2509 |
|
2509 |
is( $accountline->amountoutstanding + 0, 0, 'Fine has been reduced to 0' ); |
2510 |
is( $accountline->amountoutstanding + 0, 0, 'Fine amountoutstanding has been reduced to 0' ); |
|
|
2511 |
isnt( $accountline->status, 'UNRETURNED', 'Open fine ( account type OVERDUE ) has been closed out ( status not UNRETURNED )'); |
2510 |
is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )'); |
2512 |
is( $accountline->status, 'FORGIVEN', 'Open fine ( account type OVERDUE ) has been set to fine forgiven ( status FORGIVEN )'); |
2511 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2513 |
is( ref $offset, "Koha::Account::Offset", "Found matching offset for fine reduction via forgiveness" ); |
2512 |
is( $offset->amount, '-99.000000', "Amount of offset is correct" ); |
2514 |
is( $offset->amount + 0, -99, "Amount of offset is correct" ); |
2513 |
my $credit = $offset->credit; |
2515 |
my $credit = $offset->credit; |
2514 |
is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" ); |
2516 |
is( ref $credit, "Koha::Account::Line", "Found matching credit for fine forgiveness" ); |
2515 |
is( $credit->amount, '-99.000000', "Credit amount is set correctly" ); |
2517 |
is( $credit->amount + 0, -99, "Credit amount is set correctly" ); |
2516 |
is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" ); |
2518 |
is( $credit->amountoutstanding + 0, 0, "Credit amountoutstanding is correctly set to 0" ); |
2517 |
}; |
2519 |
}; |
2518 |
|
2520 |
|
2519 |
- |
|
|