Calculate total amount for credit payment as integers to avoid rounding
errors w/ large sets of small billings.
E.g. avoid trying to pay a fine of 9.
999999999999 for a set of fines
which should add up to 10.00.
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Ben Shum <ben@evergreener.net>
$amount =~ s/\$//og; # just to be safe
my $trans = $xacts{$transid};
- $total_paid += $amount;
+ # add amounts as integers
+ $total_paid += (100 * $amount);
my $org_id = $U->xact_org($transid, $e);
} # all payment objects have been created and inserted.
+ # return to decimal format, forcing X.YY format for consistency.
+ $total_paid = sprintf("%.2f", $total_paid / 100);
+
#### NO WRITES TO THE DB ABOVE THIS LINE -- THEY'LL ONLY BE DISCARDED ###
$e->rollback;