Check in the near completed implementation of security deposit utilization. It was on it's way to working well (although it only works for existing payment divs and there is not an obviously easy way for new payment divs to have the security deposit info as well). It feels like we've really gone overboard on the payment screen, pushing too much together. I'm going to strip some of this out on the next checkin, and create a dedicated security deposit utilization screen, perhaps just as part of move-out, or perhaps part of move-out and as an independent operation as well.
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@292 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -399,12 +399,27 @@ 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;
|
||||
@@ -445,12 +460,23 @@ class CustomersController extends AppController {
|
||||
$unreconciled = $this->Customer->findUnreconciledLedgerEntries($id);
|
||||
$unreconciled = array('entries' =>
|
||||
array_intersect_key($unreconciled['debit'],
|
||||
array('entry'=>1, 'balance'=>1)));
|
||||
array('entry'=>1, 'balance'=>1)),
|
||||
'deposit' => array(),
|
||||
);
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
@@ -137,6 +137,14 @@ class TransactionsController extends AppController {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach($this->data['LedgerEntry'] AS &$entry) {
|
||||
if (!isset($entry['acct'][$entry['account_id']]))
|
||||
continue;
|
||||
|
||||
$entry['MonetarySource'] = $entry['acct'][$entry['account_id']];
|
||||
}
|
||||
|
||||
pr($this->data);
|
||||
if (!$this->Transaction->addReceipt($this->data,
|
||||
$this->data['Customer']['id'])) {
|
||||
$this->Session->setFlash("RECEIPT FAILED", true);
|
||||
|
||||
@@ -86,8 +86,8 @@ class Customer extends AppModel {
|
||||
|
||||
$A = new Account();
|
||||
$entries = $A->findLedgerEntriesRelatedToAccount
|
||||
($A->invoiceAccountID(),
|
||||
$A->securityDepositAccountID(),
|
||||
($A->securityDepositAccountID(),
|
||||
array($A->invoiceAccountID(), $A->receiptAccountID()),
|
||||
true, array('LedgerEntry.customer_id' => $id), $link);
|
||||
|
||||
/* pr(array('function' => 'Customer::findSecurityDeposits', */
|
||||
|
||||
@@ -88,8 +88,8 @@ class Lease extends AppModel {
|
||||
|
||||
$A = new Account();
|
||||
$entries = $A->findLedgerEntriesRelatedToAccount
|
||||
($this->accountId($id),
|
||||
$A->securityDepositAccountID(),
|
||||
($A->securityDepositAccountID(),
|
||||
array($A->invoiceAccountID(), $A->receiptAccountID()),
|
||||
true, array('LedgerEntry.lease_id' => $id), $link);
|
||||
|
||||
/* pr(array('function' => 'Lease::findSecurityDeposits', */
|
||||
|
||||
@@ -91,7 +91,8 @@ class LedgerEntry extends AppModel {
|
||||
* query the ledger/account to find it out.
|
||||
*/
|
||||
function ledgerContextFields($ledger_id = null, $account_type = null) {
|
||||
$fields = array('id', 'effective_date', 'through_date', 'comment', 'amount');
|
||||
$fields = array('id', 'effective_date', 'through_date',
|
||||
'lease_id', 'customer_id', 'comment', 'amount');
|
||||
|
||||
if (isset($ledger_id)) {
|
||||
$fields[] = ("IF(LedgerEntry.debit_ledger_id = $ledger_id," .
|
||||
|
||||
@@ -201,6 +201,57 @@ function addPaymentSource(flash) {
|
||||
$div .= ' ID="payment-type-div-%{id}-'.$account_id.'"';
|
||||
$div .= ' CLASS="payment-type-div-%{id}"';
|
||||
$div .= ' STYLE="display:none;">';
|
||||
|
||||
if ($name == 'Check') {
|
||||
$div .= '<DIV CLASS="input text required">';
|
||||
$div .= ' <LABEL FOR="payment-check-number-%{id}">Check Number</LABEL>';
|
||||
$div .= ' <INPUT TYPE="text" SIZE="6" NAME="data[LedgerEntry][%{id}][acct]['.$account_id.'][data1]"';
|
||||
$div .= ' ID="payment-check-number-%{id}" />';
|
||||
$div .= '</DIV>';
|
||||
}
|
||||
elseif ($name == 'Money Order') {
|
||||
$div .= '<DIV CLASS="input text required">';
|
||||
$div .= ' <LABEL FOR="payment-moneyorder-number-%{id}">Money Order Number</LABEL>';
|
||||
$div .= ' <INPUT TYPE="text" SIZE="6" NAME="data[LedgerEntry][%{id}][acct]['.$account_id.'][data1]"';
|
||||
$div .= ' ID="payment-moneyorder-number-%{id}" />';
|
||||
$div .= '</DIV>';
|
||||
}
|
||||
elseif ($name == 'ACH') {
|
||||
$div .= '<DIV CLASS="input text required">';
|
||||
$div .= ' <LABEL FOR="payment-ach-routing-%{id}">Routing Number</LABEL>';
|
||||
$div .= ' <INPUT TYPE="text" SIZE="9" NAME="data[LedgerEntry][%{id}][acct]['.$account_id.'][data1]"';
|
||||
$div .= ' ID="payment-ach-routing-%{id}" />';
|
||||
$div .= '</DIV>';
|
||||
|
||||
$div .= '<DIV CLASS="input text required">';
|
||||
$div .= ' <LABEL FOR="payment-ach-account-%{id}">Account Number</LABEL>';
|
||||
$div .= ' <INPUT TYPE="text" SIZE="17" NAME="data[LedgerEntry][%{id}][acct]['.$account_id.'][data2]"';
|
||||
$div .= ' ID="payment-ach-account-%{id}" />';
|
||||
$div .= '</DIV>';
|
||||
}
|
||||
elseif ($name == 'Credit Card') {
|
||||
$div .= '<DIV CLASS="input text required">';
|
||||
$div .= ' <LABEL FOR="payment-creditcard-account-%{id}">Account Number</LABEL>';
|
||||
$div .= ' <INPUT TYPE="text" SIZE="16" NAME="data[LedgerEntry][%{id}][acct]['.$account_id.'][data1]"';
|
||||
$div .= ' ID="payment-creditcard-account-%{id}" />';
|
||||
$div .= '</DIV>';
|
||||
|
||||
$div .= '<DIV CLASS="input text required">';
|
||||
$div .= ' <LABEL FOR="payment-creditcard-expiration-%{id}">Expiration Date</LABEL>';
|
||||
$div .= ' <INPUT TYPE="text" SIZE="10" NAME="data[LedgerEntry][%{id}][acct]['.$account_id.'][data2]"';
|
||||
$div .= ' ID="payment-creditcard-expiration-%{id}" />';
|
||||
$div .= ' </DIV>';
|
||||
|
||||
$div .= '<DIV CLASS="input text required">';
|
||||
$div .= ' <LABEL FOR="payment-creditcard-cvv2-%{id}">CVV2 Code</LABEL>';
|
||||
$div .= ' <INPUT TYPE="text" SIZE="10" NAME="data[LedgerEntry][%{id}][acct]['.$account_id.'][data3]"';
|
||||
$div .= ' ID="payment-creditcard-cvv2-%{id}" />';
|
||||
$div .= '</DIV>';
|
||||
}
|
||||
elseif ($name == 'Security Deposit') {
|
||||
$div .= '<DIV CLASS="security-deposit-info"></DIV>';
|
||||
}
|
||||
|
||||
$div .= '</DIV>';
|
||||
echo "'$div' +\n";
|
||||
}
|
||||
@@ -211,82 +262,8 @@ function addPaymentSource(flash) {
|
||||
}
|
||||
|
||||
function switchPaymentType(paymentid_base, paymentid, radioid) {
|
||||
//alert(paymentid_base + ";\n" + paymentid + ";\n" + radioid);
|
||||
$("."+paymentid_base+"-"+paymentid).slideUp();
|
||||
$("."+paymentid_base+"-"+paymentid).html('');
|
||||
|
||||
var html;
|
||||
var type = $("#"+radioid+ " + label").html();
|
||||
var account_id = $("#"+radioid).val();
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case 'Check':
|
||||
html =
|
||||
'<DIV CLASS="input text required">' +
|
||||
' <LABEL FOR="payment-check-number-'+paymentid+'">Check Number</LABEL>' +
|
||||
// REVISIT <AP>: 20090617: Use comment field for now.
|
||||
' <INPUT TYPE="text" SIZE="6" NAME="data[LedgerEntry]['+paymentid+'][MonetarySource][data1]"' +
|
||||
' ID="payment-check-number-'+paymentid+'" />' +
|
||||
'</DIV>';
|
||||
break;
|
||||
|
||||
case 'Money Order':
|
||||
html =
|
||||
'<DIV CLASS="input text required">' +
|
||||
' <LABEL FOR="payment-moneyorder-number-'+paymentid+'">Money Order Number</LABEL>' +
|
||||
// REVISIT <AP>: 20090617: Use comment field for now.
|
||||
' <INPUT TYPE="text" SIZE="6" NAME="data[LedgerEntry]['+paymentid+'][MonetarySource][data1]"' +
|
||||
' ID="payment-moneyorder-number-'+paymentid+'" />' +
|
||||
'</DIV>';
|
||||
break;
|
||||
|
||||
case 'ACH':
|
||||
html =
|
||||
'<DIV CLASS="input text required">' +
|
||||
' <LABEL FOR="payment-ach-routing-'+paymentid+'">Routing Number</LABEL>' +
|
||||
// REVISIT <AP>: 20090617: Use comment field for now.
|
||||
' <INPUT TYPE="text" SIZE="9" NAME="data[LedgerEntry]['+paymentid+'][MonetarySource][data1]"' +
|
||||
' ID="payment-ach-routing-'+paymentid+'" />' +
|
||||
'</DIV>' +
|
||||
|
||||
'<DIV CLASS="input text required">' +
|
||||
' <LABEL FOR="payment-ach-account-'+paymentid+'">Account Number</LABEL>' +
|
||||
// REVISIT <AP>: 20090617: Use comment field for now.
|
||||
' <INPUT TYPE="text" SIZE="17" NAME="data[LedgerEntry]['+paymentid+'][MonetarySource][data2]"' +
|
||||
' ID="payment-ach-account-'+paymentid+'" />' +
|
||||
'</DIV>';
|
||||
break;
|
||||
|
||||
case 'Credit Card':
|
||||
html =
|
||||
'<DIV CLASS="input text required">' +
|
||||
' <LABEL FOR="payment-creditcard-account-'+paymentid+'">Account Number</LABEL>' +
|
||||
// REVISIT <AP>: 20090617: Use comment field for now.
|
||||
' <INPUT TYPE="text" SIZE="16" NAME="data[LedgerEntry]['+paymentid+'][MonetarySource][data1]' +
|
||||
' ID="payment-creditcard-account-'+paymentid+'" />' +
|
||||
'</DIV>' +
|
||||
|
||||
'<DIV CLASS="input text required">' +
|
||||
' <LABEL FOR="payment-creditcard-expiration-'+paymentid+'">Expiration Date</LABEL>' +
|
||||
// REVISIT <AP>: 20090617: Use comment field for now.
|
||||
' <INPUT TYPE="text" SIZE="10" NAME="data[LedgerEntry]['+paymentid+'][MonetarySource][data2]' +
|
||||
' ID="payment-creditcard-expiration-'+paymentid+'" />' +
|
||||
' </DIV>' +
|
||||
|
||||
'<DIV CLASS="input text required">' +
|
||||
' <LABEL FOR="payment-creditcard-cvv2-'+paymentid+'">CVV2 Code</LABEL>' +
|
||||
// REVISIT <AP>: 20090617: Use comment field for now.
|
||||
' <INPUT TYPE="text" SIZE="10" NAME=data[LedgerEntry]['+paymentid+'][MonetarySource][data3]' +
|
||||
' ID="payment-creditcard-cvv2-'+paymentid+'" />' +
|
||||
'</DIV>';
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
$("#"+paymentid_base+"-"+paymentid+"-"+account_id).html(html);
|
||||
$("#"+paymentid_base+"-"+paymentid+"-"+account_id).slideDown();
|
||||
}
|
||||
|
||||
@@ -311,11 +288,22 @@ function updateCharges(id) {
|
||||
dataType: "xml",
|
||||
success: function(xml) {
|
||||
var ids = new Array();
|
||||
//$('#update-target ol').html('<A HREF="'+url+'">Data URL</A>');
|
||||
$('entry',xml).each(function(i){
|
||||
ids.push($(this).attr('id'));
|
||||
//$('#update-target').append("Push: len=" + ids.length + '<BR>');
|
||||
});
|
||||
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);
|
||||
@@ -381,7 +369,7 @@ echo('<DIV CLASS="receipt grid-selection-text">' .
|
||||
'<DIV CLASS="customer-selection-valid" style="display:none">' .
|
||||
|
||||
//'<DIV CLASS="supporting">' .
|
||||
'<TABLE>' .
|
||||
'<TABLE ID="supporting-table">' .
|
||||
'<TR><TD CLASS="field">Balance:</TD><TD CLASS="value"><SPAN id="receipt-balance"></SPAN></TD></TR>' .
|
||||
'</TABLE>' .
|
||||
//'</DIV>' .
|
||||
|
||||
Reference in New Issue
Block a user