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@293 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-10 09:28:29 +00:00
parent 5877874e82
commit f2f389ee45
7 changed files with 71 additions and 48 deletions

View File

@@ -879,12 +879,12 @@ INSERT INTO `pmgr_accounts` (`type`, `name`, `tillable`, `depositable`, `chargea
('ASSET', 'Cash', 1, 0, 0, 1),
('ASSET', 'Check', 1, 0, 0, 1),
('ASSET', 'Money Order', 1, 0, 0, 1),
('LIABILITY', 'Security Deposit', 0, 0, 1, 1),
('LIABILITY', 'Security Deposit', 0, 0, 1, 0),
('INCOME', 'Rent', 0, 0, 1, 0),
('INCOME', 'Late Charge', 0, 0, 1, 0),
('INCOME', 'Damage', 0, 0, 1, 0),
('EXPENSE', 'Concession', 0, 0, 0, 1),
('EXPENSE', 'Bad Debt', 0, 0, 0, 1),
('EXPENSE', 'Bad Debt', 0, 0, 0, 0),
('EXPENSE', 'Maintenance', 0, 0, 0, 0);
UNLOCK TABLES;

View File

@@ -58,7 +58,7 @@ Operations to be functional
- NOTE: As a temporary solution, disallow customer to run
a credit. Require charges be entered first.
X - Record Customer Move-Out from Unit
- Record utilization of Security Deposit
X - Record utilization of Security Deposit
- Record issuing of a refund
- Record Deposit into Petty Cash
- Record Payment from Petty Cash to expenses

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,

View File

@@ -135,7 +135,7 @@ class Transaction extends AppModel {
* - Adds a new receipt transaction
*/
function addReceipt($data, $customer_id) {
function addReceipt($data, $customer_id, $lease_id = null) {
// Sanitize the data
if (!$data['Transaction']['comment'])
$data['Transaction']['comment'] = null;
@@ -173,7 +173,7 @@ class Transaction extends AppModel {
$this->LedgerEntry->MonetarySource->nameToID('Cash');
unset($entry['MonetarySource']);
}
else {
elseif (isset($entry['MonetarySource'])) {
$entry['MonetarySource']['name'] = $A->name($entry['account_id']);
// Give it a fancy name based on the check number
@@ -197,6 +197,7 @@ class Transaction extends AppModel {
= $A->currentLedgerID($A->receiptAccountID());
$entry['customer_id'] = $customer_id;
$entry['lease_id'] = $lease_id;
// Create it
$receipt_entry = new LedgerEntry();

View File

@@ -248,8 +248,8 @@ function addPaymentSource(flash) {
$div .= ' ID="payment-creditcard-cvv2-%{id}" />';
$div .= '</DIV>';
}
elseif ($name == 'Security Deposit') {
$div .= '<DIV CLASS="security-deposit-info"></DIV>';
else {
continue;
}
$div .= '</DIV>';
@@ -291,19 +291,6 @@ function updateCharges(id) {
$('entry',xml).each(function(i){
ids.push($(this).attr('id'));
});
var html = '';
$('deposit',xml).each(function(i){
html += '<TR><TD>Lease #' + $(this).attr('lease_id') + ' Deposit:</TD><TD>' +
fmtCurrency($(this).attr('balance')) + '</TD></TR>';
});
var html = '<UL>';
$('deposit',xml).each(function(i){
html += '<LI>Lease #' + $(this).attr('lease_id') + ': ' +
fmtCurrency($(this).attr('balance')) + '</LI>';
});
html += '</UL>';
$('.security-deposit-info').html(html);
$('#receipt-balance').html(fmtCurrency($('entries',xml).attr('balance')));
$("#receipt-charges-caption").html("Outstanding Charges");
updateChargesGrid(ids);