Added ACH and Concession entry. Like everything else, I haven't tested too robustly, but it does seem to work. I might want to change the monetary source id for Concession. Right now each concession gets its own monetary source, but we could probably use a common one without issue.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@284 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-09 06:10:00 +00:00
parent 37beb8b436
commit fb29380ac5
2 changed files with 49 additions and 26 deletions

View File

@@ -180,12 +180,16 @@ class Transaction extends AppModel {
$this->LedgerEntry->MonetarySource->MonetaryType $this->LedgerEntry->MonetarySource->MonetaryType
->nameToID($entry['monetary_type_name']); ->nameToID($entry['monetary_type_name']);
$entry['MonetarySource']['name'] = if (!isset($entry['MonetarySource']['monetary_type_id'])) {
$this->LedgerEntry->MonetarySource->MonetaryType $entry['MonetarySource']['name'] = 'Other';
->nameToID($entry['monetary_type_name']); $entry['MonetarySource']['monetary_type_id'] =
$this->LedgerEntry->MonetarySource->MonetaryType
->nameToID('Other Non-Tillable');
} else {
$entry['MonetarySource']['name'] = $entry['monetary_type_name'];
}
// Give it a fancy name based on the check number // Give it a fancy name based on the check number
$entry['MonetarySource']['name'] = $entry['monetary_type_name'];
if ($entry['monetary_type_name'] === 'Check' || if ($entry['monetary_type_name'] === 'Check' ||
$entry['monetary_type_name'] === 'Money Order') { $entry['monetary_type_name'] === 'Money Order') {
$entry['MonetarySource']['name'] .= $entry['MonetarySource']['name'] .=
@@ -193,6 +197,18 @@ class Transaction extends AppModel {
} }
} }
// Determine which account we'll use for the ledger entry
$account_name = $entry['monetary_type_name'];
// REVISIT <AP>: 20090708
// I _hate_ hardcoding values, but I'm not sure how
// else to handle this at the moment. I'm pretty sure
// what needs to happen is for the account information
// to be figured out programatically on the receipt
// presentation page, and then those values would flow
// back after entry to here.
if ($account_name === 'ACH')
$account_name = 'Bank';
// This entry of physical money is part of the receipt transaction // This entry of physical money is part of the receipt transaction
// debit: Cash/Check/Etc credit: Receipt // debit: Cash/Check/Etc credit: Receipt
@@ -200,7 +216,7 @@ class Transaction extends AppModel {
// Receipt must debit the "money" asset (bank, cash, check, etc)... // Receipt must debit the "money" asset (bank, cash, check, etc)...
$entry['debit_ledger_id'] $entry['debit_ledger_id']
= $A->currentLedgerID($A->nameToID($entry['monetary_type_name'])); = $A->currentLedgerID($A->nameToID($account_name));
// ...and credit the Receipt ledger // ...and credit the Receipt ledger
$entry['credit_ledger_id'] $entry['credit_ledger_id']

View File

@@ -168,20 +168,25 @@ function addPaymentSource(flash) {
'<FIELDSET CLASS="payment subset">' + '<FIELDSET CLASS="payment subset">' +
'<LEGEND>Payment #%{id} (%{remove})</LEGEND>' + '<LEGEND>Payment #%{id} (%{remove})</LEGEND>' +
'<DIV ID="payment-type-div-%{id}">' + '<DIV ID="payment-div-%{id}">' +
<?php <?php
$types = array(); $types = array();
foreach(array('Cash', 'Check', 'Money Order', /*'ACH', 'Credit Card'*/) AS $name) foreach(array('Cash', 'Check', 'Money Order', 'ACH', /*'Credit Card'*/ 'Concession') AS $name) {
$types[preg_replace("/ /", "", strtolower($name))] = $name; $type = preg_replace("/ /", "", strtolower($name));
$acct = $name;
/* if ($acct === 'ACH') */
/* $acct = 'Bank'; */
$types[] = array('key' => $type, 'name' => $name, 'acct' => $acct);
}
foreach ($types AS $type => $name) { foreach ($types AS $type) {
$div = '<DIV>'; $div = '<DIV>';
$div .= '<INPUT TYPE="radio" NAME="data[LedgerEntry][%{id}][monetary_type_name]"'; $div .= '<INPUT TYPE="radio" NAME="data[LedgerEntry][%{id}][monetary_type_name]"';
$div .= ' ONCLICK="switchPaymentType(%{id}, \\\''.$type.'\\\')"'; $div .= ' ONCLICK="switchPaymentType(\\\'payment-type-div\\\', %{id}, \\\''.$type['key'].'\\\')"';
$div .= ' CLASS="payment-type-%{id}" ID="payment-type-'.$type.'-%{id}"'; $div .= ' CLASS="payment-radio-%{id}" ID="payment-radio-%{id}-'.$type['key'].'"';
$div .= ' VALUE="'.$name.'" ' . ($name == 'Cash' ? 'CHECKED ' : '') . '/>'; $div .= ' VALUE="'.$type['acct'].'" ' . ($type['name'] == 'Cash' ? 'CHECKED ' : '') . '/>';
$div .= ' <LABEL FOR="payment-type-'.$type.'-%{id}">'.$name.'</LABEL>'; $div .= ' <LABEL FOR="payment-radio-%{id}-'.$type['key'].'">'.$type['name'].'</LABEL>';
$div .= '</DIV>'; $div .= '</DIV>';
echo "'$div' +\n"; echo "'$div' +\n";
} }
@@ -196,12 +201,9 @@ function addPaymentSource(flash) {
'</DIV>' + '</DIV>' +
<?php <?php
foreach ($types AS $type => $name) { foreach ($types AS $type) {
if ($type == 'cash')
continue;
$div = '<DIV'; $div = '<DIV';
$div .= ' ID="payment-'.$type.'-div-%{id}"'; $div .= ' ID="payment-type-div-%{id}-'.$type['key'].'"';
$div .= ' CLASS="payment-type-div-%{id}"'; $div .= ' CLASS="payment-type-div-%{id}"';
$div .= ' STYLE="display:none;">'; $div .= ' STYLE="display:none;">';
$div .= '</DIV>'; $div .= '</DIV>';
@@ -213,14 +215,16 @@ function addPaymentSource(flash) {
); );
} }
function switchPaymentType(paymentid, type) { function switchPaymentType(paymentid_base, paymentid, type) {
$(".payment-type-div-"+paymentid).slideUp(); $("."+paymentid_base+"-"+paymentid).slideUp();
$(".payment-type-div-"+paymentid).html(''); $("."+paymentid_base+"-"+paymentid).html('');
var html;
switch(type) switch(type)
{ {
case 'cash': case 'cash':
break; return;
case 'check': case 'check':
html = html =
@@ -283,13 +287,16 @@ function switchPaymentType(paymentid, type) {
'</DIV>'; '</DIV>';
break; break;
case 'concession':
return;
default: default:
html = '<DIV><H2>INVALID TYPE ('+type+')</H2></DIV>'; html = '<H2>INVALID TYPE ('+type+')</H2>';
break; break;
} }
$("#payment-"+type+"-div-"+paymentid).html(html); $("#"+paymentid_base+"-"+paymentid+"-"+type).html(html);
$("#payment-"+type+"-div-"+paymentid).slideDown(); $("#"+paymentid_base+"-"+paymentid+"-"+type).slideDown();
} }