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
This commit is contained in:
abijah
2009-07-08 00:52:33 +00:00
parent 1f95e835f8
commit 5f9b9e15cb

View File

@@ -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