diff --git a/scripts/sitelink2pmgr.pl b/scripts/sitelink2pmgr.pl index 0027875..b8d4238 100644 --- a/scripts/sitelink2pmgr.pl +++ b/scripts/sitelink2pmgr.pl @@ -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); + diff --git a/site/controllers/leases_controller.php b/site/controllers/leases_controller.php index 6ea53be..ac0269e 100644 --- a/site/controllers/leases_controller.php +++ b/site/controllers/leases_controller.php @@ -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); } diff --git a/site/models/lease.php b/site/models/lease.php index 82bcfab..c82d26c 100644 --- a/site/models/lease.php +++ b/site/models/lease.php @@ -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 : 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)); + } + /************************************************************************** ************************************************************************** **************************************************************************