Modified NSF to use positive amounts for the ledger entries (swapping credit/debit, of course). The statement entries remain using negative amounts, as they are negative disbursements.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@511 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-08-10 04:46:54 +00:00
parent 9a3a24ca0c
commit fdcdc94bec

View File

@@ -225,7 +225,7 @@ class Transaction extends AppModel {
if (!isset($group[$entry['account_id']])) if (!isset($group[$entry['account_id']]))
$group[$entry['account_id']] = $group[$entry['account_id']] =
array('account_id' => $entry['account_id'], array('account_id' => $entry['account_id'],
'crdr' => 'CREDIT', 'crdr' => strtoupper($this->Account->fundamentalOpposite($deposit['crdr'])),
'amount' => 0); 'amount' => 0);
$group[$entry['account_id']]['amount'] += $entry['amount']; $group[$entry['account_id']]['amount'] += $entry['amount'];
} }
@@ -556,6 +556,8 @@ class Transaction extends AppModel {
array_intersect_key($transaction, array_intersect_key($transaction,
array_flip(array('customer_id', 'lease_id'))); array_flip(array('customer_id', 'lease_id')));
$se['comment'] = $entry['statement_entry_comment']; $se['comment'] = $entry['statement_entry_comment'];
if (!empty($entry['se_negative']))
$se['amount'] *= -1;
// (DISBURSEMENTS will have statement entries created below, when // (DISBURSEMENTS will have statement entries created below, when
// assigning credits, and DEPOSITS don't have statement entries) // assigning credits, and DEPOSITS don't have statement entries)
@@ -581,11 +583,11 @@ class Transaction extends AppModel {
// that were created above before we nulled them out // that were created above before we nulled them out
array_unshift($entries, array_unshift($entries,
array('le1' => array('account_id' => $transaction['account_id'], array('le1' => array('account_id' => $transaction['account_id'],
'crdr' => 'DEBIT',
'amount' => $transaction['amount']),
'le2' => array('account_id' => $this->Account->accountReceivableAccountID(),
'crdr' => 'CREDIT', 'crdr' => 'CREDIT',
'amount' => $transaction['amount']) 'amount' => -1 * $transaction['amount']),
'le2' => array('account_id' => $this->Account->accountReceivableAccountID(),
'crdr' => 'DEBIT',
'amount' => -1 * $transaction['amount'])
)); ));
} }
@@ -681,10 +683,12 @@ class Transaction extends AppModel {
// and recording it in the NSF account. It has nothing to do // and recording it in the NSF account. It has nothing to do
// with the customer statement (charges, disbursements, credits, etc). // with the customer statement (charges, disbursements, credits, etc).
$bounce_result = $this->addDeposit $bounce_result = $this->addDeposit
(array('Transaction' => array(), (array('Transaction' => array('crdr' => 'CREDIT'),
'Entry' => array(array('tender_id' => null, 'Entry' => array(array('tender_id' => null,
'account_id' => $this->Account->nsfAccountID(), 'account_id' => $this->Account->nsfAccountID(),
'amount' => -1 * $tender['LedgerEntry']['amount'], 'crdr' => 'DEBIT',
'amount' => $tender['LedgerEntry']['amount'],
'se_negative' => true,
))), ))),
$tender['Transaction']['account_id']); $tender['Transaction']['account_id']);
@@ -724,10 +728,9 @@ class Transaction extends AppModel {
$rollback['Transaction']['stamp'] = $stamp; $rollback['Transaction']['stamp'] = $stamp;
$rollback['Transaction']['type'] = 'RECEIPT'; $rollback['Transaction']['type'] = 'RECEIPT';
$rollback['Transaction']['crdr'] = 'DEBIT'; // Unused... keeps verifyTx happy $rollback['Transaction']['crdr'] = 'CREDIT'; // Unused... keeps verifyTx happy
$rollback['Transaction']['account_id'] = $this->Account->nsfAccountID(); $rollback['Transaction']['account_id'] = $this->Account->nsfAccountID();
$rollback['Transaction']['customer_id'] = $tender['Tender']['customer_id']; $rollback['Transaction']['customer_id'] = $tender['Tender']['customer_id'];
$rollback['Transaction']['amount'] = -1 * $tender['LedgerEntry']['amount'];
foreach ($nsf_ledger_entry['Transaction']['StatementEntry'] AS $disbursement) { foreach ($nsf_ledger_entry['Transaction']['StatementEntry'] AS $disbursement) {
if ($disbursement['type'] === 'SURPLUS') { if ($disbursement['type'] === 'SURPLUS') {