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'), ))); }