Added a much more user friendly way to present the data1-4 labels for each type, now that we have a tender_types table. Still not a perfect solution, but definitely good enough for now. Modified the application to recognize the new tender_types table. There may be other modifications necessary, but this gets the most obvious spot.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@378 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-24 02:07:43 +00:00
parent b408d86a98
commit 1e0b96953e
6 changed files with 46 additions and 14 deletions

View File

@@ -1131,14 +1131,17 @@ CREATE TABLE `pmgr_tender_types` (
-- include credit cards, debit cards, and ACH transfers. -- include credit cards, debit cards, and ACH transfers.
`tillable` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1, `tillable` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,
-- How many data fields are required/used by this type. -- Names of the 4 data fields (or NULL if not used)
-- Not the most robust of solutions, especially since -- Not the most robust of solutions, especially since
-- it requires (or strongly implicates) that all fields -- it requires (or strongly implicates) that all fields
-- be of the same type (ugh). A more complete solution -- be of the same type (ugh). A more complete solution
-- would be for each type to have its own table of data -- would be for each type to have its own table of data
-- and to have that table specified here. However, this -- and to have that table specified here. However, this
-- is MUCH simpler, and works for now. -- is MUCH simpler, and works for now.
`data_fields` SMALLINT UNSIGNED NOT NULL DEFAULT 0, `data1_name` VARCHAR(80) DEFAULT NULL,
`data2_name` VARCHAR(80) DEFAULT NULL,
`data3_name` VARCHAR(80) DEFAULT NULL,
`data4_name` VARCHAR(80) DEFAULT NULL,
-- When we accept legal tender of this form, where does -- When we accept legal tender of this form, where does
-- it go? Each type of legal tender can specify an -- it go? Each type of legal tender can specify an

View File

@@ -543,25 +543,36 @@ foreach my $tender_name ('Cash', 'Check', 'Money Order', 'ACH',
#'Debit Card', 'Credit Card', #'Debit Card', 'Credit Card',
) { ) {
my ($tillable, $fields) = (0, 0); my ($tillable, $fields) = (0, 0);
my ($name1, $name2, $name3, $name4);
$tillable = 1 $tillable = 1
if ($tender_name =~ /^Cash|Check|Money Order$/); if ($tender_name =~ /^Cash|Check|Money Order$/);
$fields = 1 # Check / Money Order Number ($name1) = ('Check Number')
if ($tender_name =~ /^Check|Money Order$/); if ($tender_name eq 'Check');
$fields = 2 # Routing Number, Account Number ($name1) = ('Money Order Number')
if ($tender_name =~ /^ACH$/); if ($tender_name eq 'Money Order');
$fields = 3 # Card Number, Expiration, Billing Zip ($name1, $name2) = ('Routing Number', 'Account Number')
if ($tender_name =~ / Card$/); if ($tender_name eq 'ACH');
($name1, $name2) = ('Debit Card Number', 'Expiration Date')
if ($tender_name eq 'Debit Card');
($name1, $name2, $name3) = ('Debit Card Number', 'Expiration Date', 'Billing Zip Code')
if ($tender_name eq 'Credit Card');
addRow('tender_types', { addRow('tender_types', {
'name' => $tender_name, 'name' => $tender_name,
'account_id' => $newdb{'lookup'}{'account'}{$tender_name}{'account_id'}, 'account_id' => $newdb{'lookup'}{'account'}{$tender_name}{'account_id'},
'tillable' => $tillable, 'tillable' => $tillable,
'data_fields' => $fields, 'data1_name' => $name1,
'data2_name' => $name2,
'data3_name' => $name3,
'data4_name' => $name4,
}); });
$newdb{'lookup'}{'tender_type'}{$tender_name} $newdb{'lookup'}{'tender_type'}{$tender_name}
= { 'tender_type_id' => $newdb{'tables'}{'tender_types'}{'autoid'}, = { 'tender_type_id' => $newdb{'tables'}{'tender_types'}{'autoid'},
'account_id' => $newdb{'lookup'}{'account'}{$tender_name}{'account_id'}, 'account_id' => $newdb{'lookup'}{'account'}{$tender_name}{'account_id'},
@@ -613,6 +624,7 @@ foreach my $account_type (keys(%SITELINK_ACCOUNT_TYPE)) {
$newdb{'lookup'}{'_closing'} $newdb{'lookup'}{'_closing'}
= { 'name' => 'Closing', = { 'name' => 'Closing',
'amount' => 0,
'tender_type_id' => undef, 'tender_type_id' => undef,
'debit_account_id' => $newdb{'lookup'}{'account'}{'Closing'}{'account_id'}, 'debit_account_id' => $newdb{'lookup'}{'account'}{'Closing'}{'account_id'},
'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Closing'}{'ledger_id'}, 'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Closing'}{'ledger_id'},

View File

@@ -84,7 +84,7 @@ class TendersController extends AppController {
// Get the Tender and related fields // Get the Tender and related fields
$tender = $this->Tender->find $tender = $this->Tender->find
('first', array ('first', array
('contain' => false, ('contain' => array('TenderType'),
)); ));
// REVISIT <AP>: 20090713 // REVISIT <AP>: 20090713

View File

@@ -2,6 +2,7 @@
class Tender extends AppModel { class Tender extends AppModel {
var $belongsTo = array( var $belongsTo = array(
'TenderType',
'LedgerEntry', 'LedgerEntry',
'DepositTransaction' => array( 'DepositTransaction' => array(
'className' => 'Transaction', 'className' => 'Transaction',

View File

@@ -0,0 +1,9 @@
<?php
class TenderType extends AppModel {
var $hasMany = array(
'Tender',
);
}
?>

View File

@@ -9,15 +9,22 @@ echo '<div class="tender view">' . "\n";
* Tender Detail Main Section * Tender Detail Main Section
*/ */
$ttype = $tender['TenderType'];
$tender = $tender['Tender']; $tender = $tender['Tender'];
$rows = array(); $rows = array();
$rows[] = array('ID', $tender['id']); $rows[] = array('ID', $tender['id']);
$rows[] = array('Name', $tender['name']); $rows[] = array('Name', $tender['name']);
$rows[] = array('Data 1', $tender['data1']); $rows[] = array('Type', $ttype['name']);
$rows[] = array('Data 2', $tender['data2']); /* $rows[] = array('Type', $html->link($ttype['name'], */
$rows[] = array('Data 3', $tender['data3']); /* array('controller' => 'tender_types', */
$rows[] = array('Data 4', $tender['data4']); /* 'action' => 'view', */
/* $ttype['id']))); */
for ($i=1; $i<=4; ++$i)
if (!empty($ttype["data{$i}_name"]))
$rows[] = array($ttype["data{$i}_name"], $tender["data{$i}"]);
$rows[] = array('Comment', $tender['comment']); $rows[] = array('Comment', $tender['comment']);
echo $this->element('table', echo $this->element('table',