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