diff --git a/models/account.php b/models/account.php index a6ce986..c0a2558 100644 --- a/models/account.php +++ b/models/account.php @@ -85,6 +85,25 @@ class Account extends AppModel { } + /************************************************************************** + ************************************************************************** + ************************************************************************** + * function: name + * - Returns the name of this account + */ + function name($id) { + $this->cacheQueries = true; + $account = $this->find('first', array + ('recursive' => -1, + 'fields' => array('name'), + 'conditions' => array(array('Account.id' => $id)), + )); + $this->cacheQueries = false; + + return $account['Account']['name']; + } + + /************************************************************************** ************************************************************************** ************************************************************************** diff --git a/models/transaction.php b/models/transaction.php index 7c323c8..7dfb7a8 100644 --- a/models/transaction.php +++ b/models/transaction.php @@ -166,7 +166,7 @@ class Transaction extends AppModel { foreach ($data['LedgerEntry'] AS $entry) { // Get the Monetary Source squared away - if ($entry['account_name'] === 'Cash') { + if ($entry['account_id'] == $A->cashAccountID()) { // No distinguishing features of Cash, just // use the shared monetary source $entry['monetary_source_id'] = @@ -174,17 +174,14 @@ class Transaction extends AppModel { unset($entry['MonetarySource']); } else { - // The monetary source needs to be unique - // Create a new one dedicated to this entry + $entry['MonetarySource']['name'] = $A->name($entry['account_id']); + // Give it a fancy name based on the check number - if ($entry['account_name'] === 'Check' || - $entry['account_name'] === 'Money Order') { + if ($A->name($entry['account_id']) === 'Check' || + $A->name($entry['account_id']) === 'Money Order') { $entry['MonetarySource']['name'] .= ' #' . $entry['MonetarySource']['data1']; } - else { - $entry['MonetarySource']['name'] = $entry['account_name']; - } } // This entry of physical money is part of the receipt transaction @@ -193,7 +190,7 @@ class Transaction extends AppModel { // Receipt must debit the "money" asset (bank, cash, check, etc)... $entry['debit_ledger_id'] - = $A->currentLedgerID($A->nameToID($entry['account_name'])); + = $A->currentLedgerID($entry['account_id']); // ...and credit the Receipt ledger $entry['credit_ledger_id'] diff --git a/views/customers/receipt.ctp b/views/customers/receipt.ctp index 0fc710d..c36f2f3 100644 --- a/views/customers/receipt.ctp +++ b/views/customers/receipt.ctp @@ -170,24 +170,21 @@ function addPaymentSource(flash) { '
' + $type, 'name' => $name, 'acct' => $acct); - } - - foreach ($types AS $type) { - $div = '
'; - $div .= ''; - $div .= ' '; - $div .= '
'; - echo "'$div' +\n"; - } + echo FormatHelper::phpVarToJavascript + ($form->input('LedgerEntry.%{id}.account_id', + array('type' => 'radio', + 'separator' => '
', + 'onclick' => ('switchPaymentType(' . + '\\\'payment-type-div\\\', ' . + '%{id}, ' . + '$(this).attr("id")' . + ')' . + //' return false;' + '' + ), + 'legend' => false, + 'value' => $defaultAccount, + 'options' => $paymentAccounts))) . "+\n"; ?> '
' + @@ -199,9 +196,9 @@ function addPaymentSource(flash) { '' + $name) { $div = 'Check Number' + @@ -234,7 +231,7 @@ function switchPaymentType(paymentid_base, paymentid, type) { ''; break; - case 'moneyorder': + case 'Money Order': html = '
' + ' ' + @@ -244,7 +241,7 @@ function switchPaymentType(paymentid_base, paymentid, type) { '
'; break; - case 'ach': + case 'ACH': html = '
' + ' ' + @@ -261,7 +258,7 @@ function switchPaymentType(paymentid_base, paymentid, type) { '
'; break; - case 'creditcard': + case 'Credit Card': html = '
' + ' ' + @@ -285,16 +282,12 @@ function switchPaymentType(paymentid_base, paymentid, type) { '
'; break; - case 'concession': - return; - default: - html = '

INVALID TYPE ('+type+')

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