Implemented a single function to assess rent across all leases.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@506 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-08-08 16:09:49 +00:00
parent 868e23b982
commit a0c00f1a35
3 changed files with 43 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ use Data::Dumper;
use File::Copy;
my $closing_one_transaction = 0;
my $work_from_scratch = 1;
my $work_from_scratch = 0;
# Internally adjust all numbers coming from the database to
# be in inches. Not necessary to go to this detail, but the
@@ -1576,3 +1576,14 @@ $query = "UPDATE pmgr_transactions T, pmgr_ledger_entries E
WHERE E.transaction_id = T.id AND E.account_id = T.account_id";
query($db_handle, $query);
######################################################################
## Invoice date fixes
# print("Fix Invoice Dates...\n");
# $query = "UPDATE pmgr_transactions T, pmgr_statement_entries E
# SET T.`stamp` =
# WHERE E.transaction_id = T.id AND E.account_id = T.account_id";
# query($db_handle, $query);

View File

@@ -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);
}

View File

@@ -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));
}
/**************************************************************************
**************************************************************************
**************************************************************************