From b73135c3cc3a88e2ddc80b0a531accd2020d5b83 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 25 Nov 2020 12:58:56 +0000 Subject: [PATCH] Bug 27079: Floating point comparison correction We cannot compare calculated values directly as those calculations may have introduced floating point differences. We have the Koha::Number::Price->round function to consistently round the floating point number to a decimal with 2 points precission for comparison. Test plan 1/ Set a circ rule to have a .15 per day fine 2/ Issue an item of this type to a borrower (making it 12 days overdue by setting the due date to 12 days in the past) 3/ Run the fines job: 4/ Pay the fine for the patron 5/ Check in the item 6/ Note that the patron does not have an 'Overpayment refund' of $0.00 Signed-off-by: Josef Moravec --- C4/Overdues.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/Overdues.pm b/C4/Overdues.pm index a9de67d1ee..607af71f5c 100644 --- a/C4/Overdues.pm +++ b/C4/Overdues.pm @@ -574,7 +574,7 @@ sub UpdateFine { } if ( $accountline ) { - if ( $accountline->amount != $amount ) { + if ( $accountline->amount != Koha::Number::Price->new($amount)->round ) { $accountline->adjust( { amount => $amount, -- 2.11.0