From 77c5bf811dff806f638ffd6c51ca6d36a21f2435 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 6 Dec 2019 15:35:27 +0000 Subject: [PATCH] Bug 24146: Illustrate increasing and decreasing fine Signed-off-by: Nick Clemens --- t/db_dependent/Overdues.t | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Overdues.t b/t/db_dependent/Overdues.t index 48c957d61d..88388163ba 100644 --- a/t/db_dependent/Overdues.t +++ b/t/db_dependent/Overdues.t @@ -132,7 +132,7 @@ $schema->storage->txn_rollback; subtest 'UpdateFine tests' => sub { - plan tests => 53; + plan tests => 59; $schema->storage->txn_begin; @@ -358,7 +358,7 @@ subtest 'UpdateFine tests' => sub { issue_id => $checkout1->issue_id, itemnumber => $item1->itemnumber, borrowernumber => $patron->borrowernumber, - amount => '30', + amount => '50', due => $checkout1->date_due } ); @@ -373,7 +373,34 @@ subtest 'UpdateFine tests' => sub { $fine2 = $fines->next; is( $fine2->amount, '30.000000', "Second fine amount unchanged" ); $fine3 = $fines->next; - is( $fine3->amount, '30.000000', "Third fine increased now MaxFine cap is disabled" ); + is( $fine3->amount, '50.000000', "Third fine increased now MaxFine cap is disabled" ); + is( $fine3->amountoutstanding, '30.000000', "Third fine increased now MaxFine cap is disabled" ); + + # If somehow the fine should be reduced, we changed rules or checkout date or something + UpdateFine( + { + issue_id => $checkout1->issue_id, + itemnumber => $item1->itemnumber, + borrowernumber => $patron->borrowernumber, + amount => '30', + due => $checkout1->date_due + } + ); + + $fines = Koha::Account::Lines->search( + { borrowernumber => $patron->borrowernumber }, + { order_by => { '-asc' => 'accountlines_id' } } + ); + is( $fines->count, 3, "Still only three fines after MaxFine cap removed and third fine altered" ); + $fine = $fines->next; + is( $fine->amount, '80.000000', "First fine amount unchanged" ); + $fine2 = $fines->next; + is( $fine2->amount, '30.000000', "Second fine amount unchanged" ); + $fine3 = $fines->next; + is( $fine3->amount, '30.000000', "Third fine reduced" ); + is( $fine3->amountoutstanding, '10.000000', "Third fine amount outstanding is reduced" ); + + $schema->storage->txn_rollback; }; -- 2.11.0