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