Stripped security deposits out of the Receipt page (and bad debt too). Added a dedicated security deposit utilization page. Works, I think, but my eyes are closing and it really needs fresh eyes again in the morning.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@293 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-10 09:28:29 +00:00
parent bcbe3767e3
commit 99904f22bb
5 changed files with 68 additions and 45 deletions

View File

@@ -399,27 +399,12 @@ class CustomersController extends AppController {
*/
function receipt($id = null) {
/* $deposits = $this->Customer->findSecurityDeposits($id); */
/* pr($deposits); */
/* $this->autoRender = false; */
/* return; */
if (isset($id)) {
$this->Customer->recursive = -1;
$customer = $this->Customer->read(null, $id);
$customer = $customer['Customer'];
$unreconciled = $this->Customer->findUnreconciledLedgerEntries($id);
$charges = $unreconciled['debit'];
$leases = $this->Customer->find('first', array('contain' => array('CurrentLease'),
'conditions' => array('Customer.id' => $id)));
$deposits = array();
foreach ($leases['CurrentLease'] AS $lease) {
$lease_deposits = $this->Customer->Lease->findSecurityDeposits($lease['id']);
$deposits[] = array('lease_id' => $lease['id'],
'balance' => $lease_deposits['summary']['balance']);
}
pr($deposits);
$this->set(compact('deposits'));
}
else {
$customer = null;
@@ -460,23 +445,12 @@ class CustomersController extends AppController {
$unreconciled = $this->Customer->findUnreconciledLedgerEntries($id);
$unreconciled = array('entries' =>
array_intersect_key($unreconciled['debit'],
array('entry'=>1, 'balance'=>1)),
'deposit' => array(),
);
array('entry'=>1, 'balance'=>1)));
// XML Helper will dump an empty tag if the array is empty
if (!count($unreconciled['entries']['entry']))
unset($unreconciled['entries']['entry']);
$leases = $this->Customer->find('first', array('contain' => array('CurrentLease'),
'conditions' => array('Customer.id' => $id)));
foreach ($leases['CurrentLease'] AS $lease) {
$lease_deposits = $this->Customer->Lease->findSecurityDeposits($lease['id']);
$unreconciled['deposit'][]
= array('lease_id' => $lease['id'],
'balance' => $lease_deposits['summary']['balance']);
}
pr($unreconciled);
//$reconciled = $cust->reconcileNewLedgerEntry($cust_id, 'credit', $amount);

View File

@@ -228,6 +228,61 @@ class LeasesController extends AppController {
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: apply_deposit
* - Applies the security deposit to charges. This is much
* like a receipt, but it's separated to keep it simple and
* to prevent feature overload on the receipt page.
*/
function apply_deposit($id) {
$A = new Account();
$lease = $this->Lease->find
('first', array
('contain' => array
(// Models
'Unit' =>
array('order' => array('sort_order'),
'fields' => array('id', 'name'),
),
'Customer' =>
array('fields' => array('id', 'name'),
),
),
'conditions' => array(array('Lease.id' => $id),
array('Lease.close_date' => null),
),
));
// Get the lease balance, part of lease stats
$this->Lease->statsMerge($lease['Lease'],
array('stats' => $this->Lease->stats($id)));
// Determine the lease security deposit
$deposit = $this->Lease->findSecurityDeposits($lease['Lease']['id']);
$this->set(compact('deposit'));
$this->set('customer', $lease['Customer']);
$this->set('unit', $lease['Unit']);
$this->set('lease', $lease['Lease']);
$this->set('account', array('id' => $A->securityDepositAccountID()));
/* $redirect = array('controller' => 'leases', */
/* 'action' => 'view', */
/* $id); */
$title = ('Lease #' . $lease['Lease']['number'] . ': ' .
$lease['Unit']['name'] . ': ' .
$lease['Customer']['name'] . ': Utilize Security Deposit');
$this->set(compact('title', 'redirect'));
}
/**************************************************************************
**************************************************************************
**************************************************************************
@@ -346,6 +401,11 @@ class LeasesController extends AppController {
'action' => 'receipt',
$lease['Customer']['id']));
if (isset($lease['Lease']['moveout_date']) && $outstanding_deposit > 0)
$this->sidemenu_links[] =
array('name' => 'Apply Deposit', 'url' => array('action' => 'apply_deposit',
$id));
if ($this->Lease->closeable($id))
$this->sidemenu_links[] =
array('name' => 'Close', 'url' => array('action' => 'close',

View File

@@ -146,7 +146,8 @@ class TransactionsController extends AppController {
pr($this->data);
if (!$this->Transaction->addReceipt($this->data,
$this->data['Customer']['id'])) {
$this->data['Customer']['id'],
$this->data['Lease']['id'])) {
$this->Session->setFlash("RECEIPT FAILED", true);
// REVISIT <AP> 20090706:
// Until we can work out the session problems,