From ee351068fc677963c110b9970f453557a8b81737 Mon Sep 17 00:00:00 2001 From: sunsetsystems Date: Sat, 16 Apr 2005 05:16:22 +0000 Subject: [PATCH] improve rounding of amounts in ar table --- interface/billing/sl_eob_invoice.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/interface/billing/sl_eob_invoice.php b/interface/billing/sl_eob_invoice.php index c2502f23b..92e895cc2 100644 --- a/interface/billing/sl_eob_invoice.php +++ b/interface/billing/sl_eob_invoice.php @@ -84,13 +84,15 @@ } } - // Update totals and payment date in the invoice header. + // Update totals and payment date in the invoice header. Dollar amounts are + // stored as double precision floats so we have to be careful about rounding. // function updateAR($invid, $amount, $paid = 0, $paydate = "") { global $sl_err, $debug; $paydate = fixDate($paydate); - $query = "UPDATE ar SET amount = amount + $amount, netamount = netamount + $amount"; - if ($paid) $query .= ", paid = paid + $paid, datepaid = '$paydate'"; + $query = "UPDATE ar SET amount = round(CAST (amount AS numeric) + $amount, 2), " . + "netamount = round(CAST (netamount AS numeric) + $amount, 2)"; + if ($paid) $query .= ", paid = round(CAST (paid AS numeric) + $paid, 2), datepaid = '$paydate'"; $query .= " WHERE id = $invid"; if ($debug) { echo $query . "
\n"; -- 2.11.4.GIT