Implemented a single function to assess rent across all leases.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@506 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -407,8 +407,8 @@ class LeasesController extends AppController {
|
||||
* - Assesses the new monthly rent charge, if need be
|
||||
*/
|
||||
|
||||
function assess_rent($id, $date = null) {
|
||||
$this->Lease->assessMonthlyRent($id, $date);
|
||||
function assess_rent($date = null) {
|
||||
$this->Lease->assessMonthlyRentAll($date);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -326,7 +326,11 @@ class Lease extends AppModel {
|
||||
|
||||
// Build the invoice transaction
|
||||
$invoice = array('Transaction' => array(), 'Entry' => array());
|
||||
//$invoice['Transaction']['stamp'] = date('Y-m-d', $date);
|
||||
// REVISIT <AP>: 20090808
|
||||
// Keeping Transaction.stamp until the existing facility
|
||||
// is up to date. Then we want the stamp to be now()
|
||||
// (and so can just delete the next line).
|
||||
$invoice['Transaction']['stamp'] = date('Y-m-d', $date);
|
||||
$invoice['Entry'][] =
|
||||
array('effective_date' => date('Y-m-d', $date),
|
||||
'through_date' => date('Y-m-d', $charge_through_date),
|
||||
@@ -342,6 +346,30 @@ class Lease extends AppModel {
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* function: assessMonthlyRentAll
|
||||
* - Ensures rent has been charged on all open leases
|
||||
*/
|
||||
|
||||
function assessMonthlyRentAll($date = null) {
|
||||
$this->prEnter(compact('date'));
|
||||
$leases = $this->find
|
||||
('all', array('contain' => false,
|
||||
'conditions' => array('Lease.close_date' => null),
|
||||
));
|
||||
|
||||
$ret = array('Lease' => array());
|
||||
foreach ($leases AS $lease) {
|
||||
$result = $this->assessMonthlyRent($lease['Lease']['id'], $date);
|
||||
$ret['Lease'][$lease['Lease']['id']] = $result;
|
||||
if ($result['error'])
|
||||
$ret['error'] = true;
|
||||
}
|
||||
return $this->prReturn($ret + array('error' => false));
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user