From b83c870eedf5d1a0ce7c861716870854881a0d49 Mon Sep 17 00:00:00 2001 From: abijah Date: Fri, 2 Apr 2010 13:08:41 +0000 Subject: [PATCH] Merge in bugfix from v0.2_work git-svn-id: file:///svn-source/pmgr/branches/v0.3_work@982 97e9348a-65ac-dc4b-aefc-98561f571b83 --- site/models/statement_entry.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/site/models/statement_entry.php b/site/models/statement_entry.php index c047970..e127a28 100644 --- a/site/models/statement_entry.php +++ b/site/models/statement_entry.php @@ -542,14 +542,14 @@ class StatementEntry extends AppModel { // Set the disbursement amount to the maximum amount // possible without exceeding the charge or credit balance - $disbursement_amount = min($charge['balance'], $credit['balance']); + $disbursement_amount = round(min($charge['balance'], $credit['balance']), 2); if (!isset($credit['applied'])) $credit['applied'] = 0; - $credit['applied'] += $disbursement_amount; - $credit['balance'] -= $disbursement_amount; + $credit['applied'] = round($credit['applied'] + $disbursement_amount, 2); + $credit['balance'] = round($credit['balance'] - $disbursement_amount, 2); - $this->pr(20, compact('credit'), + $this->pr(20, compact('credit', 'disbursement_amount'), ($credit['balance'] > 0 ? 'Utilized' : 'Exhausted') . (empty($credit['receipt']) ? ' Credit' : ' Receipt')); @@ -614,12 +614,12 @@ class StatementEntry extends AppModel { } // Adjust the charge balance to reflect the new disbursement - $charge['balance'] -= $disbursement_amount; + $charge['balance'] = round($charge['balance'] - $disbursement_amount, 2); + $this->pr(20, compact('charge', 'disbursement_amount'), + ($charge['balance'] > 0 ? 'Unfinished' : 'Fully Paid') . ' Charge'); + if ($charge['balance'] < 0) die("HOW DID WE GET A NEGATIVE CHARGE AMOUNT?"); - - if ($charge['balance'] <= 0) - $this->pr(20, 'Fully Paid Charge'); } // Break the $credit reference to avoid future problems unset($credit);