Changed the StatementEntry type enum from CREDIT to SURPLUS. I never liked using the term CREDIT, since its use is confusing along side DEBIT/CREDIT. I couldn't think of another name earlier, which is why I used CREDIT, but I decided anything other than CREDIT is good, so I chose SURPLUS.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@435 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -1062,7 +1062,7 @@ CREATE TABLE `pmgr_statement_entries` (
|
|||||||
|
|
||||||
`type` ENUM('CHARGE',
|
`type` ENUM('CHARGE',
|
||||||
'PAYMENT',
|
'PAYMENT',
|
||||||
'CREDIT')
|
'SURPLUS')
|
||||||
NOT NULL,
|
NOT NULL,
|
||||||
|
|
||||||
`transaction_id` INT(10) UNSIGNED NOT NULL,
|
`transaction_id` INT(10) UNSIGNED NOT NULL,
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class StatementEntry extends AppModel {
|
|||||||
($sum ? ')' : '') . ' AS charge' . ($sum ? 's' : ''),
|
($sum ? ')' : '') . ' AS charge' . ($sum ? 's' : ''),
|
||||||
|
|
||||||
($sum ? 'SUM(' : '') .
|
($sum ? 'SUM(' : '') .
|
||||||
"IF({$entry_name}.type = 'PAYMENT' OR {$entry_name}.type = 'CREDIT'," .
|
"IF({$entry_name}.type = 'PAYMENT' OR {$entry_name}.type = 'SURPLUS'," .
|
||||||
" {$entry_name}.amount, NULL)" .
|
" {$entry_name}.amount, NULL)" .
|
||||||
($sum ? ')' : '') . ' AS payment' . ($sum ? 's' : ''),
|
($sum ? ')' : '') . ' AS payment' . ($sum ? 's' : ''),
|
||||||
|
|
||||||
@@ -346,7 +346,7 @@ OPTION 2
|
|||||||
|
|
||||||
// First, find all known credits
|
// First, find all known credits
|
||||||
$lquery = $query;
|
$lquery = $query;
|
||||||
$lquery['conditions'][] = array('StatementEntry.type' => 'CREDIT');
|
$lquery['conditions'][] = array('StatementEntry.type' => 'SURPLUS');
|
||||||
$lquery['order'][] = 'StatementEntry.effective_date ASC';
|
$lquery['order'][] = 'StatementEntry.effective_date ASC';
|
||||||
$credits = $this->find('all', $lquery);
|
$credits = $this->find('all', $lquery);
|
||||||
/* pr(array('StatementEntry::assignCredits' => */
|
/* pr(array('StatementEntry::assignCredits' => */
|
||||||
@@ -435,7 +435,7 @@ OPTION 2
|
|||||||
$payment_account_id = $credit['LedgerEntry']['account_id'];
|
$payment_account_id = $credit['LedgerEntry']['account_id'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
die("HOW DID WE GET HERE WITH NO CREDITS?");
|
die("HOW DID WE GET HERE WITH NO SURPLUS?");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the payment amount to the maximum amount
|
// Set the payment amount to the maximum amount
|
||||||
@@ -454,7 +454,7 @@ OPTION 2
|
|||||||
/* + compact('credit'))); */
|
/* + compact('credit'))); */
|
||||||
|
|
||||||
if ($credit['balance'] < 0)
|
if ($credit['balance'] < 0)
|
||||||
die("HOW DID WE END UP WITH NEGATIVE CREDIT BALANCE?");
|
die("HOW DID WE END UP WITH NEGATIVE SURPLUS BALANCE?");
|
||||||
|
|
||||||
// If we've exhaused the credit, get it out of the
|
// If we've exhaused the credit, get it out of the
|
||||||
// available credit pool (but keep track of it for later).
|
// available credit pool (but keep track of it for later).
|
||||||
@@ -534,7 +534,7 @@ OPTION 2
|
|||||||
/* + compact('credit'))); */
|
/* + compact('credit'))); */
|
||||||
|
|
||||||
$result = $this->addStatementEntry
|
$result = $this->addStatementEntry
|
||||||
(array('type' => 'CREDIT',
|
(array('type' => 'SURPLUS',
|
||||||
'account_id' => $credit['LedgerEntry']['account_id'],
|
'account_id' => $credit['LedgerEntry']['account_id'],
|
||||||
'amount' => $credit['balance'],
|
'amount' => $credit['balance'],
|
||||||
'effective_date' => $credit['Transaction']['stamp'],
|
'effective_date' => $credit['Transaction']['stamp'],
|
||||||
|
|||||||
Reference in New Issue
Block a user