Preventing moved-out leases in sitelink data from being closed, since the security deposit hasn't been released. Added a temporary function to release the deposit, so I can manually release and close the few leases needed.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@510 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-08-10 01:27:12 +00:00
parent 07a2be05f7
commit cdb7d4b15c
3 changed files with 21 additions and 6 deletions

View File

@@ -962,7 +962,7 @@ foreach $row (@{query($sdbh, $query)}) {
'lease_date' => datefmt($row->{'DateIn'}),
'movein_date' => datefmt($row->{'DateIn'}),
'moveout_date' => datefmt($row->{'DateOut'}),
'close_date' => datefmt($row->{'DateClosed'}),
#'close_date' => datefmt($row->{'DateClosed'}),
'rent' => $row->{'Rent'},
#'comment' => "LedgerID: $row->{'LedgerID'}",
});

View File

@@ -329,9 +329,23 @@ class LeasesController extends AppController {
* - Closes a lease to any further action
*/
// REVISIT <AP>: 20090809
// While cleaning up the sitelink data, then delete reldep()
function reldep($id) {
$this->Lease->id = $id;
$stamp = $this->Lease->field('moveout_date');
$this->Lease->releaseSecurityDeposits($id, $stamp);
$this->redirect(array('action'=>'view', $id));
}
function close($id) {
// REVISIT <AP>: 20090708
// We should probably seek confirmation first...
if (!$this->Lease->closeable($id)) {
INTERNAL_ERROR("This lease is not ready to close");
$this->redirect(array('action'=>'view', $id));
}
$this->Lease->close($id);
$this->redirect(array('action'=>'view', $id));
}

View File

@@ -700,12 +700,13 @@ class Lease extends AppModel {
if (isset($this->data['Lease']['close_date']))
return $this->prReturn(false);
$deposit_balance = $this->securityDepositBalance($id);
$stats = $this->stats($id);
// A lease can only be closed if there are no outstanding
// security deposits, and if the account balance is zero.
if ($deposit_balance != 0)
// security deposits ...
if ($this->securityDepositBalance($id) != 0)
return $this->prReturn(false);
// ... and if the account balance is zero.
if ($this->balance($id) != 0)
return $this->prReturn(false);
// Apparently this lease meets all the criteria!