Added routines to reconcile a new ledger entry against unreconciled entries. I haven't tested it robustly, but it seems to work on the surface at least.
git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@161 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -30,6 +30,24 @@ class Lease extends AppModel {
|
||||
'LateSchedule',
|
||||
);
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* function: accountId
|
||||
* - Returns the accountId of the given lease
|
||||
*/
|
||||
function accountId($id) {
|
||||
$this->cacheQueries = true;
|
||||
$lease = $this->find('first', array
|
||||
('recursive' => -1,
|
||||
'fields' => array('account_id'),
|
||||
'conditions' => array(array('id' => $id)),
|
||||
));
|
||||
$this->cacheQueries = false;
|
||||
|
||||
return $lease['Lease']['account_id'];
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
@@ -43,14 +61,9 @@ class Lease extends AppModel {
|
||||
/* 'args' => compact('id', 'all', 'cond', 'link'), */
|
||||
/* )); */
|
||||
|
||||
$lease = $this->find('first', array
|
||||
('recursive' => -1,
|
||||
'fields' => array('account_id'),
|
||||
'conditions' => array(array('id' => $id)),
|
||||
));
|
||||
|
||||
$entries = $this->Account->findLedgerEntries($lease['Lease']['account_id'],
|
||||
$entries = $this->Account->findLedgerEntries($this->accountId($id),
|
||||
$all, $cond, $link);
|
||||
|
||||
/* pr(array('function' => 'Lease::findAccountEntries', */
|
||||
/* 'args' => compact('id', 'all', 'cond', 'link'), */
|
||||
/* 'vars' => compact('lease'), */
|
||||
@@ -71,14 +84,8 @@ class Lease extends AppModel {
|
||||
/* 'args' => compact('id', 'link'), */
|
||||
/* )); */
|
||||
|
||||
$lease = $this->find('first', array
|
||||
('recursive' => -1,
|
||||
'fields' => array('account_id'),
|
||||
'conditions' => array(array('id' => $id)),
|
||||
));
|
||||
|
||||
$entries = $this->Account->findLedgerEntriesRelatedToAccount
|
||||
($lease['Lease']['account_id'],
|
||||
($this->accountId($id),
|
||||
$this->Account->securityDepositAccountID(),
|
||||
true, null, $link);
|
||||
|
||||
@@ -99,14 +106,29 @@ class Lease extends AppModel {
|
||||
* (such as charges not paid).
|
||||
*/
|
||||
|
||||
function findUnreconciledLedgerEntries($id = null) {
|
||||
$lease = $this->find('first', array
|
||||
('recursive' => -1,
|
||||
'fields' => array('account_id'),
|
||||
'conditions' => array(array('id' => $id)),
|
||||
));
|
||||
function findUnreconciledLedgerEntries($id = null, $fundamental_type = null) {
|
||||
return $this->Account->findUnreconciledLedgerEntries
|
||||
($this->accountId($id), $fundamental_type);
|
||||
}
|
||||
|
||||
return $this->Account->findUnreconciledLedgerEntries($lease['Lease']['account_id']);
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* function: reconcileNewLedgerEntry
|
||||
* - 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 reconcileNewLedgerEntry($id, $fund, $amount) {
|
||||
return $this->Account->reconcileNewLedgerEntry
|
||||
($this->accountId($id), $fund, $amount);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user