Several minor changes including a couple minor bugfixes.

git-svn-id: file:///svn-source/pmgr/branches/surplus_account_20090815@592 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-08-17 02:15:02 +00:00
parent 4afe0bd77b
commit 90ecbda541
8 changed files with 45 additions and 19 deletions

View File

@@ -139,8 +139,17 @@ class Account extends AppModel {
function invoiceAccountID() { return $this->nameToID('Invoice'); }
function receiptAccountID() { return $this->nameToID('Receipt'); }
function badDebtAccountID() { return $this->nameToID('Bad Debt'); }
function customerCreditAccountID() { return $this->nameToID('Credit'); }
function customerCreditAccountID() { return $this->nameToID(
// REVISIT <AP>: 20090816
// Use of A/R works, and saves an excess of accounts.
// However, a dedicated account is nice, since it can
// quickly be spotted how much is _really_ due, vs
// how much has been pre-paid. Customer credits in
// A/R is not as clear, although a report is an
// obvious solution.
//'A/R'
'Credit'
); }
/**************************************************************************
**************************************************************************
@@ -224,13 +233,28 @@ class Account extends AppModel {
function collectableAccounts() {
$accounts = $this->receiptAccounts();
foreach(array($this->nsfAccountID(),
foreach(array($this->customerCreditAccountID(),
$this->securityDepositAccountID(),
$this->nsfAccountID(),
$this->waiverAccountID(),
$this->badDebtAccountID(),
$this->securityDepositAccountID())
//$this->nameToID('Closing'),
//$this->nameToID('Equity'),
)
AS $account_id) {
$accounts[$account_id] = $this->name($account_id);
}
$accounts['all'] = $accounts['default'] = $accounts;
foreach(array($this->concessionAccountID(),
$this->waiverAccountID(),
$this->badDebtAccountID(),
)
AS $account_id) {
unset($accounts['default'][$account_id]);
}
return $accounts;
}

View File

@@ -224,9 +224,11 @@ class StatementEntry extends AppModel {
$result = $this->Transaction->addReversal
($charge, $stamp, 'Charge Reversal');
// Mark the charge as reversed
$this->id = $id;
$this->saveField('reverse_transaction_id', $result['transaction_id']);
if (empty($result['error'])) {
// Mark the charge as reversed
$this->id = $id;
$this->saveField('reverse_transaction_id', $result['transaction_id']);
}
return $this->prReturn($result);
}

View File

@@ -1169,9 +1169,12 @@ class Transaction extends AppModel {
$squery['fields'][] = "SUM(Transaction.amount) AS total";
$squery['fields'][] = "COUNT(Transaction.id) AS count";
$stats = $this->find('first', $squery);
if (empty($stats))
return $this->prReturn(array());
$stats = $stats[0];
unset($stats[0]);
foreach ($this->hasMany AS $table => $association) {
// Only calculate stats for *Entry types
if (!preg_match("/Entry$/", $table) &&