Modified to use the logging mechanism

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@445 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-31 01:45:57 +00:00
parent a1a9c7800b
commit 323519ab75

View File

@@ -22,16 +22,14 @@ class Tender extends AppModel {
* (not in a pre-existing tender) * (not in a pre-existing tender)
*/ */
function verifyTender($tender) { function verifyTender($tender) {
/* pr(array("Tender::verifyTender()" */ $this->prFunctionLevel(10);
/* => compact('tender'))); */ $this->prEnter(compact('tender'));
if (empty($tender['tender_type_id'])) { if (empty($tender['tender_type_id'])) {
/* pr(array("Tender::verifyTender()" */ return $this->prReturn(false);
/* => "Tender verification failed")); */
return false;
} }
return true; return $this->prReturn(true);
} }
@@ -43,12 +41,11 @@ class Tender extends AppModel {
*/ */
function addTender($tender) { function addTender($tender) {
/* pr(array('Tender::addTender' => */ $this->prEnter(compact('tender'));
/* compact('tender'))); */
$ret = array(); $ret = array();
if (!$this->verifyTender($tender)) if (!$this->verifyTender($tender))
return array('error' => true) + $ret; return $this->prReturn(array('error' => true) + $ret);
// Come up with a (not necessarily unique) name for the tender. // Come up with a (not necessarily unique) name for the tender.
// For checks & money orders, this will be based on the check // For checks & money orders, this will be based on the check
@@ -66,16 +63,15 @@ class Tender extends AppModel {
} }
} }
/* pr(array('Tender::addTender' => */ $this->pr(20, array('Tender' => $tender),
/* array('checkpoint' => 'Pre-Save') */ 'Pre-Save');
/* + array('Tender' => $tender))); */
$this->create(); $this->create();
if (!$this->save($tender)) if (!$this->save($tender))
return array('error' => true) + $ret; return $this->prReturn(array('error' => true) + $ret);
$ret['tender_id'] = $this->id; $ret['tender_id'] = $this->id;
return $ret + array('error' => false); return $this->prReturn($ret + array('error' => false));
} }
@@ -107,8 +103,8 @@ class Tender extends AppModel {
*/ */
function nsf($id, $stamp = null) { function nsf($id, $stamp = null) {
pr(array('Tender::nsf', $this->prFunctionLevel(30);
compact('id'))); $this->prEnter(compact('id'));
// Get information about this NSF item. // Get information about this NSF item.
$this->id = $id; $this->id = $id;
@@ -120,7 +116,7 @@ class Tender extends AppModel {
'NsfTransaction'), 'NsfTransaction'),
)); ));
//'conditions' => array(array('Tender.id' => $id)), //'conditions' => array(array('Tender.id' => $id)),
pr($tender); $this->pr(20, compact('tender'));
if (!empty($tender['NsfTransaction']['id'])) if (!empty($tender['NsfTransaction']['id']))
die("Item has already been set as NSF"); die("Item has already been set as NSF");
@@ -136,7 +132,7 @@ class Tender extends AppModel {
'amount' => -1 * $tender['LedgerEntry']['amount'], 'amount' => -1 * $tender['LedgerEntry']['amount'],
))), ))),
$tender['DepositTransaction']['account_id']); $tender['DepositTransaction']['account_id']);
pr(compact('result')); $this->pr(20, compact('result'));
if ($result['error']) if ($result['error'])
die("Unable to save NSF transaction"); die("Unable to save NSF transaction");
@@ -161,7 +157,7 @@ class Tender extends AppModel {
'conditions' => array('LedgerEntry.id' => $tender['LedgerEntry']['id']), 'conditions' => array('LedgerEntry.id' => $tender['LedgerEntry']['id']),
)); ));
pr(compact('nsf_ledger_entry')); $this->pr(20, compact('nsf_ledger_entry'));
$bounce = array('Transaction' => array(), 'Entry' => array()); $bounce = array('Transaction' => array(), 'Entry' => array());
@@ -189,7 +185,7 @@ class Tender extends AppModel {
} }
} }
pr(compact('bounce')); $this->pr(20, compact('bounce'));
$result = $this->NsfTransaction->addNsf($bounce); $result = $this->NsfTransaction->addNsf($bounce);
if ($result['error']) if ($result['error'])
@@ -200,7 +196,7 @@ class Tender extends AppModel {
/* $nsf_fee_account_id = $A->nsfChargeAccountID(); */ /* $nsf_fee_account_id = $A->nsfChargeAccountID(); */
return true; return $this->prReturn(true);
} }