From 430dc045033ea3f70684068da3d37f0b769b60f9 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 8 Mar 2016 11:58:24 +0000 Subject: [PATCH] Bug 15741: Fix rounding in total fines calculations MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit C4::Members::GetMemberAccountRecords wrongly casts float to integer It's common to use sprintf in Perl to do this job. % perl -e 'print int(1000*64.60)."\n"'; 64599 % perl -e 'print sprintf("%.0f", 1000*64.60)."\n"'; 64600 Test plan: 1) Create manual invoice for 64.60 (or 1.14, 1.36, ...) 2) Try to pay it using "Pay amount" or "Pay selected" buttons Signed-off-by: Sally Healey Signed-off-by: Katrin Fischer Signed-off-by: Tomas Cohen Arazi Signed-off-by: Brendan A Gallagher (cherry picked from commit 92fbb1f3d0f2bdb070a1b647c96edbce5b28a377) Signed-off-by: Julian Maurice (cherry picked from commit 40507ce1529a237ec5c51837805100e89e96db9c) Signed-off-by: Frédéric Demians --- C4/Members.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/Members.pm b/C4/Members.pm index 26adb71831..667f6bfd20 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -1176,7 +1176,7 @@ sub GetMemberAccountRecords { } $acctlines[$numlines] = $data; $numlines++; - $total += int(1000 * $data->{'amountoutstanding'}); # convert float to integer to avoid round-off errors + $total += sprintf "%.0f", 1000*$data->{amountoutstanding}; # convert float to integer to avoid round-off errors } $total /= 1000; return ( $total, \@acctlines,$numlines); -- 2.39.5