Fixed bug when fetching data for editing a customer (the details function was deleted sometime back and might be worth putting back in). Also, added a tiny helper feature to update cached items while things are still somewhat unstable. Any time customer edit is clicked, the customer (and associated leases) will all be updated. This should allow an easy customer workaround in case there is a bug in the field.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@599 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-08-17 05:43:01 +00:00
parent 4c44794212
commit b8d0e18014
3 changed files with 47 additions and 4 deletions

View File

@@ -208,6 +208,7 @@ class Customer extends AppModel {
* - Update any cached or calculated fields
*/
function update($id) {
$this->prEnter(compact('id'));
// REVISIT <AP>: 20090812
// updateLeaseCount is handled directly when needed.
@@ -216,11 +217,21 @@ class Customer extends AppModel {
$current_leases =
$this->find('all',
array('link' => array('CurrentLease' => array('type' => 'INNER')),
// REVISIT <AP>: 20090816
// Do we need to update leases other than the current ones?
// It may be necessary. For example, a non-current lease
// can still be hit with an NSF item. In that case, it
// could have stale data if we look only to current leases.
//array('link' => array('CurrentLease' => array('type' => 'INNER')),
array('link' => array('Lease' => array('type' => 'INNER')),
'conditions' => array('Customer.id' => $id)));
foreach ($current_leases AS $lease)
$this->Lease->update($lease['CurrentLease']['id']);
foreach ($current_leases AS $lease) {
if (!empty($lease['CurrentLease']['id']))
$this->Lease->update($lease['CurrentLease']['id']);
if (!empty($lease['Lease']['id']))
$this->Lease->update($lease['Lease']['id']);
}
}

View File

@@ -792,6 +792,8 @@ class Lease extends AppModel {
* - Update any cached or calculated fields
*/
function update($id) {
$this->prEnter(compact('id'));
$this->id = $id;
$this->saveField('charge_through_date', $this->rentChargeThrough($id));
$this->saveField('paid_through_date', $this->rentPaidThrough($id));