From 5f9b9e15cbf02dfc0f786ca35d962ae82d64560a Mon Sep 17 00:00:00 2001 From: abijah Date: Wed, 8 Jul 2009 00:52:33 +0000 Subject: [PATCH] Fixed bug with security deposits after I did away with sitelinks use of ledger number some time back git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@254 97e9348a-65ac-dc4b-aefc-98561f571b83 --- scripts/sitelink2pmgr.pl | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/scripts/sitelink2pmgr.pl b/scripts/sitelink2pmgr.pl index 99682e1..b19c120 100644 --- a/scripts/sitelink2pmgr.pl +++ b/scripts/sitelink2pmgr.pl @@ -904,6 +904,15 @@ foreach $row (@{query($sdbh, $query)}) { 'amount' => $row->{'InvoiceAmount'}, } }; + # Charges are the only way we have to figure out security + # deposit requirements for a lease. So, if we encounter + # a security deposit charge, update the lease to reflect. + if ($row->{'ChargeDescription'} eq 'Security Deposit') { + $newdb{'tables'}{'leases'}{'rows'}[ + $newdb{'lookup'}{'ledger'}{$row->{'LedgerID'}}{'lease_id'} + ]{'deposit'} = $row->{'ChargeAmount'}; + } + addRow('transactions', { 'stamp' => datefmt($row->{'ChargeDate'}), 'through_date' => datefmt($row->{'EndDate'}) }); @@ -1539,21 +1548,6 @@ print Dumper \%newdb; buildTables(); -###################################################################### -## Security Deposits - -print(STDERR "Set Lease Security Deposits...\n"); - -$query = "SELECT L.LedgerID, L.UnitID, C.ChargeAmount FROM TenantLedger L INNER JOIN Charges C ON C.LedgerID = L.LedgerID WHERE L.UnitID <> 'POS\$' AND C.ChargeDescription = 'Security Deposit' ORDER BY UnitID"; - -foreach $row (@{query($sdbh, $query)}) { - #my $uid = $newdb{'lookup'}{'unit'}{$row->{'UnitID'}}; - $query = "UPDATE pmgr_leases - SET deposit = $row->{'ChargeAmount'} - WHERE `number` = '$row->{'LedgerID'}'"; - query($db_handle, $query, $row); -} - ###################################################################### ## Contact Display Names @@ -1567,6 +1561,7 @@ $query = " IF(first_name IS NOT NULL, first_name, last_name))"; query($db_handle, $query); + ###################################################################### ## Unit Lease Assignments