Fixed a couple small bugs with assignCredits, one of which was causing charges to get paid out of order.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@460 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-31 19:20:35 +00:00
parent 53a279a6db
commit 1e10fbbf38

View File

@@ -372,7 +372,7 @@ OPTION 2
// Now find all unpaid charges
$lquery = $query;
$lquery['order'] = 'StatementEntry.effective_date ASC';
$charges = $this->reconciledSet('CHARGE', $query, true);
$charges = $this->reconciledSet('CHARGE', $lquery, true);
$this->pr(18, compact('charges'),
"Outstanding Charges Determined");
@@ -436,20 +436,15 @@ OPTION 2
$this->pr(20, compact('credit'),
(($credit['balance'] > 0 ? 'Utilized' : 'Exhausted')
. (count($credits) ? '' : ' Anon')
. ' Credit'));
' ' . (count($credits) ? 'Credit' : 'Receipt')));
if ($credit['balance'] < 0)
die("HOW DID WE END UP WITH NEGATIVE SURPLUS BALANCE?");
// If we've exhaused the credit, get it out of the
// available credit pool (but keep track of it for later).
if ($credit['balance'] <= 0) {
if (count($credits))
$used_credits[] = array_shift($credits);
else
$used_anon_credits[] = array_shift($anon_credits);
}
if ($credit['balance'] <= 0 && count($credits))
$used_credits[] = array_shift($credits);
// Add a payment that uses the available credit to pay the charge
$payment = array('type' => 'PAYMENT',
@@ -486,7 +481,7 @@ OPTION 2
if (isset($credits[0]['applied']))
$used_credits[] = array_shift($credits);
$this->pr(18, compact('credits', 'used_credits', 'anon_credits', 'used_anon_credits'),
$this->pr(18, compact('credits', 'used_credits', 'receipt_credit'),
'Payments added');
// Clean up any explicit credits that have been used