Modified tenders to use a tender_type_id, not only for the ability to dynamically add types later, but primarily so that a type could be associated with an account, instead of hardcoding it in the application. With this, I changed several of the account field names, but they shouldn't be in too heavy use in the application.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@376 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -510,7 +510,6 @@ foreach $row (@$result) {
|
||||
|
||||
$newdb{'lookup'}{'account'}{$row->{'name'}}
|
||||
= {'account_id' => $row->{'id'},
|
||||
'tillable' => $row->{'tillable'},
|
||||
'ledger_id' => $newdb{'tables'}{'ledgers'}{'autoid'} };
|
||||
|
||||
if ((!defined $newdb{'tables'}{'accounts'}{'autoid'}) ||
|
||||
@@ -534,21 +533,91 @@ $newdb{'lookup'}{'charge_type'}{'Security Deposit'} =
|
||||
$newdb{'lookup'}{'account'}{'Security Deposit'};
|
||||
|
||||
|
||||
#################################################################
|
||||
## MONETARY TYPES
|
||||
|
||||
$newdb{'lookup'}{'tender_type'} = {};
|
||||
|
||||
foreach my $tender_name ('Cash', 'Check', 'Money Order', 'ACH',
|
||||
#'Debit Card', 'Credit Card',
|
||||
) {
|
||||
my ($tillable, $fields) = (0, 0);
|
||||
|
||||
$tillable = 1
|
||||
if ($tender_name =~ /^Cash|Check|Money Order$/);
|
||||
|
||||
$fields = 1 # Check / Money Order Number
|
||||
if ($tender_name =~ /^Check|Money Order$/);
|
||||
|
||||
$fields = 2 # Routing Number, Account Number
|
||||
if ($tender_name =~ /^ACH$/);
|
||||
|
||||
$fields = 3 # Card Number, Expiration, Billing Zip
|
||||
if ($tender_name =~ / Card$/);
|
||||
|
||||
addRow('tender_types', {
|
||||
'name' => $tender_name,
|
||||
'account_id' => $newdb{'lookup'}{'account'}{$tender_name}{'account_id'},
|
||||
'tillable' => $tillable,
|
||||
'data_fields' => $fields,
|
||||
});
|
||||
$newdb{'lookup'}{'tender_type'}{$tender_name}
|
||||
= { 'tender_type_id' => $newdb{'tables'}{'tender_types'}{'autoid'},
|
||||
'account_id' => $newdb{'lookup'}{'account'}{$tender_name}{'account_id'},
|
||||
'ledger_id' => $newdb{'lookup'}{'account'}{$tender_name}{'ledger_id'},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#################################################################
|
||||
## MONETARY
|
||||
|
||||
$newdb{'lookup'}{'payment_type'} = {};
|
||||
$newdb{'lookup'}{'payment_type'}{1}
|
||||
= { 'name' => 'Cash', 'account_name' => 'Cash' };
|
||||
$newdb{'lookup'}{'payment_type'}{2}
|
||||
= { 'name' => 'Check', 'account_name' => 'Check' };
|
||||
$newdb{'lookup'}{'payment_type'}{3}
|
||||
= { 'name' => 'Money Order', 'account_name' => 'Money Order' };
|
||||
$newdb{'lookup'}{'payment_type'}{4}
|
||||
= { 'name' => 'ACH', 'account_name' => 'Bank' };
|
||||
$newdb{'lookup'}{'payment_type'}{12}
|
||||
= { 'name' => 'Concession', 'account_name' => 'Concession' };
|
||||
|
||||
# SITELINK PAYMENT TYPE CODES
|
||||
my %SITELINK_ACCOUNT_TYPE =
|
||||
( 1 => 'Cash',
|
||||
2 => 'Check',
|
||||
3 => 'Money Order',
|
||||
4 => 'ACH',
|
||||
12 => 'Concession',
|
||||
);
|
||||
|
||||
foreach my $account_type (keys(%SITELINK_ACCOUNT_TYPE)) {
|
||||
my $payment_name = $SITELINK_ACCOUNT_TYPE{$account_type};
|
||||
my ($ttid, $aid, $lid);
|
||||
|
||||
if (defined $newdb{'lookup'}{'tender_type'}{$payment_name}) {
|
||||
($ttid, $aid, $lid) = ( $newdb{'lookup'}{'tender_type'}{$payment_name}{'tender_type_id'},
|
||||
$newdb{'lookup'}{'tender_type'}{$payment_name}{'account_id'},
|
||||
$newdb{'lookup'}{'tender_type'}{$payment_name}{'ledger_id'} );
|
||||
}
|
||||
else {
|
||||
($ttid, $aid, $lid) = ( undef,
|
||||
$newdb{'lookup'}{'account'}{$payment_name}{'account_id'},
|
||||
$newdb{'lookup'}{'account'}{$payment_name}{'ledger_id'} );
|
||||
}
|
||||
|
||||
$newdb{'lookup'}{'payment_type'}{$account_type}
|
||||
= { 'name' => $payment_name,
|
||||
'tender_type_id' => $ttid,
|
||||
'account_id' => $aid,
|
||||
'ledger_id' => $lid,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#################################################################
|
||||
## SPECIAL CASE FOR CLOSING
|
||||
|
||||
$newdb{'lookup'}{'_closing'}
|
||||
= { 'name' => 'Closing',
|
||||
'tender_type_id' => undef,
|
||||
'debit_account_id' => $newdb{'lookup'}{'account'}{'Closing'}{'account_id'},
|
||||
'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Closing'}{'ledger_id'},
|
||||
'credit_account_id' => $newdb{'lookup'}{'account'}{'A/R'}{'account_id'},
|
||||
'credit_ledger_id' => $newdb{'lookup'}{'account'}{'A/R'}{'ledger_id'},
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1083,19 +1152,25 @@ foreach $row (@{query($sdbh, $query)}) {
|
||||
|
||||
if ($row->{'ReceiptDate'} =~ m%3/25/2009%) {
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'name'}
|
||||
= 'Closing';
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'account_name'}
|
||||
= 'Bank';
|
||||
= $newdb{'lookup'}{'_closing'}{'name'};
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'tender_type_id'}
|
||||
= $newdb{'lookup'}{'_closing'}{'tender_type_id'};
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_account_id'}
|
||||
= $newdb{'lookup'}{'_closing'}{'debit_account_id'};
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_ledger_id'}
|
||||
= $newdb{'lookup'}{'_closing'}{'debit_ledger_id'};
|
||||
}
|
||||
else {
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'name'}
|
||||
= $newdb{'lookup'}{'payment_type'}{$row->{'PaymentType'}}{'name'};
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'type'}
|
||||
= $newdb{'lookup'}{'payment_type'}{$row->{'PaymentType'}}{'account_name'};
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'account_name'}
|
||||
= $newdb{'lookup'}{'payment_type'}{$row->{'PaymentType'}}{'account_name'};
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'tender_type_id'}
|
||||
= $newdb{'lookup'}{'payment_type'}{$row->{'PaymentType'}}{'tender_type_id'};
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_account_id'}
|
||||
= $newdb{'lookup'}{'payment_type'}{$row->{'PaymentType'}}{'account_id'};
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_ledger_id'}
|
||||
= $newdb{'lookup'}{'payment_type'}{$row->{'PaymentType'}}{'ledger_id'};
|
||||
|
||||
if ($newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'name'} eq 'Check') {
|
||||
if ($SITELINK_ACCOUNT_TYPE{$row->{'PaymentType'}} == 'Check') {
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'name'}
|
||||
= 'Check #' . $row->{'CheckNum'};
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'data1'}
|
||||
@@ -1103,10 +1178,6 @@ foreach $row (@{query($sdbh, $query)}) {
|
||||
}
|
||||
}
|
||||
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'type'} = undef
|
||||
if ($newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'type'}
|
||||
== 'Concession');
|
||||
|
||||
addRow('transactions', {
|
||||
'type' => 'RECEIPT',
|
||||
'stamp' => $stamp,
|
||||
@@ -1120,14 +1191,7 @@ foreach $row (@{query($sdbh, $query)}) {
|
||||
= $newdb{'tables'}{'transactions'}{'autoid'};
|
||||
|
||||
# Receipt must debit the "money" asset (bank, cash, check, etc)...
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_account_id'}
|
||||
= $newdb{'lookup'}{'account'}{
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'account_name'}
|
||||
}{'account_id'};
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_ledger_id'}
|
||||
= $newdb{'lookup'}{'account'}{
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'account_name'}
|
||||
}{'ledger_id'};
|
||||
# (This was set above, based on whether part of closing or not)
|
||||
|
||||
# ...and credit the A/R ledger
|
||||
$newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'credit_account_id'}
|
||||
@@ -1167,7 +1231,7 @@ foreach $row (@{query($sdbh, $query)}) {
|
||||
addRow('tenders', {
|
||||
'ledger_entry_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'debit_entry_id'},
|
||||
'name' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'name'},
|
||||
'type' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'type'},
|
||||
'tender_type_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'tender_type_id'},
|
||||
'data1' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'data1'},
|
||||
'comment' => "Physical Payment: $row->{'ReceiptNum'}; Type: $row->{'PaymentType'}",
|
||||
});
|
||||
@@ -1410,4 +1474,3 @@ $query = "UPDATE pmgr_transactions T, pmgr_ledger_entries E
|
||||
WHERE E.transaction_id = T.id AND E.account_id = T.account_id";
|
||||
query($db_handle, $query);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user