This rework is nowhere near complete, but there are certain things that are falling in place, and worth capturing. I started a branch for just this purpose of being able to check in intermediate work.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@352 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-19 23:35:25 +00:00
parent e303898a95
commit 6ac0204baf
26 changed files with 3058 additions and 1767 deletions

View File

@@ -19,17 +19,14 @@ class Customer extends AppModel {
'conditions' => 'CurrentLease.close_date IS NULL',
),
'Lease',
'LedgerEntry',
'DoubleEntry',
'ContactsCustomer',
'Transaction',
);
var $hasAndBelongsToMany = array(
'Contact',
'Transaction' => array(
'joinTable' => 'ledger_entries',
'foreignKey' => 'customer_id',
'associationForeignKey' => 'transaction_id',
),
);
@@ -87,7 +84,7 @@ class Customer extends AppModel {
$A = new Account();
$entries = $A->findLedgerEntries
($A->securityDepositAccountID(),
true, array('LedgerEntry.customer_id' => $id), $link);
true, array('DoubleEntry.customer_id' => $id), $link);
/* pr(array('function' => 'Customer::findSecurityDeposits', */
/* 'args' => compact('id', 'link'), */
@@ -112,7 +109,7 @@ class Customer extends AppModel {
$unreconciled = $A->findUnreconciledLedgerEntries
($A->accountReceivableAccountID(),
$fundamental_type,
array('LedgerEntry.customer_id' => $id));
array('DoubleEntry.customer_id' => $id));
return $unreconciled;
}
@@ -121,7 +118,7 @@ class Customer extends AppModel {
/**************************************************************************
**************************************************************************
**************************************************************************
* function: reconcileNewLedgerEntry
* function: amountWouldReconcile
* - Returns which ledger entries a new credit/debit would
* reconcile, and how much.
*
@@ -132,18 +129,41 @@ class Customer extends AppModel {
* whatever algorithm is simplest.
*/
function reconcileNewLedgerEntry($id, $fundamental_type, $amount) {
function amountWouldReconcile($id, $fundamental_type, $amount) {
$A = new Account();
$reconciled = $A->reconcileNewLedgerEntry
$reconciled = $A->amountWouldReconcile
($A->accountReceivableAccountID(),
$fundamental_type,
$amount,
array('LedgerEntry.customer_id' => $id));
array('DoubleEntry.customer_id' => $id));
return $reconciled;
}
/**************************************************************************
**************************************************************************
**************************************************************************
* function: reconcileLedgerEntries
* - Returns which ledger entries a new credit/debit would
* reconcile, and how much.
*
* - REVISIT <AP> 20090617
* This should be subject to different algorithms, such
* as apply to oldest charges first, newest first, to fees
* before rent, etc. Until we get there, I'll hardcode
* whatever algorithm is simplest.
*/
function reconcileLedgerEntries($id) {
$A = new Account();
$reconciled = $A->reconcileLedgerEntries
($A->accountReceivableAccountID(),
array('DoubleEntry.customer_id' => $id));
return $reconciled;
}
/**************************************************************************
**************************************************************************
**************************************************************************
@@ -274,7 +294,7 @@ class Customer extends AppModel {
$A = new Account();
$stats = $A->stats($A->accountReceivableAccountID(), true,
array('LedgerEntry.customer_id' => $id));
array('DoubleEntry.customer_id' => $id));
// Pull to the top level and return
$stats = $stats['Ledger'];