Very, very messy and broken. It does work somewhat, but I can see just what a mess it's going to be to carry it out, so I'm abandoning.
git-svn-id: file:///svn-source/pmgr/branches/reconcile_entry_to_receipt_20090629@187 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -4,8 +4,6 @@ use DBI;
|
||||
use Data::Dumper;
|
||||
use File::Copy;
|
||||
|
||||
my $use_ir = 0;
|
||||
|
||||
# Internally adjust all numbers coming from the database to
|
||||
# be in inches. Not necessary to go to this detail, but the
|
||||
# actual units used is irrelevant, provided everything is to
|
||||
@@ -880,19 +878,6 @@ foreach $row (@{query($sdbh, $query)}) {
|
||||
};
|
||||
|
||||
$credit_ledger_id = $newdb{'lookup'}{'charge_type'}{$row->{'ChargeDescription'}}{'ledger_id'};
|
||||
if ($use_ir) {
|
||||
addRow('ledger_entries',
|
||||
{ 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'},
|
||||
'transaction_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'tx'},
|
||||
'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Invoice'}{'ledger_id'},
|
||||
'credit_ledger_id' => $credit_ledger_id,
|
||||
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'},
|
||||
'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'},
|
||||
'amount' => $row->{'ChargeAmount'},
|
||||
'comment' => "Charge: $row->{'ChargeID'}; Ledger: $row->{'LedgerID'}" });
|
||||
$ledger_entry_id = $newdb{'tables'}{'ledger_entries'}{'autoid'};
|
||||
$credit_ledger_id = $newdb{'lookup'}{'account'}{'Invoice'}{'ledger_id'};
|
||||
}
|
||||
|
||||
addRow('ledger_entries',
|
||||
{ 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'},
|
||||
@@ -907,33 +892,9 @@ foreach $row (@{query($sdbh, $query)}) {
|
||||
$newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'ledger_entry_id'}
|
||||
= $newdb{'tables'}{'ledger_entries'}{'autoid'};
|
||||
|
||||
if ($use_ir) {
|
||||
# Reconcile the invoice account. Since this is from the perspective
|
||||
# of the invoice, the entry crediting the charge is the debit, and
|
||||
# the entry debiting A/R is the credit.
|
||||
addRow('reconciliations',
|
||||
{ 'debit_ledger_entry_id' => $ledger_entry_id,
|
||||
'credit_ledger_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'ledger_entry_id'},
|
||||
'amount' => $row->{'ChargeAmount'},
|
||||
});
|
||||
}
|
||||
|
||||
next unless $row->{'TaxAmount'};
|
||||
|
||||
$credit_ledger_id = $newdb{'lookup'}{'charge_type'}{'Tax'}{'ledger_id'};
|
||||
if ($use_ir) {
|
||||
addRow('ledger_entries',
|
||||
{ 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'},
|
||||
'transaction_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'tx'},
|
||||
'debit_ledger_id' => $newdb{'lookup'}{'account'}{'Invoice'}{'ledger_id'},
|
||||
'credit_ledger_id' => $credit_ledger_id,
|
||||
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'},
|
||||
'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'},
|
||||
'amount' => $row->{'TaxAmount'},
|
||||
'comment' => undef });
|
||||
$ledger_entry_id = $newdb{'tables'}{'ledger_entries'}{'autoid'};
|
||||
$credit_ledger_id = $newdb{'lookup'}{'account'}{'Invoice'}{'ledger_id'};
|
||||
}
|
||||
|
||||
addRow('ledger_entries',
|
||||
{ 'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'},
|
||||
@@ -948,16 +909,6 @@ foreach $row (@{query($sdbh, $query)}) {
|
||||
$newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'tax_entry'}
|
||||
= $newdb{'tables'}{'ledger_entries'}{'autoid'};
|
||||
|
||||
if ($use_ir) {
|
||||
# Reconcile the invoice account. Since this is from the perspective
|
||||
# of the invoice, the entry crediting the charge is the debit, and
|
||||
# the entry debiting A/R is the credit.
|
||||
addRow('reconciliations',
|
||||
{ 'debit_ledger_entry_id' => $ledger_entry_id,
|
||||
'credit_ledger_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'tax_entry'},
|
||||
'amount' => $row->{'TaxAmount'},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1052,22 +1003,6 @@ foreach $row (@{query($sdbh, $query)})
|
||||
$row->{'PaymentID'}}{'account_name'}
|
||||
}{'ledger_id'};
|
||||
|
||||
if ($use_ir) {
|
||||
addRow('ledger_entries',
|
||||
{ 'monetary_source_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{$row->{'PaymentType'}}{'monetary_source_id'},
|
||||
'transaction_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{'tx'},
|
||||
'debit_ledger_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'debit_ledger_id'},
|
||||
'credit_ledger_id' => $newdb{'lookup'}{'account'}{'Receipt'}{'ledger_id'},
|
||||
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'customer_id'},
|
||||
'lease_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'lease_id'},
|
||||
'amount' => $row->{'PaymentAmount'},
|
||||
'comment' => "Receipt: $row->{'ReceiptNum'}; Charge: $row->{'ChargeID'}; Payment: $row->{'PaymentID'}" });
|
||||
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'ledger_entry_id'}
|
||||
= $newdb{'tables'}{'ledger_entries'}{'autoid'};
|
||||
$newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'debit_ledger_id'}
|
||||
= $newdb{'lookup'}{'account'}{'Receipt'}{'ledger_id'};
|
||||
}
|
||||
|
||||
# Sitelink splits one physical payment into multiple "payments" to match each charge
|
||||
# This is kludgy, but for our cases at least, brings those pseudo-payments back into
|
||||
# a single one. It presumes that there is only one PaymentType per receipt.
|
||||
@@ -1106,10 +1041,11 @@ foreach $row (@{query($sdbh, $query)})
|
||||
# Reconcile the A/R account. Since this is from the perspective
|
||||
# of the A/R, charge is the debit, and payment is the credit
|
||||
addRow('reconciliations',
|
||||
{ 'debit_ledger_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'ledger_entry_id'},
|
||||
'credit_ledger_entry_id' => $newdb{'lookup'}{'payment'}{$row->{'PaymentID'}}{'ledger_entry_id'},
|
||||
'amount' => $reconcile_amount,
|
||||
});
|
||||
{ 'type' => 'DEBIT',
|
||||
'ledger_entry_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'ledger_entry_id'},
|
||||
'transaction_id' => $newdb{'lookup'}{'receipt'}{$row->{'ReceiptNum'}}{'tx'},
|
||||
'amount' => $reconcile_amount,
|
||||
});
|
||||
|
||||
# Update the transaction to use the memo from this payment
|
||||
if ($row->{'Memo'}) {
|
||||
@@ -1300,8 +1236,9 @@ sub fakeTesting {
|
||||
|
||||
foreach my $t (@{$e->{'track'}}) {
|
||||
addRow('reconciliations',
|
||||
{ 'debit_ledger_entry_id' => $t->{'debit'},
|
||||
'credit_ledger_entry_id' => $e->{'id'},
|
||||
{ 'type' => 'DEBIT',
|
||||
'ledger_entry_id' => $t->{'debit'},
|
||||
'transaction_id' => $tx->{'id'},
|
||||
'amount' => $t->{'amount'}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user