Added customer association to each tender

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@413 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-29 09:33:29 +00:00
parent 2ffe04e3e4
commit b789ed62b7
6 changed files with 37 additions and 15 deletions

View File

@@ -1171,6 +1171,10 @@ CREATE TABLE `pmgr_tenders` (
-- The type of this legal tender -- The type of this legal tender
`tender_type_id` INT(10) UNSIGNED DEFAULT NULL, `tender_type_id` INT(10) UNSIGNED DEFAULT NULL,
-- The customer that provided this tender
-- REVISIT <AP>: 20090728 Do we allow anonymous payments?
`customer_id` INT(10) UNSIGNED NOT NULL,
-- REVISIT <AP>: 20090605 -- REVISIT <AP>: 20090605
-- Check Number; -- Check Number;
-- Routing Number, Account Number; -- Routing Number, Account Number;

View File

@@ -1265,7 +1265,7 @@ foreach $row (@{query($sdbh, $query)}) {
'comment' => "Physical Payment: $row->{'ReceiptNum'}; Type: $row->{'PaymentType'}", 'comment' => "Physical Payment: $row->{'ReceiptNum'}; Type: $row->{'PaymentType'}",
}); });
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'payment_id'} $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'tender_id'}
= $newdb{'tables'}{'tenders'}{'autoid'}; = $newdb{'tables'}{'tenders'}{'autoid'};
@@ -1278,7 +1278,7 @@ foreach $row (@{query($sdbh, $query)}) {
$newdb{'lookup'}{'_closing'}{'credit_entry_id'} = $newdb{'lookup'}{'_closing'}{'credit_entry_id'} =
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_entry_id'}; $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_entry_id'};
$newdb{'lookup'}{'_closing'}{'tender_id'} = $newdb{'lookup'}{'_closing'}{'tender_id'} =
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'payment_id'}; $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'tender_id'};
} }
} }
@@ -1304,6 +1304,7 @@ foreach $row (@{query($sdbh, $query)})
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}} $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}
= { 'receipt_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'receipt_id'}, = { 'receipt_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'receipt_id'},
'tender_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'tender_id'},
# 'effective_date' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'effective_date'}, # 'effective_date' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'effective_date'},
# 'effective_date' => $effective_date; # 'effective_date' => $effective_date;
# 'through_date' => $through_date; # 'through_date' => $through_date;
@@ -1319,10 +1320,13 @@ foreach $row (@{query($sdbh, $query)})
$row->{'ChargeID'} = undef $row->{'ChargeID'} = undef
if $row->{'entry_type'} eq 'CREDIT'; if $row->{'entry_type'} eq 'CREDIT';
# Update the receipt customer_id, now that we have payment info # Update the receipt & tender customer_id, now that we have payment info
$newdb{'tables'}{'transactions'}{'rows'}[ $newdb{'tables'}{'transactions'}{'rows'}[
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'receipt_id'} $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'receipt_id'}
]{'customer_id'} = $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'customer_id'}; ]{'customer_id'} = $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'customer_id'};
$newdb{'tables'}{'tenders'}{'rows'}[
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'tender_id'}
]{'customer_id'} = $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'customer_id'};
# Use the Memo as our comment, if it exists # Use the Memo as our comment, if it exists
my $comment = $row->{'Memo'} || "Payment: $row->{'ReceiptNum'}; Type: $row->{'PaymentType'}"; my $comment = $row->{'Memo'} || "Payment: $row->{'ReceiptNum'}; Type: $row->{'PaymentType'}";

View File

@@ -121,7 +121,8 @@ class TendersController extends AppController {
$tenders = $this->Tender->find $tenders = $this->Tender->find
('all', ('all',
array('contain' => array array('contain' => array
('LedgerEntry', ('Customer',
'LedgerEntry',
), ),
'conditions' => array(array('Tender.deposit_transaction_id' => null), 'conditions' => array(array('Tender.deposit_transaction_id' => null),
@@ -141,8 +142,7 @@ class TendersController extends AppController {
); );
$deposit['types'][$type_id]['entries'][] = $deposit['types'][$type_id]['entries'][] =
array('name' => $tender['Tender']['name'], array('name' => $tender['Tender']['name'],
//'customer' => $tender['Customer']['name'], 'customer' => $tender['Customer']['name'],
'customer' => 'Not Yet',
'amount' => $tender['LedgerEntry']['amount']); 'amount' => $tender['LedgerEntry']['amount']);
$deposit['types'][$type_id]['total'] += $tender['LedgerEntry']['amount']; $deposit['types'][$type_id]['total'] += $tender['LedgerEntry']['amount'];
} }
@@ -208,7 +208,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' => array('TenderType'), ('contain' => array('TenderType', 'Customer', 'LedgerEntry' => array('Transaction')),
)); ));
// REVISIT <AP>: 20090713 // REVISIT <AP>: 20090713

View File

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

View File

@@ -353,6 +353,7 @@ class Transaction extends AppModel {
foreach ($data['Entry'] AS $e_index => &$entry) { foreach ($data['Entry'] AS $e_index => &$entry) {
extract($entry); extract($entry);
$le1['transaction_id'] = $le2['transaction_id'] = $ret['transaction_id']; $le1['transaction_id'] = $le2['transaction_id'] = $ret['transaction_id'];
$le1_tender['customer_id'] = $transaction['customer_id'];
$result = $this->LedgerEntry->DoubleEntry->addDoubleEntry($le1, $le2, $le1_tender); $result = $this->LedgerEntry->DoubleEntry->addDoubleEntry($le1, $le2, $le1_tender);
$ret['entries'][$e_index]['DoubleEntry'] = $result; $ret['entries'][$e_index]['DoubleEntry'] = $result;
if ($result['error']) { if ($result['error']) {
@@ -376,7 +377,7 @@ class Transaction extends AppModel {
!$ret['error']) { !$ret['error']) {
$result = $this->StatementEntry->assignCredits $result = $this->StatementEntry->assignCredits
(array('link' => array('Customer'), (array('link' => array('Customer'),
'conditions' => array('Customer.id' => $customer_id)), 'conditions' => array('Customer.id' => $transaction['customer_id'])),
($transaction['type'] == 'RECEIPT' ($transaction['type'] == 'RECEIPT'
? $ret['transaction_id'] ? $ret['transaction_id']
: null)); : null));

View File

@@ -10,11 +10,20 @@ echo '<div class="tender view">' . "\n";
*/ */
$ttype = $tender['TenderType']; $ttype = $tender['TenderType'];
$customer = $tender['Customer'];
$entry = $tender['LedgerEntry'];
$transaction = $entry['Transaction'];
$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('Received', FormatHelper::date($transaction['stamp']));
$rows[] = array('Customer', $html->link($customer['name'],
array('controller' => 'customers',
'action' => 'view',
$customer['id'])));
$rows[] = array('Amount', FormatHelper::currency($entry['amount']));
$rows[] = array('Item', $tender['name']);
$rows[] = array('Type', $ttype['name']); $rows[] = array('Type', $ttype['name']);
/* $rows[] = array('Type', $html->link($ttype['name'], */ /* $rows[] = array('Type', $html->link($ttype['name'], */
/* array('controller' => 'tender_types', */ /* array('controller' => 'tender_types', */
@@ -25,15 +34,18 @@ for ($i=1; $i<=4; ++$i)
if (!empty($ttype["data{$i}_name"])) if (!empty($ttype["data{$i}_name"]))
$rows[] = array($ttype["data{$i}_name"], $tender["data{$i}"]); $rows[] = array($ttype["data{$i}_name"], $tender["data{$i}"]);
$rows[] = array('Deposit', $html->link('#'.$tender['deposit_transaction_id'], if (!empty($tender['deposit_transaction_id']))
$rows[] = array('Deposit', $html->link('#'.$tender['deposit_transaction_id'],
array('controller' => 'transactions', array('controller' => 'transactions',
'action' => 'view', 'action' => 'view',
$tender['deposit_transaction_id']))); $tender['deposit_transaction_id'])));
if (!empty($tender['nsf_transaction_id'])) if (!empty($tender['nsf_transaction_id']))
$rows[] = array('NSF', $html->link('#'.$tender['nsf_transaction_id'], $rows[] = array('NSF', $html->link('#'.$tender['nsf_transaction_id'],
array('controller' => 'transactions', array('controller' => 'transactions',
'action' => 'view', 'action' => 'view',
$tender['nsf_transaction_id']))); $tender['nsf_transaction_id'])));
$rows[] = array('Comment', $tender['comment']); $rows[] = array('Comment', $tender['comment']);
echo $this->element('table', echo $this->element('table',