From 3c390d940fcfaf440ff56775d23828bbf223980f Mon Sep 17 00:00:00 2001 From: abijah Date: Fri, 31 Jul 2009 01:40:16 +0000 Subject: [PATCH] Modified how NSF customer surplus items are handled. Instead of creating a negative surplus (which was dumb, but a decent first pass), we just void out the surplus. This drops the surplus off the radar, and in fact may cause confusion since the transaction no longer has enough statement entries to total up correctly. However, it doesn't appear too confusing, especially as tender item names are now decorated with strikethrough when they're NSF (the previous checkin). git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@444 97e9348a-65ac-dc4b-aefc-98561f571b83 --- models/tender.php | 25 ++++++++++++++++--------- views/customers/view.ctp | 3 ++- views/elements/ledger_entries.ctp | 2 +- views/transactions/view.ctp | 5 +++-- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/models/tender.php b/models/tender.php index 4f0d175..9f265a3 100644 --- a/models/tender.php +++ b/models/tender.php @@ -171,15 +171,22 @@ class Tender extends AppModel { $bounce['Transaction']['amount'] = -1 * $tender['LedgerEntry']['amount']; foreach ($nsf_ledger_entry['Transaction']['StatementEntry'] AS $payment) { - $bounce['Entry'][] = - array('type' => $payment['type'], - 'amount' => -1 * $payment['amount'], - 'account_id' => $this->LedgerEntry->Account->nsfAccountID(), - 'customer_id' => $payment['customer_id'], - 'lease_id' => $payment['lease_id'], - 'charge_entry_id' => $payment['charge_entry_id'], - 'effective_date' => $nsf_deposit['stamp'], - ); + if ($payment['type'] === 'SURPLUS') { + $payment['type'] = 'VOID'; + $this->NsfTransaction->StatementEntry->id = $payment['id']; + $this->NsfTransaction->StatementEntry->saveField('type', $payment['type']); + } + else { + $bounce['Entry'][] = + array('type' => $payment['type'], + 'amount' => -1 * $payment['amount'], + 'account_id' => $this->LedgerEntry->Account->nsfAccountID(), + 'customer_id' => $payment['customer_id'], + 'lease_id' => $payment['lease_id'], + 'charge_entry_id' => $payment['charge_entry_id'], + 'effective_date' => $nsf_deposit['stamp'], + ); + } } pr(compact('bounce')); diff --git a/views/customers/view.ctp b/views/customers/view.ctp index 8ba3c0b..7bdfff3 100644 --- a/views/customers/view.ctp +++ b/views/customers/view.ctp @@ -81,7 +81,8 @@ echo $this->element('statement_entries', array (// Grid configuration 'config' => array ('caption' => 'Account', - 'filter' => array('Customer.id' => $customer['Customer']['id']), + 'filter' => array('Customer.id' => $customer['Customer']['id'], + 'type !=' => 'VOID'), 'exclude' => array('Customer'), ))); diff --git a/views/elements/ledger_entries.ctp b/views/elements/ledger_entries.ctp index dc031b7..d41c7d2 100644 --- a/views/elements/ledger_entries.ctp +++ b/views/elements/ledger_entries.ctp @@ -8,7 +8,7 @@ $cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => $cols['Account'] = array('index' => 'Account.name', 'formatter' => 'name'); $cols['Cr/Dr'] = array('index' => 'LedgerEntry.crdr', 'formatter' => 'enum'); -$cols['Tender'] = array('index' => 'Tender.name', 'formatter' => 'name'); +$cols['Tender'] = array('index' => 'Tender.name', 'formatter' => 'longname'); $cols['Comment'] = array('index' => 'LedgerEntry.comment', 'formatter' => 'comment', 'width'=>150); $cols['Amount'] = array('index' => 'LedgerEntry.amount', 'formatter' => 'currency'); diff --git a/views/transactions/view.ctp b/views/transactions/view.ctp index 6ebf3d8..e73b9ee 100644 --- a/views/transactions/view.ctp +++ b/views/transactions/view.ctp @@ -73,8 +73,9 @@ if ($transaction['type'] === 'INVOICE' || $transaction['type'] === 'RECEIPT') { 'config' => array ( 'caption' => 'Statement Entries', - 'filter' => array('Transaction.id' => $transaction['id']), - 'exclude' => array('Transaction'), + 'filter' => array('Transaction.id' => $transaction['id'], + 'type !=' => 'VOID'), + 'exclude' => array('Transaction', 'Account'), ))); }