Got rid of the massive variable dump to stdout, and so moved all of the STDERR prints back to STDIN. Also hooked up root_transaction_id, although it's not being used yet (and may never be).
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@275 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -1,3 +1,3 @@
|
|||||||
@echo off
|
@echo off
|
||||||
%~dp0\scripts\sitelink2pmgr.pl %~dp0\db\schema.sql %~dp0db\vss.mdb %* > NUL
|
%~dp0\scripts\sitelink2pmgr.pl %~dp0\db\schema.sql %~dp0db\vss.mdb %*
|
||||||
echo Done!
|
echo Done!
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ $database = shift if @ARGV;
|
|||||||
$user = shift if @ARGV;
|
$user = shift if @ARGV;
|
||||||
$password = shift if @ARGV;
|
$password = shift if @ARGV;
|
||||||
|
|
||||||
print STDERR "Connecting to $database as $user\n";
|
print "Connecting to $database as $user\n";
|
||||||
my $db_handle = DBI->connect("DBI:mysql:database=$database;host=$hostname",
|
my $db_handle = DBI->connect("DBI:mysql:database=$database;host=$hostname",
|
||||||
$user, $password,
|
$user, $password,
|
||||||
{'PrintError' => 1,
|
{'PrintError' => 1,
|
||||||
@@ -178,14 +178,15 @@ sub executeSchema {
|
|||||||
## buildTables
|
## buildTables
|
||||||
|
|
||||||
sub buildTables {
|
sub buildTables {
|
||||||
foreach my $table (values %{$newdb{'tables'}}) {
|
foreach my $table_name (sort keys %{$newdb{'tables'}}) {
|
||||||
|
my $table = $newdb{'tables'}{$table_name};
|
||||||
my $count = 0;
|
my $count = 0;
|
||||||
foreach (@{$table->{'rows'}}) {
|
foreach (@{$table->{'rows'}}) {
|
||||||
next unless defined $_;
|
next unless defined $_;
|
||||||
++$count;
|
++$count;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf(STDERR "%-30s : %d rows\n", $table->{'name'}, $count);
|
printf("%-30s : %d rows\n", $table->{'name'}, $count);
|
||||||
|
|
||||||
foreach (@{$table->{'rows'}}) {
|
foreach (@{$table->{'rows'}}) {
|
||||||
next unless defined $_;
|
next unless defined $_;
|
||||||
@@ -977,6 +978,7 @@ foreach $row (@{query($sdbh, $query)}) {
|
|||||||
'through_date' => $through_date,
|
'through_date' => $through_date,
|
||||||
'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'},
|
'monetary_source_id' => $newdb{'ids'}{'monetary_source'}{'internal'},
|
||||||
'transaction_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'tx'},
|
'transaction_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'tx'},
|
||||||
|
'root_transaction_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'charge_tx'},
|
||||||
'debit_ledger_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'debit_ledger_id'},
|
'debit_ledger_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'debit_ledger_id'},
|
||||||
'credit_ledger_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'credit_ledger_id'},
|
'credit_ledger_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'credit_ledger_id'},
|
||||||
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'customer_id'},
|
'customer_id' => $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'customer_id'},
|
||||||
@@ -1332,7 +1334,7 @@ foreach $row (@{query($sdbh, $query)})
|
|||||||
|
|
||||||
# Figure out how much of the charge can be reconciled
|
# Figure out how much of the charge can be reconciled
|
||||||
my $reconcile_amount = $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'amount'};
|
my $reconcile_amount = $newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}{'invoice'}{'amount'};
|
||||||
#print STDERR Dumper($newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}); exit;
|
#print Dumper($newdb{'lookup'}{'charge'}{$row->{'ChargeID'}}); exit;
|
||||||
$reconcile_amount = $row->{'PaymentAmount'} if $row->{'PaymentAmount'} <= $reconcile_amount;
|
$reconcile_amount = $row->{'PaymentAmount'} if $row->{'PaymentAmount'} <= $reconcile_amount;
|
||||||
|
|
||||||
# Reconcile the A/R account. Our two entries look like:
|
# Reconcile the A/R account. Our two entries look like:
|
||||||
@@ -1599,7 +1601,7 @@ sub fakeTesting {
|
|||||||
#fakeTesting();
|
#fakeTesting();
|
||||||
|
|
||||||
$Data::Dumper::Sortkeys = 1;
|
$Data::Dumper::Sortkeys = 1;
|
||||||
print Dumper \%newdb;
|
# print Dumper \%newdb;
|
||||||
# exit;
|
# exit;
|
||||||
|
|
||||||
buildTables();
|
buildTables();
|
||||||
@@ -1608,7 +1610,7 @@ buildTables();
|
|||||||
######################################################################
|
######################################################################
|
||||||
## Contact Display Names
|
## Contact Display Names
|
||||||
|
|
||||||
print(STDERR "Set Contact Display Names...\n");
|
print("Set Contact Display Names...\n");
|
||||||
|
|
||||||
$query =
|
$query =
|
||||||
"UPDATE pmgr_contacts".
|
"UPDATE pmgr_contacts".
|
||||||
@@ -1622,7 +1624,7 @@ query($db_handle, $query);
|
|||||||
######################################################################
|
######################################################################
|
||||||
## Unit Lease Assignments
|
## Unit Lease Assignments
|
||||||
|
|
||||||
print(STDERR "Set Current Leases...\n");
|
print("Set Current Leases...\n");
|
||||||
|
|
||||||
$query = "UPDATE pmgr_units U, pmgr_leases L
|
$query = "UPDATE pmgr_units U, pmgr_leases L
|
||||||
SET U.`current_lease_id` = L.id
|
SET U.`current_lease_id` = L.id
|
||||||
|
|||||||
Reference in New Issue
Block a user