More work on handling security deposit utilizations. This is headed in the right direction, but unfortunately, there is a problem if the security deposits have not been paid. I could just ignore it, because it's a low priority problem, but I think the solution might be to just provide a waiver on the unpaid charges. Since I need to implement fee waivers anyway, I'll just move onto that next, and then finish out the security deposit work.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@463 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-31 21:11:00 +00:00
parent b00944a412
commit 1c2c2b457c
6 changed files with 149 additions and 30 deletions

View File

@@ -70,6 +70,7 @@ class Customer extends AppModel {
return $ids;
}
/**************************************************************************
**************************************************************************
**************************************************************************
@@ -80,21 +81,46 @@ class Customer extends AppModel {
$this->prEnter(compact('id', 'query'));
$this->queryInit($query);
$A = new Account();
if (!isset($query['link']['Customer']))
$query['link']['Customer'] = array();
if (!isset($query['link']['Customer']['fields']))
$query['link']['Customer']['fields'] = array();
$query['conditions'][] = array('Customer.id' => $id);
$query['conditions'][] = array('StatementEntry.account_id' => $A->securityDepositAccountID());
$query['conditions'][] = array('StatementEntry.account_id' =>
$this->StatementEntry->Account->securityDepositAccountID());
$set = $this->StatementEntry->reconciledSet('CHARGE', $query);
$set = $this->StatementEntry->reconciledSet('CHARGE', $query, false, true);
return $this->prReturn($set);
}
/**************************************************************************
**************************************************************************
**************************************************************************
* function: securityDepositBalance
* - Returns the balance of the customer security deposit(s)
*/
function securityDepositBalance($id, $query = null) {
$this->prEnter(compact('id', 'query'));
$this->queryInit($query);
if (!isset($query['link']['Lease']))
$query['link']['Lease'] = array();
if (!isset($query['link']['Lease']['fields']))
$query['link']['Lease']['fields'] = array();
$query['conditions'][] = array('Lease.id' => $id);
$query['conditions'][] = array('StatementEntry.account_id' =>
$this->StatementEntry->Account->securityDepositAccountID());
$stats = $this->StatementEntry->stats(null, $query);
$balance = $stats['Charge']['reconciled'] - $stats['Payment']['reconciled'];
return $this->prReturn($balance);
}
/**************************************************************************
**************************************************************************
**************************************************************************