From bfd0d5d3e231909c396be894778670df3118ccf4 Mon Sep 17 00:00:00 2001 From: "G. Richardson" Date: Fri, 27 May 2011 13:10:35 +0200 Subject: [PATCH] Addition to bugfix 1666: correcting rounding errors for negative values make sure rounding error is caught if invoicediff and expensediff both have negative values see also commit cc47124952e133ee4edbc116d927b90040dc8a05 --- SL/IR.pm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/SL/IR.pm b/SL/IR.pm index 602ffc365..86b1323fd 100644 --- a/SL/IR.pm +++ b/SL/IR.pm @@ -400,12 +400,10 @@ sub post_invoice { # shall receive the total rounding error, and the next time it is rounded # the 1 cent correction will be introduced. - my $total_rounding_diff = $invoicediff+$expensediff; - $form->{amount}{ $form->{id} }{$lastinventoryaccno} -= $invoicediff if $lastinventoryaccno; $form->{amount}{ $form->{id} }{$lastexpenseaccno} -= $expensediff if $lastexpenseaccno; - if ( ($expensediff+$invoicediff) >= 0.005 and $expensediff < 0.005 and $invoicediff < 0.005 ) { + if ( (abs($expensediff)+abs($invoicediff)) >= 0.005 and abs($expensediff) < 0.005 and abs($invoicediff) < 0.005 ) { # in total the rounding error adds up to 1 cent effectively, correct the # larger of the two numbers -- 2.20.1