From eca049d54b0d489650b7c0a9280227c621f9ef27 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 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 --- C4/Members.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/C4/Members.pm b/C4/Members.pm index ac64477..60af264 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -1062,7 +1062,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); -- 1.7.10.4