Fixed the monthly charges report to only reflect income accounts (not things like security deposits). Also, by restricting to charges, the report was neglecting things like reversals, leaving the totals skewed. Thefore, the 'CHARGES' restriction was removed and replaced with the much more appropriate chargeDisbursementFields() function, which dumps fields that tabulate correctly.

git-svn-id: file:///svn-source/pmgr/branches/v0.3_work@962 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2010-03-12 02:21:57 +00:00
parent 2f2a4642fb
commit 68e6dc2d20

View File

@@ -264,11 +264,10 @@ class StatementEntriesController extends AppController {
$result = $this->StatementEntry->find $result = $this->StatementEntry->find
('all', ('all',
array('link' => array('Account' => array('fields' => 'name')), array('link' => array('Account' => array('fields' => 'name')),
'fields' => array('MONTHNAME(effective_date) AS month', 'fields' => array_merge(array('MONTHNAME(effective_date) AS month',
'YEAR(effective_date) AS year', 'YEAR(effective_date) AS year'),
'SUM(amount) AS amount', $this->StatementEntry->chargeDisbursementFields(true)),
), 'conditions' => array('Account.type' => 'INCOME',
'conditions' => array('StatementEntry.type' => 'CHARGE',
'effective_date >= DATE(NOW() - INTERVAL 11 MONTH - INTERVAL DAY(NOW())-1 DAY)', 'effective_date >= DATE(NOW() - INTERVAL 11 MONTH - INTERVAL DAY(NOW())-1 DAY)',
'effective_date <= NOW()', 'effective_date <= NOW()',
), ),
@@ -285,10 +284,10 @@ class StatementEntriesController extends AppController {
'charges' => 0); 'charges' => 0);
$month = &$overview['months'][$mname]; $month = &$overview['months'][$mname];
$month['subs'][] = array('name' => $row['Account']['name'], $month['subs'][] = array('name' => $row['Account']['name'],
'charges' => $row[0]['amount']); 'charges' => $row[0]['balance']);
$month['charges'] += $row[0]['amount']; $month['charges'] += $row[0]['balance'];
$overview['charges'] += $row[0]['amount']; $overview['charges'] += $row[0]['balance'];
} }
// Enable the Reports menu section // Enable the Reports menu section