Additional work on generating ledger information. I've been reading up on accounting basics though, and I feel I'm just not going in the right direction. I'm checking this in, since it works somewhat, and will probably try to head in a different direction.

git-svn-id: file:///svn-source/pmgr/branches/initial_20090526@66 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-04 01:54:15 +00:00
parent e586268dee
commit e1671a9fca
4 changed files with 357 additions and 71 deletions

View File

@@ -4,20 +4,20 @@
<?php
function currency($number) {
if ($number < 0)
return "($ " . number_format(-1*$number, 2) . ")";
else
return "$ " . number_format($number, 2);
function currency($amount) {
return NumberHelper::currency($amount);
}
function datefmt($date) {
$date_fmt = 'm/d/Y';
return ($date
? date_format(date_create($date), $date_fmt)
: null);
return TimeHelper::format($date_fmt, $date);
}
function datetimefmt($date) {
return TimeHelper::nice($date);
}
/**********************************************************************
* Unit Info
*/
@@ -59,8 +59,8 @@ foreach($unit['Lease'] AS $lease) {
datefmt($lease['lease_date']),
datefmt($lease['movein_date']),
datefmt($lease['moveout_date']),
$lease['amount'],
$lease['deposit'],
currency($lease['amount']),
currency($lease['deposit']),
$lease['comment']);
}
@@ -76,49 +76,11 @@ echo $this->element('table',
* Ledger History
*/
foreach($unit['Lease'] AS $lease) {
$headers = array(/*'Charge/Receipt'*/'ID', 'Date', /*'Through',*/ 'Type', 'Comment', 'Amount', 'Total');
$rows = array();
$running_total = 0;
$odd = 0;
foreach($lease['Charge'] AS $charge) {
$amount = $charge['total'];
$running_total += $amount;
$rows[] = array($html->link('#'.$charge['id'],
array('controller' => 'charges',
'action' => 'view',
$charge['id'])),
datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']),
$charge['ChargeType']['name'],
$charge['comment'],
currency($amount),
currency($running_total));
$row_class[] = array('charge', (++$odd % 2) ? 'oddrow' : 'evnrow');
foreach ($charge['Receipt'] AS $receipt) {
$amount = -1 * $receipt['ChargesReceipt']['amount'];
$running_total += $amount;
$rows[] = array($html->link('#'.$receipt['id'],
array('controller' => 'receipts',
'action' => 'view',
$receipt['id'])),
' -- ' . datefmt($receipt['stamp']),
'Payment Applied',
$receipt['comment'],
currency($amount),
currency($running_total));
$row_class[] = array('receipt', ($odd % 2) ? 'oddrow' : 'evnrow');
}
}
echo $this->element('table',
array('class' => 'item ledger list',
'caption' => 'Lease #'.$lease['number'].' (Tenant: '.$lease['Contact'][0]['display_name'].')',
'suppress_alternate_rows' => true,
'headers' => $headers,
'rows' => $rows,
'row_class' => $row_class,
'column_class' => $headers));
$caption = 'Lease #'.$lease['number'].' (Tenant: '.$lease['Contact'][0]['display_name'].')';
echo $this->element('ledger',
array('lease' => $lease,
'caption' => $caption,
'ledger' => array('charges'=>1, 'receipts'=>1, 'match'=>1, 'zmix'=>1)));
}
?>