diff --git a/app_model.php b/app_model.php index 067ab83..ede3751 100644 --- a/app_model.php +++ b/app_model.php @@ -104,11 +104,11 @@ class AppModel extends Model { $trace = debug_backtrace(false); - // Get rid of pr/prEnter/prExit + // Get rid of pr/prEnter/prReturn $caller = array_shift($trace); // The next entry shows where pr was called from, but it - // shows _what_ was called, which is pr/prEntry/prExit. + // shows _what_ was called, which is pr/prEntry/prReturn. $caller = array_shift($trace); $file = $caller['file']; $line = $caller['line']; @@ -158,8 +158,8 @@ class AppModel extends Model { $this->_pr($level, $args, 'Function Entry'); } - function prExit($retval, $level = 16) { - $this->_pr($level, $retval, 'Function Exit'); + function prReturn($retval, $level = 16) { + $this->_pr($level, $retval, 'Function Return'); return $retval; } diff --git a/models/statement_entry.php b/models/statement_entry.php index ec95d36..0bfecdf 100644 --- a/models/statement_entry.php +++ b/models/statement_entry.php @@ -22,7 +22,7 @@ class StatementEntry extends AppModel { ); - var $default_log_level = 30; + //var $default_log_level = 30; /************************************************************************** ************************************************************************** @@ -45,7 +45,8 @@ class StatementEntry extends AppModel { ($sum ? ')' : '') . ' AS payment' . ($sum ? 's' : ''), ($sum ? 'SUM(' : '') . - "IF({$entry_name}.type = 'CHARGE', 1, -1)" . + "IF({$entry_name}.type = 'CHARGE', 1," . + " IF({$entry_name}.type = 'PAYMENT' OR {$entry_name}.type = 'SURPLUS', -1, 0))" . " * IF({$entry_name}.amount, {$entry_name}.amount, 0)" . ($sum ? ')' : '') . ' AS balance', ); @@ -73,10 +74,10 @@ class StatementEntry extends AppModel { empty($entry['account_id']) || empty($entry['amount']) ) { - return $this->prExit(false); + return $this->prReturn(false); } - return $this->prExit(true); + return $this->prReturn(true); } @@ -101,7 +102,7 @@ class StatementEntry extends AppModel { return array('error' => true, 'save_data' => $entry) + $ret; $ret['statement_entry_id'] = $this->id; - return $this->prExit($ret + array('error' => false)); + return $this->prReturn($ret + array('error' => false)); } @@ -184,7 +185,7 @@ OPTION 2 elseif (isset($entry['credit_ledger_id'])) $refund_account_id = $this->Ledger->accountID($entry['credit_ledger_id']); else - return $this->prExit(null); + return $this->prReturn(null); // post new refund in the income account $ids = $A->postEntry @@ -207,14 +208,14 @@ OPTION 2 ); if ($ids['error']) - return $this->prExit(null); + return $this->prReturn(null); $transaction_id = $ids['transaction_id']; $this->pr(15, compact('ids', 'amount', 'refund_account_id', 'ar_account_id'), 'Posted Refund Ledger Entry'); } - return $this->prExit(true); + return $this->prReturn(true); } @@ -277,7 +278,7 @@ OPTION 2 } } - return $this->prExit(array('entries' => $resultset, + return $this->prReturn(array('entries' => $resultset, 'summary' => $this->stats(null, $query))); } @@ -314,7 +315,7 @@ OPTION 2 foreach (array_keys($result) AS $i) unset($result[$i]['StatementEntry']); - return $this->prExit(array('entries' => $result)); + return $this->prReturn(array('entries' => $result)); } @@ -330,6 +331,7 @@ OPTION 2 * */ function assignCredits($query = null, $receipt_id = null) { + //$this->prFunctionLevel(25); $this->prEnter( compact('query', 'receipt_id')); $this->queryInit($query); @@ -524,7 +526,7 @@ OPTION 2 $ret['error'] = true; } - return $this->prExit($ret + array('error' => false)); + return $this->prReturn($ret + array('error' => false)); } @@ -585,7 +587,7 @@ OPTION 2 $this->pr(17, compact('rquery', 'result'), 'Payments'); - return $this->prExit($stats); + return $this->prReturn($stats); } }