Implemented the balance field of Leases as part of a single query. This not only reduces the number of queries required, it also allows balance to be a sortable column, so that we can determine which customers are overdue.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@251 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-07 16:08:56 +00:00
parent f4319364f2
commit 3f275b127b
4 changed files with 53 additions and 18 deletions

View File

@@ -32,6 +32,23 @@ class LedgerEntry extends AppModel {
'className' => 'Ledger',
'foreignKey' => 'credit_ledger_id',
),
'Ledger' => array(
'foreignKey' => false,
// conditions will be used when JOINing tables
// (such as find with LinkableBehavior)
'conditions' => array('OR' =>
array('%{MODEL_ALIAS}.debit_ledger_id = Ledger.id',
'%{MODEL_ALIAS}.credit_ledger_id = Ledger.id')),
// finderQuery will be used when tables are put
// together across several querys, not with JOIN.
// (such as find with ContainableBehavior)
'finderQuery' => 'NOT-IMPLEMENTED',
'counterQuery' => ''
),
);
var $hasAndBelongsToMany = array(