From fb29380ac55d49bb9ece2da3433ba459b616a57e Mon Sep 17 00:00:00 2001 From: abijah Date: Thu, 9 Jul 2009 06:10:00 +0000 Subject: [PATCH] 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 --- models/transaction.php | 28 +++++++++++++++++----- views/customers/receipt.ctp | 47 +++++++++++++++++++++---------------- 2 files changed, 49 insertions(+), 26 deletions(-) diff --git a/models/transaction.php b/models/transaction.php index 5b4543d..8e055e3 100644 --- a/models/transaction.php +++ b/models/transaction.php @@ -180,12 +180,16 @@ class Transaction extends AppModel { $this->LedgerEntry->MonetarySource->MonetaryType ->nameToID($entry['monetary_type_name']); - $entry['MonetarySource']['name'] = - $this->LedgerEntry->MonetarySource->MonetaryType - ->nameToID($entry['monetary_type_name']); - + if (!isset($entry['MonetarySource']['monetary_type_id'])) { + $entry['MonetarySource']['name'] = 'Other'; + $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 - $entry['MonetarySource']['name'] = $entry['monetary_type_name']; if ($entry['monetary_type_name'] === 'Check' || $entry['monetary_type_name'] === 'Money Order') { $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 : 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 // debit: Cash/Check/Etc credit: Receipt @@ -200,7 +216,7 @@ class Transaction extends AppModel { // Receipt must debit the "money" asset (bank, cash, check, etc)... $entry['debit_ledger_id'] - = $A->currentLedgerID($A->nameToID($entry['monetary_type_name'])); + = $A->currentLedgerID($A->nameToID($account_name)); // ...and credit the Receipt ledger $entry['credit_ledger_id'] diff --git a/views/customers/receipt.ctp b/views/customers/receipt.ctp index 52e8619..9a23de9 100644 --- a/views/customers/receipt.ctp +++ b/views/customers/receipt.ctp @@ -168,20 +168,25 @@ function addPaymentSource(flash) { '
' + 'Payment #%{id} (%{remove})' + - '
' + + '
' + $type, 'name' => $name, 'acct' => $acct); + } - foreach ($types AS $type => $name) { + foreach ($types AS $type) { $div = '
'; $div .= ''; - $div .= ' '; + $div .= ' ONCLICK="switchPaymentType(\\\'payment-type-div\\\', %{id}, \\\''.$type['key'].'\\\')"'; + $div .= ' CLASS="payment-radio-%{id}" ID="payment-radio-%{id}-'.$type['key'].'"'; + $div .= ' VALUE="'.$type['acct'].'" ' . ($type['name'] == 'Cash' ? 'CHECKED ' : '') . '/>'; + $div .= ' '; $div .= '
'; echo "'$div' +\n"; } @@ -196,12 +201,9 @@ function addPaymentSource(flash) { '
' + $name) { - if ($type == 'cash') - continue; - + foreach ($types AS $type) { $div = ''; break; + case 'concession': + return; + default: - html = '

INVALID TYPE ('+type+')

'; + html = '

INVALID TYPE ('+type+')

'; break; } - $("#payment-"+type+"-div-"+paymentid).html(html); - $("#payment-"+type+"-div-"+paymentid).slideDown(); + $("#"+paymentid_base+"-"+paymentid+"-"+type).html(html); + $("#"+paymentid_base+"-"+paymentid+"-"+type).slideDown(); }