Removed remnants of the Containable behavior (which we've already put into the application model. Modified the account model to look for all unreconciled transactions, not just those from the current ledger. Added a mechanism to find unreconciled transactions up the chain, including lease and customer.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@159 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-17 09:00:38 +00:00
parent 518f7836ac
commit 1e3774cad6
5 changed files with 53 additions and 15 deletions

View File

@@ -39,13 +39,11 @@ class Customer extends AppModel {
/* 'args' => compact('id', 'link'), */
/* )); */
$this->Behaviors->attach('Containable');
$customer = $this->find('first',
array('contain' =>
array('Lease' => array('fields' => array('id'))),
'fields' => array('account_id'),
'conditions' => array(array('Customer.id' => $id))));
$this->Behaviors->detach('Containable');
$entries = $this->Account->findLedgerEntriesRelatedToAccount
($customer['Customer']['account_id'],
@@ -69,6 +67,36 @@ class Customer extends AppModel {
}
/**************************************************************************
**************************************************************************
**************************************************************************
* function: findUnreconciledLedgerEntries
* - Returns ledger entries that are not yet reconciled
* (such as charges not paid).
*/
function findUnreconciledLedgerEntries($id = null) {
$customer = $this->find('first',
array('contain' =>
array('Lease' => array('fields' => array('id'))),
'fields' => array('account_id'),
'conditions' => array(array('Customer.id' => $id))));
$unreconciled = $this->Account->findUnreconciledLedgerEntries
($customer['Customer']['account_id']);
foreach ($customer['Lease'] AS $lease) {
$lease_unrec = $this->Lease->findUnreconciledLedgerEntries($lease['id']);
$unreconciled['debits'] = array_merge($unreconciled['debits'],
$lease_unrec['debits']);
$unreconciled['credits'] = array_merge($unreconciled['credits'],
$lease_unrec['credits']);
}
return $unreconciled;
}
/**************************************************************************
**************************************************************************
**************************************************************************
@@ -132,7 +160,6 @@ class Customer extends AppModel {
return null;
// Get the basic information necessary
$this->Behaviors->attach('Containable');
$customer = $this->find('first',
array('contain' =>
array('Account' => array
@@ -143,7 +170,6 @@ class Customer extends AppModel {
),
'conditions' => array
(array('Customer.id' => $id))));
$this->Behaviors->detach('Containable');
// Get stats from the customer account, and each lease
$stats['Account'] = $this->Account->stats($customer['Account']['id']);