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