Modified to use the logging mechanism

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@446 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-31 02:09:45 +00:00
parent b553dbb9c3
commit 46744a24d3

View File

@@ -211,8 +211,8 @@ class Transaction extends AppModel {
* (not in a pre-existing transaction)
*/
function verifyTransaction($transaction, $entries) {
/* pr(array("Transaction::verifyTransaction()" */
/* => compact('transaction', 'entries'))); */
$this->prFunctionLevel(10);
$this->prEnter(compact('transaction', 'entries'));
// Verify required Transaction data is present
if (empty($transaction['type']) ||
@@ -224,28 +224,22 @@ class Transaction extends AppModel {
(in_array($transaction['type'], array('INVOICE'))
&& empty($transaction['lease_id']))
) {
/* pr(array("Transaction::verifyTransaction()" */
/* => "Transaction verification failed")); */
return false;
return $this->prReturn(false);
}
// Verify all entries
foreach ($entries AS $entry) {
extract($entry);
if (!$this->LedgerEntry->DoubleEntry->verifyDoubleEntry($le1, $le2, $le1_tender)) {
/* pr(array("Transaction::verifyTransaction()" */
/* => "Double Entry verification failed")); */
return false;
return $this->prReturn(false);
}
if ($transaction['type'] == 'INVOICE' &&
!$this->StatementEntry->verifyStatementEntry($se)) {
/* pr(array("Transaction::verifyTransaction()" */
/* => "Statement Entry verification failed")); */
return false;
return $this->prReturn(false);
}
}
return true;
return $this->prReturn(true);
}
@@ -308,13 +302,12 @@ class Transaction extends AppModel {
*/
function addTransaction($data) {
/* pr(array("Transaction::addTransaction()" */
/* => compact('data'))); */
$this->prEnter(compact('data'));
// Verify that we have a transaction and entries
if (empty($data['Transaction']) ||
($data['Transaction']['type'] !== 'CLOSE' && empty($data['Entry'])))
return array('error' => true);
return $this->prReturn(array('error' => true));
// Extract the transaction to a local variable
$transaction = $data['Transaction'];
@@ -402,16 +395,15 @@ class Transaction extends AppModel {
// Move forward, verifying and saving everything.
$ret = array();
if (!$this->verifyTransaction($transaction, $data['Entry']))
return array('error' => true) + $ret;
return $this->prReturn(array('error' => true) + $ret);
/* pr(array('Transaction::addTransaction' => */
/* array('checkpoint' => 'Pre Transaction Save') */
/* + compact('transaction', 'data'))); */
$this->pr(20, compact('transaction', 'data'),
'Pre Transaction Save');
// Save transaction to the database
$this->create();
if (!$this->save($transaction))
return array('error' => true) + $ret;
return $this->prReturn(array('error' => true) + $ret);
// Set up our return ids array
$ret['transaction_id'] = $this->id;
@@ -457,10 +449,7 @@ class Transaction extends AppModel {
$ret['error'] = true;
}
/* pr(array('Transaction::addTransaction' => */
/* array('return' => $ret))); */
return $ret;
return $this->prReturn($ret);
}
@@ -472,12 +461,11 @@ class Transaction extends AppModel {
*/
function addNsf($data) {
pr(array("Transaction::addNsf()"
=> compact('data')));
$this->prEnter(compact('data'));
// Verify that we have a transaction and entries
if (empty($data['Transaction']) || empty($data['Entry']))
return array('error' => true);
return $this->prReturn(array('error' => true));
// Extract the transaction to a local variable
$transaction = $data['Transaction'];
@@ -546,14 +534,13 @@ class Transaction extends AppModel {
/* if (!$this->verifyTransaction($transaction, $data['Entry'])) */
/* return array('error' => true) + $ret; */
pr(array('Transaction::addNsf' =>
array('checkpoint' => 'Pre Transaction Save')
+ compact('transaction')));
$this->pr(20, compact('transaction'),
'Pre Transaction Save');
// Save transaction to the database
$this->create();
if (!$this->save($transaction))
return array('error' => true) + $ret;
return $this->prReturn(array('error' => true) + $ret);
// Set up our return ids array
$ret['transaction_id'] = $this->id;
@@ -606,10 +593,7 @@ class Transaction extends AppModel {
/* $ret['error'] = true; */
/* } */
pr(array('Transaction::addNsf' =>
array('return' => $ret)));
return $ret;
return $this->prReturn($ret);
}
@@ -620,7 +604,7 @@ class Transaction extends AppModel {
* - Returns summary data from the requested transaction
*/
function stats($id = null, $query = null, $balance_account_id = null) {
//pr(array('Transaction::stats' => compact('id', 'query')));
$this->prEnter(compact('id', 'query'));
$this->queryInit($query);
unset($query['group']);
@@ -677,8 +661,7 @@ class Transaction extends AppModel {
unset($stats[$table][0]);
}
//pr(array('Transaction::stats' => array('return' => compact('stats'))));
return $stats;
return $this->prReturn($stats);
}
}
?>