Finished basic functionality for Move-Out. This still needs some work to handle the security deposit.
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@202 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -31,9 +31,6 @@ class Lease extends AppModel {
|
||||
|
||||
var $hasMany = array(
|
||||
'LedgerEntry',
|
||||
|
||||
// Cheat to get Account set as part of this class
|
||||
'Account',
|
||||
);
|
||||
|
||||
|
||||
@@ -44,7 +41,8 @@ class Lease extends AppModel {
|
||||
* - Returns the accountId of the given lease
|
||||
*/
|
||||
function accountId($id) {
|
||||
return $this->Account->invoiceAccountID();
|
||||
$A = new Account();
|
||||
return $A->invoiceAccountID();
|
||||
}
|
||||
|
||||
|
||||
@@ -64,8 +62,9 @@ class Lease extends AppModel {
|
||||
$cond = array();
|
||||
$cond[] = array('LedgerEntry.lease_id' => $id);
|
||||
|
||||
$entries = $this->Account->findLedgerEntries($this->accountId($id),
|
||||
$all, $cond, $link);
|
||||
$A = new Account();
|
||||
$entries = $A->findLedgerEntries($this->accountId($id),
|
||||
$all, $cond, $link);
|
||||
|
||||
/* pr(array('function' => 'Lease::findAccountEntries', */
|
||||
/* 'args' => compact('id', 'all', 'cond', 'link'), */
|
||||
@@ -87,9 +86,10 @@ class Lease extends AppModel {
|
||||
/* 'args' => compact('id', 'link'), */
|
||||
/* )); */
|
||||
|
||||
$entries = $this->Account->findLedgerEntriesRelatedToAccount
|
||||
$A = new Account();
|
||||
$entries = $A->findLedgerEntriesRelatedToAccount
|
||||
($this->accountId($id),
|
||||
$this->Account->securityDepositAccountID(),
|
||||
$A->securityDepositAccountID(),
|
||||
true, array('LedgerEntry.lease_id' => $id), $link);
|
||||
|
||||
/* pr(array('function' => 'Lease::findSecurityDeposits', */
|
||||
@@ -110,7 +110,8 @@ class Lease extends AppModel {
|
||||
*/
|
||||
|
||||
function findUnreconciledLedgerEntries($id = null, $fundamental_type = null) {
|
||||
return $this->Account->findUnreconciledLedgerEntries
|
||||
$A = new Account();
|
||||
return $A->findUnreconciledLedgerEntries
|
||||
($this->accountId($id), $fundamental_type, array('LedgerEntry.lease_id' => $id));
|
||||
}
|
||||
|
||||
@@ -130,11 +131,42 @@ class Lease extends AppModel {
|
||||
*/
|
||||
|
||||
function reconcileNewLedgerEntry($id, $fundamental_type, $amount) {
|
||||
return $this->Account->reconcileNewLedgerEntry
|
||||
$A = new Account();
|
||||
return $A->reconcileNewLedgerEntry
|
||||
($this->accountId($id), $fundamental_type, $amount, array('LedgerEntry.lease_id' => $id));
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* function: moveOut
|
||||
* - Moves the customer out of the specified lease
|
||||
*/
|
||||
|
||||
function moveOut($id = null, $status = 'VACANT',
|
||||
$stamp = null, $close = false) {
|
||||
$this->create(false);
|
||||
$this->id = $id;
|
||||
|
||||
// Use NOW if not given a moveout date
|
||||
if (!isset($stamp))
|
||||
$stamp = date('Y-m-d G:i:s');
|
||||
|
||||
// Move customer out of the lease, and possibly close it
|
||||
$this->data['Lease']['moveout_date'] = $stamp;
|
||||
if ($close)
|
||||
$this->data['Lease']['close_date'] = $stamp;
|
||||
|
||||
// Save it!
|
||||
$this->save($this->data, false);
|
||||
|
||||
// Finally, update the unit status
|
||||
$this->recursive = -1;
|
||||
$this->read();
|
||||
$this->Unit->updateStatus($this->data['Lease']['unit_id'], $status);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
@@ -146,8 +178,9 @@ class Lease extends AppModel {
|
||||
if (!$id)
|
||||
return null;
|
||||
|
||||
$stats = $this->Account->stats($this->Account->accountReceivableAccountID(), true,
|
||||
array('LedgerEntry.lease_id' => $id));
|
||||
$A = new Account();
|
||||
$stats = $A->stats($A->accountReceivableAccountID(), true,
|
||||
array('LedgerEntry.lease_id' => $id));
|
||||
|
||||
// Pull to the top level and return
|
||||
$stats = $stats['Ledger'];
|
||||
|
||||
Reference in New Issue
Block a user