From 0c8035b4021ff360c9f0e6ac1c4561c37dc11f02 Mon Sep 17 00:00:00 2001 From: abijah Date: Thu, 9 Jul 2009 08:28:34 +0000 Subject: [PATCH] Removed monetary_source_type. It was redundant, and it's entirely unclear what purpose it ultimately would or could serve. Our use of different accounts for Check, Cash, etc likely obsoleted any intention we might have had for monetary_source_type git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@288 97e9348a-65ac-dc4b-aefc-98561f571b83 --- controllers/ledger_entries_controller.php | 1 - controllers/monetary_sources_controller.php | 7 ++-- models/account.php | 24 +++++-------- models/monetary_source.php | 1 - models/monetary_type.php | 16 --------- models/transaction.php | 37 ++++----------------- views/customers/receipt.ctp | 4 +-- views/elements/monetary_sources.ctp | 1 - views/monetary_sources/view.ctp | 3 -- 9 files changed, 19 insertions(+), 75 deletions(-) delete mode 100644 models/monetary_type.php diff --git a/controllers/ledger_entries_controller.php b/controllers/ledger_entries_controller.php index aad81e4..4a21335 100644 --- a/controllers/ledger_entries_controller.php +++ b/controllers/ledger_entries_controller.php @@ -284,7 +284,6 @@ class LedgerEntriesController extends AppController { ('first', array('contain' => array('MonetarySource.id', 'MonetarySource.name', - 'MonetarySource.MonetaryType.id', 'Transaction.id', 'Transaction.stamp', 'DebitLedger.id', diff --git a/controllers/monetary_sources_controller.php b/controllers/monetary_sources_controller.php index ffe5ab3..cef0f05 100644 --- a/controllers/monetary_sources_controller.php +++ b/controllers/monetary_sources_controller.php @@ -38,8 +38,7 @@ class MonetarySourcesController extends AppController { function jqGridDataTables(&$params, &$model) { return array - ('link' => array('MonetaryType' => array('fields' => array('MonetaryType.id', 'MonetaryType.name')), - ), + ('contain' => false, ); } @@ -65,9 +64,7 @@ class MonetarySourcesController extends AppController { // Get the MonetarySource and related fields $monetary_source = $this->MonetarySource->find ('first', array - ('contain' => array - ('MonetaryType', - ), + ('contain' => false, )); // Prepare to render. diff --git a/models/account.php b/models/account.php index c0c02bb..a6ce986 100644 --- a/models/account.php +++ b/models/account.php @@ -463,10 +463,9 @@ class Account extends AppModel { * * monetary_source_data * - monetary_source_id (optional... if set all else is ignored) - * - monetary_type_name + * - account_name * - MonetarySource * - name - * - monetary_type_id */ function postLedgerEntry($transaction_data, @@ -512,8 +511,8 @@ class Account extends AppModel { = array_intersect_key($monetary_data, array('monetary_source_id'=>1)); } - elseif (isset($monetary_data['monetary_type_name'])) { - if ($monetary_data['monetary_type_name'] === 'Cash') { + elseif (isset($monetary_data['account_name'])) { + if ($monetary_data['account_name'] === 'Cash') { // No distinguishing features of Cash, just // use the shared monetary source $monetary_data['monetary_source_id'] = @@ -525,21 +524,16 @@ class Account extends AppModel { else { // The monetary source needs to be unique // Create a new one dedicated to this entry - $monetary_data['MonetarySource']['monetary_type_id'] = - $this->Ledger->LedgerEntry->MonetarySource->MonetaryType - ->nameToID($monetary_data['monetary_type_name']); - - $monetary_data['MonetarySource']['name'] = - $this->Ledger->LedgerEntry->MonetarySource->MonetaryType - ->nameToID($monetary_data['monetary_type_name']); - // Give it a fancy name based on the check number - $monetary_data['MonetarySource']['name'] = $monetary_data['monetary_type_name']; - if ($monetary_data['monetary_type_name'] === 'Check' || - $monetary_data['monetary_type_name'] === 'Money Order') { + $monetary_data['MonetarySource']['name'] = $monetary_data['account_name']; + if ($monetary_data['account_name'] === 'Check' || + $monetary_data['account_name'] === 'Money Order') { $monetary_data['MonetarySource']['name'] .= ' #' . $monetary_data['MonetarySource']['data1']; } + else { + $monetary_data['MonetarySource']['name'] = $monetary_data['account_name']; + } $monetary_data = array_intersect_key($monetary_data, diff --git a/models/monetary_source.php b/models/monetary_source.php index 230e3b9..32b99fb 100644 --- a/models/monetary_source.php +++ b/models/monetary_source.php @@ -9,7 +9,6 @@ class MonetarySource extends AppModel { ); var $belongsTo = array( - 'MonetaryType', ); var $hasMany = array( diff --git a/models/monetary_type.php b/models/monetary_type.php deleted file mode 100644 index 22241a4..0000000 --- a/models/monetary_type.php +++ /dev/null @@ -1,16 +0,0 @@ - array('numeric'), - 'name' => array('notempty'), - 'tillable' => array('boolean') - ); - - var $hasMany = array( - 'MonetarySource', - ); - -} -?> \ No newline at end of file diff --git a/models/transaction.php b/models/transaction.php index 8e055e3..7c323c8 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['monetary_type_name'] === 'Cash') { + if ($entry['account_name'] === 'Cash') { // No distinguishing features of Cash, just // use the shared monetary source $entry['monetary_source_id'] = @@ -176,47 +176,24 @@ class Transaction extends AppModel { else { // The monetary source needs to be unique // Create a new one dedicated to this entry - $entry['MonetarySource']['monetary_type_id'] = - $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 - if ($entry['monetary_type_name'] === 'Check' || - $entry['monetary_type_name'] === 'Money Order') { + if ($entry['account_name'] === 'Check' || + $entry['account_name'] === 'Money Order') { $entry['MonetarySource']['name'] .= ' #' . $entry['MonetarySource']['data1']; } + else { + $entry['MonetarySource']['name'] = $entry['account_name']; + } } - // 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 $entry['transaction_id'] = $receipt_transaction->id; // Receipt must debit the "money" asset (bank, cash, check, etc)... $entry['debit_ledger_id'] - = $A->currentLedgerID($A->nameToID($account_name)); + = $A->currentLedgerID($A->nameToID($entry['account_name'])); // ...and credit the Receipt ledger $entry['credit_ledger_id'] diff --git a/views/customers/receipt.ctp b/views/customers/receipt.ctp index 9a23de9..0fc710d 100644 --- a/views/customers/receipt.ctp +++ b/views/customers/receipt.ctp @@ -175,14 +175,12 @@ function addPaymentSource(flash) { foreach(array('Cash', 'Check', 'Money Order', 'ACH', /*'Credit Card'*/ 'Concession') AS $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) { $div = '
'; - $div .= ''; diff --git a/views/elements/monetary_sources.ctp b/views/elements/monetary_sources.ctp index 133ec23..ae75f0d 100644 --- a/views/elements/monetary_sources.ctp +++ b/views/elements/monetary_sources.ctp @@ -4,7 +4,6 @@ $cols = array(); $cols['ID'] = array('index' => 'MonetarySource.id', 'formatter' => 'id'); $cols['Name'] = array('index' => 'MonetarySource.name', 'formatter' => 'longname'); -$cols['Type'] = array('index' => 'MonetaryType.name', 'formatter' => 'name'); $cols['Comment'] = array('index' => 'MonetarySource.comment', 'formatter' => 'comment'); // Set up search fields if requested by caller diff --git a/views/monetary_sources/view.ctp b/views/monetary_sources/view.ctp index bfb18fe..371cf1b 100644 --- a/views/monetary_sources/view.ctp +++ b/views/monetary_sources/view.ctp @@ -9,17 +9,14 @@ echo '
' . "\n"; * MonetarySource Detail Main Section */ -$type = $monetarySource['MonetaryType']; $source = $monetarySource['MonetarySource']; $rows = array(array('ID', $source['id']), array('Name', $source['name']), - array('Type', $type['name']), array('Data 1', $source['data1']), array('Data 2', $source['data2']), array('Data 3', $source['data3']), array('Data 4', $source['data4']), - array('Tillable', $type['tillable'] ? 'Yes' : 'No'), array('Comment', $source['comment'])); echo $this->element('table',