Bugzilla – Attachment 114018 Details for
Bug 27079
UpdateFine adds refunds for fines paid off before return
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27079: Unit tests
Bug-27079-Unit-tests.patch (text/plain), 3.28 KB, created by
Victor Grousset/tuxayo
on 2020-11-26 18:37:56 UTC
(
hide
)
Description:
Bug 27079: Unit tests
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2020-11-26 18:37:56 UTC
Size:
3.28 KB
patch
obsolete
>From 5190e326460f3c8f481507ca26ccf3edb93e3eaa Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 25 Nov 2020 14:10:34 +0000 >Subject: [PATCH] Bug 27079: Unit tests > >Add a unit test to check for floating point errors in UpdateFine >relating to catching matching CalcFine amounts compared to DB amount >values. > >Test plan >1/ Run the unit test and confirm it fails >2/ Apply the second patch in the series >3/ Run the unit test and confirm it passes > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > t/db_dependent/Overdues.t | 37 +++++++++++++++++++++++++++++++++++-- > 1 file changed, 35 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Overdues.t b/t/db_dependent/Overdues.t >index e270c52506..f58d1bb0eb 100755 >--- 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 => 70; >+ plan tests => 74; > > $schema->storage->txn_begin; > >@@ -430,7 +430,7 @@ subtest 'UpdateFine tests' => sub { > is( $fine3->amount+0, 30, "Third fine reduced" ); > is( $fine3->amountoutstanding+0, 10, "Third fine amount outstanding is reduced" ); > >- # Ensure calculations work correctly for floats (bug #25127) >+ # Ensure maxfine calculations work correctly for floats (bug #25127) > # 7.2 (maxfine) - 7.2 (total_amount_other) != 8.88178419700125e-16 (ð¢) > t::lib::Mocks::mock_preference( 'MaxFine', '7.2' ); > my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); >@@ -503,5 +503,38 @@ subtest 'UpdateFine tests' => sub { > is( $fines->count, 4, "New amount should be 0 so no fine added" ); > ok( C4::Circulation::AddReturn( $item_1->barcode, $item_1->homebranch, 1), "Returning the item and forgiving fines succeeds"); > >+ t::lib::Mocks::mock_preference( 'MaxFine', 0 ); >+ >+ # Ensure CalcFine calculations work correctly for floats (bug #27079) >+ # 1.800000 (amount from database) != 1.8~ (CalcFine of 0.15cents * 12units) (ð¢) >+ my $amount = 0.15 * 12; >+ UpdateFine( >+ { >+ issue_id => $checkout_2->issue_id, >+ itemnumber => $item_2->itemnumber, >+ borrowernumber => $patron_1->borrowernumber, >+ amount => $amount, >+ due => $checkout_2->date_due >+ } >+ ); >+ $fine = Koha::Account::Lines->search({ issue_id => $checkout_2->issue_id })->single; >+ ok( $fine, 'Fine added for checkout 2'); >+ is( $fine->amount, "1.800000", "Fine amount is 1.800000 as expected"); >+ >+ $fine->amountoutstanding(0)->store; >+ $fine->discard_changes; >+ is( $fine->amountoutstanding + 0, 0, "Fine was paid off"); >+ UpdateFine( >+ { >+ issue_id => $checkout_2->issue_id, >+ itemnumber => $item_2->itemnumber, >+ borrowernumber => $patron_1->borrowernumber, >+ amount => $amount, >+ due => $checkout_2->date_due >+ } >+ ); >+ my $refunds = Koha::Account::Lines->search({ itemnumber => $item_2->itemnumber, credit_type_code => 'OVERPAYMENT' }); >+ is( $refunds->count, 0, "Overpayment refund not added when the amounts are equal" ); >+ > $schema->storage->txn_rollback; > }; >-- >2.29.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27079
:
113981
|
113983
|
113984
|
113997
|
113999
|
114000
|
114001
| 114018 |
114019
|
114020
|
114029