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@288 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-09 08:28:34 +00:00
parent 112aa7cf59
commit 7a31f5cbd2
11 changed files with 36 additions and 133 deletions

View File

@@ -871,14 +871,18 @@ INSERT INTO `pmgr_accounts` (`type`, `name`, `tillable`, `depositable`, `chargea
('LIABILITY', 'Customer Credit', 0, 0, 1, 1),
('ASSET', 'Petty Cash', 0, 0, 0, 0),
('ASSET', 'Bank', 0, 1, 0, 0),
('ASSET', 'Cash', 1, 0, 0, 0),
('ASSET', 'Check', 1, 0, 0, 0),
('ASSET', 'Money Order', 1, 0, 0, 0),
('ASSET', 'ACH', 0, 0, 0, 1),
('ASSET', 'Cash', 1, 0, 0, 1),
('ASSET', 'Check', 1, 0, 0, 1),
('ASSET', 'Money Order', 1, 0, 0, 1),
('LIABILITY', 'Security Deposit', 0, 0, 1, 1),
('INCOME', 'Rent', 0, 0, 1, 0),
('INCOME', 'Late Charge', 0, 0, 1, 0),
('EXPENSE', 'Concession', 0, 0, 0, 1),
('EXPENSE', 'Bad Debt', 0, 0, 0, 1);
('EXPENSE', 'Bad Debt', 0, 0, 0, 1),
('EXPENSE', 'Cleaning', 0, 0, 0, 0),
('EXPENSE', 'Maintenance', 0, 0, 0, 0);
UNLOCK TABLES;
@@ -1028,7 +1032,6 @@ CREATE TABLE `pmgr_monetary_sources` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(80) DEFAULT NULL,
monetary_type_id INT(10) UNSIGNED NOT NULL,
-- REVISIT <AP>: 20090605
-- Check Number;
@@ -1054,37 +1057,6 @@ CREATE TABLE `pmgr_monetary_sources` (
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- ----------------------------------------------------------------------
-- ----------------------------------------------------------------------
-- TABLE pmgr_monetary_types
DROP TABLE IF EXISTS `pmgr_monetary_types`;
CREATE TABLE `pmgr_monetary_types` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(80) NOT NULL,
`comment` VARCHAR(255) DEFAULT NULL,
`tillable` TINYINT(1) NOT NULL DEFAULT 1, -- Does manager collect by hand?
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
LOCK TABLES `pmgr_monetary_types` WRITE;
INSERT INTO `pmgr_monetary_types` (`id`, `name`, `tillable`)
VALUES
-- (1, 'Transfer', 0),
(2, 'Cash', 1),
(3, 'Check', 1),
(4, 'Money Order', 1),
(5, 'ACH', 0),
(6, 'Debit Card', 0),
(7, 'Credit Card', 0),
(8, 'Other Tillable', 1),
(9, 'Other Non-Tillable', 0);
UNLOCK TABLES;
-- ######################################################################
-- ######################################################################

View File

@@ -535,41 +535,30 @@ $newdb{'lookup'}{'charge_type'}{'Security Deposit'} =
#################################################################
## MONETARY
$newdb{'lookup'}{'monetary_type'} = {};
$query = "SELECT * FROM pmgr_monetary_types";
$result = query($db_handle, $query);
foreach $row (@$result) {
$newdb{'lookup'}{'monetary_type'}{$row->{'name'}}
= {'id' => $row->{'id'} };
}
$newdb{'lookup'}{'payment_type'} = {};
$newdb{'lookup'}{'payment_type'}{1}
= { 'name' => 'Cash', 'account_name' => 'Cash', 'monetary_type' => $newdb{'lookup'}{'monetary_type'}{'Cash'} };
= { 'name' => 'Cash', 'account_name' => 'Cash' };
$newdb{'lookup'}{'payment_type'}{2}
= { 'name' => 'Check', 'account_name' => 'Check', 'monetary_type' => $newdb{'lookup'}{'monetary_type'}{'Check'} };
= { 'name' => 'Check', 'account_name' => 'Check' };
$newdb{'lookup'}{'payment_type'}{3}
= { 'name' => 'Money Order', 'account_name' => 'Money Order', 'monetary_type' => $newdb{'lookup'}{'monetary_type'}{'Money Order'} };
= { 'name' => 'Money Order', 'account_name' => 'Money Order' };
$newdb{'lookup'}{'payment_type'}{4}
= { 'name' => 'ACH', 'account_name' => 'Bank', 'monetary_type' => $newdb{'lookup'}{'monetary_type'}{'ACH'} };
= { 'name' => 'ACH', 'account_name' => 'Bank' };
$newdb{'lookup'}{'payment_type'}{12}
= { 'name' => 'Concession', 'account_name' => 'Concession', 'monetary_type' => $newdb{'lookup'}{'monetary_type'}{'Other Non-Tillable'} };
= { 'name' => 'Concession', 'account_name' => 'Concession' };
$newdb{'ids'}{'monetary_source'} = {};
$newdb{'ids'}{'monetary_source'}{'internal'} = undef;
addRow('monetary_sources',
{ 'monetary_type_id' => $newdb{'lookup'}{'monetary_type'}{'Cash'}{'id'},
'name' => 'Cash',
{ 'name' => 'Cash',
'comment' => 'Monetary source used for any cash transaction' });
$newdb{'ids'}{'monetary_source'}{'Cash'} =
$newdb{'tables'}{'monetary_sources'}{'autoid'};
addRow('monetary_sources',
{ 'monetary_type_id' => $newdb{'lookup'}{'monetary_type'}{'Other Non-Tillable'}{'id'},
'name' => 'Closing',
{ 'name' => 'Closing',
'comment' => 'Credited at the closing table' });
$newdb{'ids'}{'monetary_source'}{'Closing'} =
$newdb{'tables'}{'monetary_sources'}{'autoid'};
@@ -1224,8 +1213,7 @@ foreach $row (@{query($sdbh, $query)}) {
$data1 = $row->{'CheckNum'};
}
addRow('monetary_sources',
{ 'monetary_type_id' => $newdb{'lookup'}{'payment_type'}{$row->{'PaymentType'}}{'monetary_type'}{'id'},
'name' => $name,
{ 'name' => $name,
'data1' => $data1,
#'comment' => "Receipt:$row->{'ReceiptNum'}; Payment:$row->{'PaymentType'}; Check:$row->{'CheckNum'}",
});
@@ -1503,8 +1491,7 @@ sub fakeTesting {
if (defined $e->{'type'}) {
addRow('monetary_sources',
{ 'monetary_type_id' => $e->{'type'},
'name' => "Money of type " . $e->{'type'},
{ 'name' => "Money of type " . $e->{'type'},
'comment' => "Fake Money For " . $e->{'id'} });
$monetary_source_id = $newdb{'tables'}{'monetary_sources'}{'autoid'};
}

View File

@@ -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',

View File

@@ -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.

View File

@@ -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,

View File

@@ -9,7 +9,6 @@ class MonetarySource extends AppModel {
);
var $belongsTo = array(
'MonetaryType',
);
var $hasMany = array(

View File

@@ -1,16 +0,0 @@
<?php
class MonetaryType extends AppModel {
var $name = 'MonetaryType';
var $validate = array(
'id' => array('numeric'),
'name' => array('notempty'),
'tillable' => array('boolean')
);
var $hasMany = array(
'MonetarySource',
);
}
?>

View File

@@ -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 <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
// 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']

View File

@@ -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>';
$div .= '<INPUT TYPE="radio" NAME="data[LedgerEntry][%{id}][monetary_type_name]"';
$div .= '<INPUT TYPE="radio" NAME="data[LedgerEntry][%{id}][account_name]"';
$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 ' : '') . '/>';

View File

@@ -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

View File

@@ -9,17 +9,14 @@ echo '<div class="monetary-source view">' . "\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',