Begin the move from having receipts generated based on 'collectable' account, to being based on what the database considers to be a form of tender. This has the excellent benefit of removing all those hardcoded data1/2 fields for each different tender type. That's all database driven now. There is more to do, but this is a good step forward.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@382 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-24 03:58:12 +00:00
parent 2db0fc12d3
commit a4dff8a6ed
2 changed files with 47 additions and 71 deletions

View File

@@ -367,21 +367,29 @@ class CustomersController extends AppController {
$this->Customer->recursive = -1;
$customer = $this->Customer->read(null, $id);
$customer = $customer['Customer'];
$unreconciled = $this->Customer->findUnreconciledLedgerEntries($id);
$charges = $unreconciled['debit'];
$unreconciled = $this->Customer->unreconciledCharges($id);
//pr($unreconciled);
$charges = $unreconciled['entries'];
$stats = $unreconciled['summary']['Charge'];
// Kludge until we update receipt to have the unpaid
// charges grid generated from a dynamic query instead
// of simply pre-providing the list of charge IDs
foreach ($charges AS &$charge)
$charge['id'] = $charge['StatementEntry']['id'];
}
else {
$customer = null;
$charges = array('balance' => 0, 'entry' => array());
$charges = array();
$stats = array('balance' => 0);
}
$A = new Account();
$payment_accounts = $A->paymentAccounts();
$default_account = $A->cashAccountID();
$this->set(compact('payment_accounts', 'default_account'));
$TT = new TenderType();
$payment_types = $TT->paymentTypes();
$default_type = $TT->defaultPaymentType();
$this->set(compact('payment_types', 'default_type'));
$title = ($customer['name'] . ': Payment Entry');
$this->set(compact('customer', 'charges', 'title'));
$this->set(compact('customer', 'charges', 'stats', 'title'));
}

View File

@@ -42,9 +42,9 @@ function verifyRequest(formData, jqForm, options) {
// formData is an array; here we use $.param to convert it to a string to display it
// but the form plugin does this for you automatically when it submits the data
//var_dump(formData);
//$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
$('#request-debug').html('Ommitted');
//return false;
$('#request-debug').html('<PRE>'+dump(formData)+'</PRE>');
//$('#request-debug').html('Ommitted');
return false;
$('#response-debug').html('Loading <BLINK>...</BLINK>');
$('#output-debug').html('Loading <BLINK>...</BLINK>');
@@ -147,8 +147,13 @@ function addPaymentSource(flash) {
'<DIV ID="payment-div-%{id}">' +
<?php
// Rearrange to be of the form (id => name)
$radioOptions = array();
foreach ($paymentTypes AS $type)
$radioOptions[$type['TenderType']['id']] = $type['TenderType']['name'];
echo FormatHelper::phpVarToJavascript
($form->input('LedgerEntry.%{id}.account_id',
($form->input('Entry.%{id}.tender_type_id',
array('type' => 'radio',
'separator' => '<BR>',
'onclick' => ('switchPaymentType(' .
@@ -160,73 +165,36 @@ function addPaymentSource(flash) {
''
),
'legend' => false,
'value' => $defaultAccount,
'options' => $paymentAccounts))) . "+\n";
'value' => $defaultType,
'options' => $radioOptions))) . "+\n";
?>
'</DIV>' +
'<DIV ID="payment-amount-div-%{id}" CLASS="input text required">' +
' <LABEL FOR="payment-amount-%{id}">Amount</LABEL>' +
' <INPUT TYPE="text" SIZE="20"' +
' NAME="data[LedgerEntry][%{id}][amount]"' +
' NAME="data[Entry][%{id}][amount]"' +
' ID="payment-amount-%{id}" />' +
'</DIV>' +
<?php
foreach ($paymentAccounts AS $account_id => $name) {
foreach ($paymentTypes AS $type) {
$type = $type['TenderType'];
$div = '<DIV';
$div .= ' ID="payment-type-div-%{id}-'.$account_id.'"';
$div .= ' ID="payment-type-div-%{id}-'.$type['id'].'"';
$div .= ' CLASS="payment-type-div-%{id}"';
$div .= ' STYLE="display:none;">';
if ($type['id'] != $defaultType)
$div .= ' STYLE="display:none;"';
$div .= '>';
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>';
}
else {
continue;
for ($i=1; $i<=4; ++$i) {
if (!empty($type["data{$i}_name"])) {
$div .= '<DIV CLASS="input text required">';
$div .= ' <LABEL FOR="payment-data'.$i.'-%{id}">'.$type["data{$i}_name"].'</LABEL>';
$div .= ' <INPUT TYPE="text" SIZE="20" NAME="data[Entry][%{id}][type]['.$type['id'].'][data'.$i.']"';
$div .= ' ID="payment-data'.$i.'-%{id}" />';
$div .= '</DIV>';
}
}
$div .= '</DIV>';
@@ -240,8 +208,8 @@ function addPaymentSource(flash) {
function switchPaymentType(paymentid_base, paymentid, radioid) {
$("."+paymentid_base+"-"+paymentid).slideUp();
var account_id = $("#"+radioid).val();
$("#"+paymentid_base+"-"+paymentid+"-"+account_id).slideDown();
var type_id = $("#"+radioid).val();
$("#"+paymentid_base+"-"+paymentid+"-"+type_id).slideDown();
}
@@ -321,7 +289,7 @@ echo ('<DIV CLASS="receipt grid-selection-text">' .
'</DIV>' . "\n");
echo $this->element('ledger_entries', array
echo $this->element('statement_entries', array
(// Element configuration
'account_ftype' => 'credit',
'limit' => 8,
@@ -332,7 +300,7 @@ echo $this->element('ledger_entries', array
'grid_div_id' => 'charge-entries',
'grid_div_class' => 'text-below',
'caption' => '<SPAN id="receipt-charges-caption"></SPAN>',
'rows' => $charges['entry'],
'rows' => $charges,
),
));
@@ -411,7 +379,7 @@ echo $form->submit('Generate Receipt') . "\n";
"<?php echo $customer['id']; ?>" +
'</A>');
$("#receipt-customer-name").html("<?php echo $customer['name']; ?>");
$("#receipt-balance").html(fmtCurrency("<?php echo $charges['balance']; ?>"));
$("#receipt-balance").html(fmtCurrency("<?php echo $stats['balance']; ?>"));
onGridState(null, 'hidden');
<?php else: ?>
onGridState(null, 'visible');