Added some comments, and changed the nsf action to redirect to viewing the tender after creation.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@453 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-31 17:15:17 +00:00
parent e47a2cc7aa
commit 655e0c3940
2 changed files with 36 additions and 17 deletions

View File

@@ -120,12 +120,8 @@ class TendersController extends AppController {
$this->redirect(array('action'=>'index'));
}
// REVISIT <AP>: 20090713
// For testing purposes, must be deleted
$stamp = '2009-07-09';
$stamp = null;
$this->Tender->nsf($id, $stamp);
$this->Tender->nsf($id);
$this->redirect(array('action'=>'view', $id));
}
/**************************************************************************

View File

@@ -103,7 +103,7 @@ class Tender extends AppModel {
*/
function nsf($id, $stamp = null) {
$this->prFunctionLevel(30);
//$this->prFunctionLevel(30);
$this->prEnter(compact('id'));
// Get information about this NSF item.
@@ -125,7 +125,10 @@ class Tender extends AppModel {
die("Item has not been deposited yet");
// Enter the NSF
$result = $this->DepositTransaction->addDeposit
// This is the transaction pulling money from the bank account
// and recording it in the NSF account. It has nothing to do
// with the customer statement (charges, payments, credits, etc).
$nsf_result = $this->DepositTransaction->addDeposit
(array('Transaction' => array(),
'Entry' => array(array('tender_id' => null,
'account_id' => $this->LedgerEntry->Account->nsfAccountID(),
@@ -134,17 +137,18 @@ class Tender extends AppModel {
$tender['DepositTransaction']['account_id']);
$this->pr(20, compact('result'));
if ($result['error'])
if ($nsf_result['error'])
die("Unable to save NSF transaction");
$this->id = $id;
$this->saveField('nsf_transaction_id', $result['transaction_id']);
// Since we may have saved the nsf transaction with a null
// timestamp, query it back out of the database to find out
// what timestamp was _really_ specified, for later use.
$nsf_deposit = $this->DepositTransaction->find
('first', array('contain' => false, 'id' => $result['transaction_id']));
('first', array('contain' => false, 'id' => $nsf_result['transaction_id']));
$nsf_deposit = $nsf_deposit['DepositTransaction'];
// OK, now move into customer realm, finding all statement
// entries that were affected by the bad payment (tender).
$nsf_ledger_entry = $this->LedgerEntry->find
('first', array
('contain' => array('Transaction' =>
@@ -159,6 +163,7 @@ class Tender extends AppModel {
$this->pr(20, compact('nsf_ledger_entry'));
// Build a transaction to adjust all of the statement entries
$bounce = array('Transaction' => array(), 'Entry' => array());
$bounce['Transaction']['stamp'] = $nsf_deposit['stamp'];
@@ -185,12 +190,30 @@ class Tender extends AppModel {
}
}
// Record the transaction, which will un-pay previously paid
// charges, void any credits, and other similar work.
$this->pr(20, compact('bounce'));
$result = $this->NsfTransaction->addNsf($bounce);
$bounce_result = $this->NsfTransaction->addNsf($bounce);
if ($result['error'])
if ($bounce_result['error'])
die("Unable to save Bounce transaction");
// Flag the tender as NSF, using the transaction created above.
// REVISIT <AP>: 20090730
// For symmetry, it seems like we should be using the nsf_result.
// Thus the tender's deposit_transaction_id would record how the
// money got into the bank account, and the nsf_transaction_id
// would record how the money was taken back out. However, that
// transaction is just not very useful. So, either we ignore
// the fact that the nsf_result is not useful to the user, we
// use the bounce_result instead, or we modify the tender view
// page to reference the bounce_result, and still use nsf_result
// for our nsf_transaction_id.
$this->id = $id;
$this->saveField('nsf_transaction_id', $nsf_result['transaction_id']);
// Add NSF Charge
$result = $this->NsfTransaction->addInvoice
(array('Transaction' =>