Suppressed all the debug print statements from transaction insertion.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@398 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -373,20 +373,20 @@ class Customer extends AppModel {
|
||||
'conditions' => array('StatementEntry.customer_id' => $id),
|
||||
));
|
||||
$find_stats = $find_stats[0];
|
||||
pr(compact('find_stats'));
|
||||
/* pr(compact('find_stats')); */
|
||||
|
||||
$tquery = $query;
|
||||
$tquery['conditions'][] = array('StatementEntry.customer_id' => $id);
|
||||
$statement_stats = $this->StatementEntry->stats(null, $tquery);
|
||||
$statement_stats['balance'] = $statement_stats['Charge']['balance'];
|
||||
pr(compact('statement_stats'));
|
||||
/* pr(compact('statement_stats')); */
|
||||
|
||||
$tquery = $query;
|
||||
//$tquery['conditions'][] = array('StatementEntry.customer_id' => $id);
|
||||
$tquery['conditions'][] = array('Transaction.customer_id' => $id);
|
||||
$transaction_stats = $this->Transaction->stats(null, $tquery);
|
||||
$transaction_stats += $transaction_stats['StatementEntry'];
|
||||
pr(compact('transaction_stats'));
|
||||
/* pr(compact('transaction_stats')); */
|
||||
|
||||
$tquery = $query;
|
||||
//$tquery['conditions'][] = array('StatementEntry.customer_id' => $id);
|
||||
@@ -394,7 +394,7 @@ class Customer extends AppModel {
|
||||
$ar_transaction_stats = $this->Transaction->stats(null, $tquery,
|
||||
$this->Transaction->Account->accountReceivableAccountID());
|
||||
$ar_transaction_stats += $ar_transaction_stats['LedgerEntry'];
|
||||
pr(compact('ar_transaction_stats'));
|
||||
/* pr(compact('ar_transaction_stats')); */
|
||||
|
||||
//$stats = $ar_transaction_stats;
|
||||
$stats = $find_stats;
|
||||
|
||||
@@ -19,25 +19,25 @@ class DoubleEntry extends AppModel {
|
||||
* (not in a pre-existing double entry)
|
||||
*/
|
||||
function verifyDoubleEntry($entry1, $entry2, $entry1_tender = null) {
|
||||
pr(array("DoubleEntry::verifyDoubleEntry()"
|
||||
=> compact('entry1', 'entry2', 'entry1_tender')));
|
||||
/* pr(array("DoubleEntry::verifyDoubleEntry()" */
|
||||
/* => compact('entry1', 'entry2', 'entry1_tender'))); */
|
||||
|
||||
$LE = new LedgerEntry();
|
||||
if (!$LE->verifyLedgerEntry($entry1, $entry1_tender)) {
|
||||
pr(array("DoubleEntry::verifyDoubleEntry()"
|
||||
=> "Entry1 verification failed"));
|
||||
/* pr(array("DoubleEntry::verifyDoubleEntry()" */
|
||||
/* => "Entry1 verification failed")); */
|
||||
return false;
|
||||
}
|
||||
if (!$LE->verifyLedgerEntry($entry2)) {
|
||||
pr(array("DoubleEntry::verifyDoubleEntry()"
|
||||
=> "Entry2 verification failed"));
|
||||
/* pr(array("DoubleEntry::verifyDoubleEntry()" */
|
||||
/* => "Entry2 verification failed")); */
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!(($entry1['crdr'] === 'DEBIT' && $entry2['crdr'] === 'CREDIT') ||
|
||||
($entry1['crdr'] === 'CREDIT' && $entry2['crdr'] === 'DEBIT'))) {
|
||||
pr(array("DoubleEntry::verifyDoubleEntry()"
|
||||
=> "Double Entry verification failed"));
|
||||
/* pr(array("DoubleEntry::verifyDoubleEntry()" */
|
||||
/* => "Double Entry verification failed")); */
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ class DoubleEntry extends AppModel {
|
||||
*/
|
||||
|
||||
function addDoubleEntry($entry1, $entry2, $entry1_tender = null) {
|
||||
pr(array('DoubleEntry::addDoubleEntry' =>
|
||||
compact('entry1', 'entry2', 'entry1_tender')));
|
||||
/* pr(array('DoubleEntry::addDoubleEntry' => */
|
||||
/* compact('entry1', 'entry2', 'entry1_tender'))); */
|
||||
|
||||
$ret = array();
|
||||
if (!$this->verifyDoubleEntry($entry1, $entry2, $entry1_tender))
|
||||
@@ -81,9 +81,9 @@ class DoubleEntry extends AppModel {
|
||||
$double_entry['credit_entry_id'] =
|
||||
($entry1['crdr'] === 'CREDIT') ? $ret['Entry1']['ledger_entry_id'] : $ret['Entry2']['ledger_entry_id'];
|
||||
|
||||
pr(array('DoubleEntry::addDoubleEntry' =>
|
||||
array('checkpoint' => 'Pre-Save')
|
||||
+ compact('double_entry')));
|
||||
/* pr(array('DoubleEntry::addDoubleEntry' => */
|
||||
/* array('checkpoint' => 'Pre-Save') */
|
||||
/* + compact('double_entry'))); */
|
||||
|
||||
$this->create();
|
||||
if (!$this->save($double_entry))
|
||||
|
||||
@@ -84,21 +84,21 @@ class LedgerEntry extends AppModel {
|
||||
* (not in a pre-existing ledger entry)
|
||||
*/
|
||||
function verifyLedgerEntry($entry, $tender = null) {
|
||||
pr(array("LedgerEntry::verifyLedgerEntry()"
|
||||
=> compact('entry', 'tender')));
|
||||
/* pr(array("LedgerEntry::verifyLedgerEntry()" */
|
||||
/* => compact('entry', 'tender'))); */
|
||||
|
||||
if (empty($entry['account_id']) ||
|
||||
empty($entry['crdr']) ||
|
||||
empty($entry['amount'])
|
||||
) {
|
||||
pr(array("LedgerEntry::verifyLedgerEntry()"
|
||||
=> "Entry verification failed"));
|
||||
/* pr(array("LedgerEntry::verifyLedgerEntry()" */
|
||||
/* => "Entry verification failed")); */
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isset($tender) && !$this->Tender->verifyTender($tender)) {
|
||||
pr(array("LedgerEntry::verifyLedgerEntry()"
|
||||
=> "Tender verification failed"));
|
||||
/* pr(array("LedgerEntry::verifyLedgerEntry()" */
|
||||
/* => "Tender verification failed")); */
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -113,8 +113,8 @@ class LedgerEntry extends AppModel {
|
||||
* - Inserts new Ledger Entry into the database
|
||||
*/
|
||||
function addLedgerEntry($entry, $tender = null) {
|
||||
pr(array('LedgerEntry::addLedgerEntry' =>
|
||||
compact('entry', 'tender')));
|
||||
/* pr(array('LedgerEntry::addLedgerEntry' => */
|
||||
/* compact('entry', 'tender'))); */
|
||||
|
||||
$ret = array();
|
||||
if (!$this->verifyLedgerEntry($entry, $tender))
|
||||
@@ -124,9 +124,9 @@ class LedgerEntry extends AppModel {
|
||||
$entry['ledger_id'] =
|
||||
$this->Account->currentLedgerID($entry['account_id']);
|
||||
|
||||
pr(array('LedgerEntry::addLedgerEntry' =>
|
||||
array('checkpoint' => 'Pre-Save')
|
||||
+ compact('entry')));
|
||||
/* pr(array('LedgerEntry::addLedgerEntry' => */
|
||||
/* array('checkpoint' => 'Pre-Save') */
|
||||
/* + compact('entry'))); */
|
||||
|
||||
$this->create();
|
||||
if (!$this->save($entry))
|
||||
|
||||
@@ -64,16 +64,16 @@ class StatementEntry extends AppModel {
|
||||
* (not in a pre-existing statement entry)
|
||||
*/
|
||||
function verifyStatementEntry($entry) {
|
||||
pr(array("StatementEntry::verifyStatementEntry()"
|
||||
=> compact('entry')));
|
||||
/* pr(array("StatementEntry::verifyStatementEntry()" */
|
||||
/* => compact('entry'))); */
|
||||
|
||||
if (empty($entry['type']) ||
|
||||
//empty($entry['effective_date']) ||
|
||||
empty($entry['account_id']) ||
|
||||
empty($entry['amount'])
|
||||
) {
|
||||
pr(array("StatementEntry::verifyStatementEntry()"
|
||||
=> "Entry verification failed"));
|
||||
/* pr(array("StatementEntry::verifyStatementEntry()" */
|
||||
/* => "Entry verification failed")); */
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -88,16 +88,16 @@ class StatementEntry extends AppModel {
|
||||
* - Inserts new Statement Entry into the database
|
||||
*/
|
||||
function addStatementEntry($entry) {
|
||||
pr(array('StatementEntry::addStatementEntry' =>
|
||||
compact('entry')));
|
||||
/* pr(array('StatementEntry::addStatementEntry' => */
|
||||
/* compact('entry'))); */
|
||||
|
||||
$ret = array();
|
||||
if (!$this->verifyStatementEntry($entry))
|
||||
return array('error' => true, 'verify_data' => $entry) + $ret;
|
||||
|
||||
pr(array('StatementEntry::addStatementEntry' =>
|
||||
array('checkpoint' => 'Pre-Save')
|
||||
+ compact('entry')));
|
||||
/* pr(array('StatementEntry::addStatementEntry' => */
|
||||
/* array('checkpoint' => 'Pre-Save') */
|
||||
/* + compact('entry'))); */
|
||||
|
||||
$this->create();
|
||||
if (!$this->save($entry))
|
||||
@@ -406,7 +406,7 @@ OPTION 2
|
||||
* - Assigns all credits to existing charges
|
||||
*/
|
||||
function assignCredits($query = null, $receipt_id = null) {
|
||||
pr(array('StatementEntry::assignCredits' => compact('query', 'receipt_id')));
|
||||
/* pr(array('StatementEntry::assignCredits' => compact('query', 'receipt_id'))); */
|
||||
$this->queryInit($query);
|
||||
|
||||
$ret = array();
|
||||
@@ -416,7 +416,7 @@ OPTION 2
|
||||
$lquery['conditions'][] = array('StatementEntry.type' => 'CREDIT');
|
||||
$lquery['order'][] = 'StatementEntry.effective_date ASC';
|
||||
$credits = $this->find('all', $lquery);
|
||||
pr(compact('lquery', 'credits'));
|
||||
/* pr(compact('lquery', 'credits')); */
|
||||
|
||||
// Then, find all receipts that have not had all
|
||||
// monies dispursed for either payments or credits
|
||||
@@ -439,7 +439,7 @@ OPTION 2
|
||||
$ac['Transaction'] += $ac[0];
|
||||
unset($ac[0]);
|
||||
}
|
||||
pr(compact('lquery', 'anon_credits'));
|
||||
/* pr(compact('lquery', 'anon_credits')); */
|
||||
|
||||
// Next, add in the credits from the newly added receipt
|
||||
if (!empty($receipt_id)) {
|
||||
@@ -452,7 +452,7 @@ OPTION 2
|
||||
if ($receipt_credit)
|
||||
$anon_credits[] = $receipt_credit;
|
||||
|
||||
pr(compact('lquery', 'anon_credits'));
|
||||
/* pr(compact('lquery', 'anon_credits')); */
|
||||
}
|
||||
|
||||
// REVISIT <AP>: 20090726
|
||||
@@ -463,7 +463,7 @@ OPTION 2
|
||||
$lquery = $query;
|
||||
$lquery['order'] = 'StatementEntry.effective_date ASC';
|
||||
$charges = $this->reconciledSet('CHARGE', $query, true);
|
||||
pr(compact('lquery', 'charges'));
|
||||
/* pr(compact('lquery', 'charges')); */
|
||||
|
||||
// Initialize our list of used credits
|
||||
$used_credits = array();
|
||||
@@ -472,9 +472,9 @@ OPTION 2
|
||||
// Work through all unpaid charges, applying payments as we go
|
||||
foreach ($charges['entries'] AS $charge) {
|
||||
|
||||
pr(array('StatementEntry::assignCredits' =>
|
||||
array('checkpoint' => 'Process Charge')
|
||||
+ compact('charge')));
|
||||
/* pr(array('StatementEntry::assignCredits' => */
|
||||
/* array('checkpoint' => 'Process Charge') */
|
||||
/* + compact('charge'))); */
|
||||
|
||||
// Check that we have available credits.
|
||||
// Technically, this isn't necessary, since the loop
|
||||
@@ -482,8 +482,8 @@ OPTION 2
|
||||
// just saves extra processing if/when there is no
|
||||
// means to resolve a charge anyway.
|
||||
if (count($credits) == 0 && count($anon_credits) == 0) {
|
||||
pr(array('StatementEntry::assignCredits' =>
|
||||
array('checkpoint' => 'No available credits')));
|
||||
/* pr(array('StatementEntry::assignCredits' => */
|
||||
/* array('checkpoint' => 'No available credits'))); */
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -491,9 +491,9 @@ OPTION 2
|
||||
while ($charge['balance'] > 0 &&
|
||||
(count($credits) || count($anon_credits))) {
|
||||
|
||||
pr(array('StatementEntry::assignCredits' =>
|
||||
array('checkpoint' => 'Attempt Charge Reconciliation')
|
||||
+ compact('charge')));
|
||||
/* pr(array('StatementEntry::assignCredits' => */
|
||||
/* array('checkpoint' => 'Attempt Charge Reconciliation') */
|
||||
/* + compact('charge'))); */
|
||||
|
||||
// Use explicit credits before using implicit credits
|
||||
// (Not sure it matters though).
|
||||
@@ -529,11 +529,11 @@ OPTION 2
|
||||
$credit['applied'] += $payment_amount;
|
||||
$credit['balance'] -= $payment_amount;
|
||||
|
||||
pr(array('StatementEntry::assignCredits' =>
|
||||
array('checkpoint' => (($credit['balance'] > 0 ? 'Utilized' : 'Exhausted')
|
||||
. (count($credits) ? '' : ' Anon')
|
||||
. ' Credit'))
|
||||
+ compact('credit')));
|
||||
/* pr(array('StatementEntry::assignCredits' => */
|
||||
/* array('checkpoint' => (($credit['balance'] > 0 ? 'Utilized' : 'Exhausted') */
|
||||
/* . (count($credits) ? '' : ' Anon') */
|
||||
/* . ' Credit')) */
|
||||
/* + compact('credit'))); */
|
||||
|
||||
if ($credit['balance'] < 0)
|
||||
die("HOW DID WE END UP WITH NEGATIVE CREDIT BALANCE?");
|
||||
@@ -559,9 +559,9 @@ OPTION 2
|
||||
'comment' => null,
|
||||
);
|
||||
|
||||
pr(array('StatementEntry::assignCredits' =>
|
||||
array('checkpoint' => 'New Payment Entry')
|
||||
+ compact('payment')));
|
||||
/* pr(array('StatementEntry::assignCredits' => */
|
||||
/* array('checkpoint' => 'New Payment Entry') */
|
||||
/* + compact('payment'))); */
|
||||
|
||||
$result = $this->addStatementEntry($payment);
|
||||
$ret['Payment'][] = $result;
|
||||
@@ -573,9 +573,9 @@ OPTION 2
|
||||
if ($charge['balance'] < 0)
|
||||
die("HOW DID WE GET A NEGATIVE CHARGE AMOUNT?");
|
||||
|
||||
if ($charge['balance'] <= 0)
|
||||
pr(array('StatementEntry::assignCredits' =>
|
||||
array('checkpoint' => 'Fully Paid Charge')));
|
||||
/* if ($charge['balance'] <= 0) */
|
||||
/* pr(array('StatementEntry::assignCredits' => */
|
||||
/* array('checkpoint' => 'Fully Paid Charge'))); */
|
||||
}
|
||||
|
||||
}
|
||||
@@ -584,24 +584,24 @@ OPTION 2
|
||||
if (isset($credits[0]['applied']))
|
||||
$used_credits[] = array_shift($credits);
|
||||
|
||||
pr(array('StatementEntry::assignCredits' =>
|
||||
array('checkpoint' => 'Payments added')
|
||||
+ compact('credits', 'used_credits', 'anon_credits', 'used_anon_credits')));
|
||||
/* pr(array('StatementEntry::assignCredits' => */
|
||||
/* array('checkpoint' => 'Payments added') */
|
||||
/* + compact('credits', 'used_credits', 'anon_credits', 'used_anon_credits'))); */
|
||||
|
||||
// Clean up any explicit credits that have been used
|
||||
foreach ($used_credits AS $credit) {
|
||||
if ($credit['balance'] > 0) {
|
||||
pr(array('StatementEntry::assignCredits' =>
|
||||
array('checkpoint' => 'Update Credit Entry')
|
||||
+ compact('credit')));
|
||||
/* pr(array('StatementEntry::assignCredits' => */
|
||||
/* array('checkpoint' => 'Update Credit Entry') */
|
||||
/* + compact('credit'))); */
|
||||
|
||||
$this->id = $credit['StatementEntry']['id'];
|
||||
$this->saveField('amount', $credit['balance']);
|
||||
}
|
||||
else {
|
||||
pr(array('StatementEntry::assignCredits' =>
|
||||
array('checkpoint' => 'Delete Exhausted Credit Entry')
|
||||
+ compact('credit')));
|
||||
/* pr(array('StatementEntry::assignCredits' => */
|
||||
/* array('checkpoint' => 'Delete Exhausted Credit Entry') */
|
||||
/* + compact('credit'))); */
|
||||
|
||||
$this->del($credit['StatementEntry']['id'], false);
|
||||
}
|
||||
@@ -612,9 +612,9 @@ OPTION 2
|
||||
if ($credit['balance'] <= 0)
|
||||
die("HOW DID EXHAUSTED ANON CREDITS GET LEFT?");
|
||||
|
||||
pr(array('StatementEntry::assignCredits' =>
|
||||
array('checkpoint' => 'Create Explicit Credit')
|
||||
+ compact('credit')));
|
||||
/* pr(array('StatementEntry::assignCredits' => */
|
||||
/* array('checkpoint' => 'Create Explicit Credit') */
|
||||
/* + compact('credit'))); */
|
||||
|
||||
$result = $this->addStatementEntry
|
||||
(array('type' => 'CREDIT',
|
||||
|
||||
@@ -21,12 +21,12 @@ class Tender extends AppModel {
|
||||
* (not in a pre-existing tender)
|
||||
*/
|
||||
function verifyTender($tender) {
|
||||
pr(array("Tender::verifyTender()"
|
||||
=> compact('tender')));
|
||||
/* pr(array("Tender::verifyTender()" */
|
||||
/* => compact('tender'))); */
|
||||
|
||||
if (empty($tender['tender_type_id'])) {
|
||||
pr(array("Tender::verifyTender()"
|
||||
=> "Tender verification failed"));
|
||||
/* pr(array("Tender::verifyTender()" */
|
||||
/* => "Tender verification failed")); */
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ class Tender extends AppModel {
|
||||
*/
|
||||
|
||||
function addTender($tender) {
|
||||
pr(array('Tender::addTender' =>
|
||||
compact('tender')));
|
||||
/* pr(array('Tender::addTender' => */
|
||||
/* compact('tender'))); */
|
||||
|
||||
$ret = array();
|
||||
if (!$this->verifyTender($tender))
|
||||
@@ -65,9 +65,9 @@ class Tender extends AppModel {
|
||||
}
|
||||
}
|
||||
|
||||
pr(array('Tender::addTender' =>
|
||||
array('checkpoint' => 'Pre-Save')
|
||||
+ array('Tender' => $tender)));
|
||||
/* pr(array('Tender::addTender' => */
|
||||
/* array('checkpoint' => 'Pre-Save') */
|
||||
/* + array('Tender' => $tender))); */
|
||||
|
||||
$this->create();
|
||||
if (!$this->save($tender))
|
||||
|
||||
@@ -101,8 +101,8 @@ class Transaction extends AppModel {
|
||||
* (not in a pre-existing transaction)
|
||||
*/
|
||||
function verifyTransaction($transaction, $entries) {
|
||||
pr(array("Transaction::verifyTransaction()"
|
||||
=> compact('transaction', 'entries', 'customer_id', 'lease_id')));
|
||||
/* pr(array("Transaction::verifyTransaction()" */
|
||||
/* => compact('transaction', 'entries', 'customer_id', 'lease_id'))); */
|
||||
|
||||
// Verify required Transaction data is present
|
||||
if (empty($transaction['type']) ||
|
||||
@@ -113,8 +113,8 @@ class Transaction extends AppModel {
|
||||
(in_array($transaction['type'], array('INVOICE'))
|
||||
&& empty($transaction['lease_id']))
|
||||
) {
|
||||
pr(array("Transaction::verifyTransaction()"
|
||||
=> "Transaction verification failed"));
|
||||
/* pr(array("Transaction::verifyTransaction()" */
|
||||
/* => "Transaction verification failed")); */
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -122,13 +122,13 @@ class Transaction extends AppModel {
|
||||
foreach ($entries AS $entry) {
|
||||
extract($entry);
|
||||
if (!$this->LedgerEntry->DoubleEntry->verifyDoubleEntry($le1, $le2, $le1_tender)) {
|
||||
pr(array("Transaction::verifyTransaction()"
|
||||
=> "Double Entry verification failed"));
|
||||
/* pr(array("Transaction::verifyTransaction()" */
|
||||
/* => "Double Entry verification failed")); */
|
||||
return false;
|
||||
}
|
||||
if (!$this->StatementEntry->verifyStatementEntry($se)) {
|
||||
pr(array("Transaction::verifyTransaction()"
|
||||
=> "Statement Entry verification failed"));
|
||||
/* pr(array("Transaction::verifyTransaction()" */
|
||||
/* => "Statement Entry verification failed")); */
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -196,8 +196,8 @@ class Transaction extends AppModel {
|
||||
*/
|
||||
|
||||
function addTransaction($data, $customer_id, $lease_id = null) {
|
||||
pr(array("Transaction::addTransaction()"
|
||||
=> compact('data', 'customer_id', 'lease_id')));
|
||||
/* pr(array("Transaction::addTransaction()" */
|
||||
/* => compact('data', 'customer_id', 'lease_id'))); */
|
||||
|
||||
if (!isset($data['Transaction']) || !isset($data['Entry']))
|
||||
return array('error' => true);
|
||||
@@ -278,9 +278,9 @@ class Transaction extends AppModel {
|
||||
if (!$this->verifyTransaction($transaction, $data['Entry'], $customer_id, $lease_id))
|
||||
return array('error' => true) + $ret;
|
||||
|
||||
pr(array('Transaction::addTransaction' =>
|
||||
array('checkpoint' => 'Pre Transaction Save')
|
||||
+ compact('transaction')));
|
||||
/* pr(array('Transaction::addTransaction' => */
|
||||
/* array('checkpoint' => 'Pre Transaction Save') */
|
||||
/* + compact('transaction'))); */
|
||||
|
||||
// Save transaction to the database
|
||||
$this->create();
|
||||
@@ -338,8 +338,8 @@ class Transaction extends AppModel {
|
||||
$ret['error'] = true;
|
||||
}
|
||||
|
||||
pr(array('Transaction::addTransaction' =>
|
||||
array('return' => $ret)));
|
||||
/* pr(array('Transaction::addTransaction' => */
|
||||
/* array('return' => $ret))); */
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user