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/site@66 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -169,12 +169,15 @@ class UnitsController extends AppController {
|
|||||||
array('order' => array('charge_date'),
|
array('order' => array('charge_date'),
|
||||||
// Models
|
// Models
|
||||||
'ChargeType',
|
'ChargeType',
|
||||||
'Receipt'
|
'Receipt' => array(// Models
|
||||||
|
'Payment'
|
||||||
|
),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$unit = $this->Unit->read(null, $id);
|
$unit = $this->Unit->read(null, $id);
|
||||||
|
//pr($unit);
|
||||||
|
|
||||||
$outstanding_deposit = 0;
|
$outstanding_deposit = 0;
|
||||||
$outstanding_balance = 0;
|
$outstanding_balance = 0;
|
||||||
@@ -183,6 +186,10 @@ class UnitsController extends AppController {
|
|||||||
$outstanding_balance += $charge['total'];
|
$outstanding_balance += $charge['total'];
|
||||||
foreach ($charge['Receipt'] AS $receipt) {
|
foreach ($charge['Receipt'] AS $receipt) {
|
||||||
$outstanding_balance -= $receipt['ChargesReceipt']['amount'];
|
$outstanding_balance -= $receipt['ChargesReceipt']['amount'];
|
||||||
|
|
||||||
|
/* foreach($receipt['Payment'] AS $payment) */
|
||||||
|
/* $outstanding_balance -= $payment['amount']; */
|
||||||
|
|
||||||
// REVISIT <AP> 20090530:
|
// REVISIT <AP> 20090530:
|
||||||
// Using hardcoded value for security deposit...
|
// Using hardcoded value for security deposit...
|
||||||
// That can't be good!
|
// That can't be good!
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ echo $this->element('table',
|
|||||||
* Ledger History
|
* Ledger History
|
||||||
*/
|
*/
|
||||||
foreach($contact['Lease'] AS $lease) {
|
foreach($contact['Lease'] AS $lease) {
|
||||||
$headers = array(/*'Charge/Receipt'*/'ID', 'Date', /*'Through',*/ 'Type', 'Comment', 'Amount', 'Total');
|
$headers = array(/*'Charge/Receipt'*/'Charge', 'Date', 'Through', 'Type', 'Comment', 'Amount', 'Balance', 'Total');
|
||||||
|
|
||||||
$rows = array();
|
$rows = array();
|
||||||
$row_class = array();
|
$row_class = array();
|
||||||
@@ -165,32 +165,28 @@ foreach($contact['Lease'] AS $lease) {
|
|||||||
$odd = 0;
|
$odd = 0;
|
||||||
foreach($lease['Charge'] AS $charge) {
|
foreach($lease['Charge'] AS $charge) {
|
||||||
$amount = $charge['total'];
|
$amount = $charge['total'];
|
||||||
$running_total += $amount;
|
|
||||||
|
$balance = $amount;
|
||||||
|
foreach ($charge['Receipt'] AS $receipt)
|
||||||
|
$balance -= $receipt['ChargesReceipt']['amount'];
|
||||||
|
|
||||||
|
$running_total += $balance;
|
||||||
|
|
||||||
$rows[] = array($html->link('#'.$charge['id'],
|
$rows[] = array($html->link('#'.$charge['id'],
|
||||||
array('controller' => 'charges',
|
array('controller' => 'charges',
|
||||||
'action' => 'view',
|
'action' => 'view',
|
||||||
$charge['id'])),
|
$charge['id'])),
|
||||||
datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']),
|
datefmt($charge['charge_date']),
|
||||||
|
datefmt($charge['charge_to_date']),
|
||||||
$charge['ChargeType']['name'],
|
$charge['ChargeType']['name'],
|
||||||
$charge['comment'],
|
$charge['comment'],
|
||||||
currency($amount),
|
currency($amount),
|
||||||
|
currency($balance),
|
||||||
|
//currency($amount - $paid));
|
||||||
currency($running_total));
|
currency($running_total));
|
||||||
|
|
||||||
$row_class[] = array('charge', (++$odd % 2) ? 'oddrow' : 'evnrow');
|
$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',
|
echo $this->element('table',
|
||||||
|
|||||||
321
views/elements/ledger.ctp
Normal file
321
views/elements/ledger.ctp
Normal file
@@ -0,0 +1,321 @@
|
|||||||
|
<?php /* -*- mode:PHP -*- */
|
||||||
|
|
||||||
|
/* if (isset($heading)) */
|
||||||
|
/* echo $heading; */
|
||||||
|
/* else */
|
||||||
|
/* echo '<h2>'.__('Payments',true).'</h2>'; */
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="ledger collection">
|
||||||
|
<!-- <span class="title">$caption</span> -->
|
||||||
|
|
||||||
|
<?php
|
||||||
|
; // Alignment purposes only
|
||||||
|
|
||||||
|
// Charges Only
|
||||||
|
// Payments Only
|
||||||
|
// Mixture of both (by date)
|
||||||
|
// Match both (payments match charges)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Charges Only
|
||||||
|
*/
|
||||||
|
if (isset($ledger['charges'])) {
|
||||||
|
$headers = array('Charge', 'Date', 'Through', 'Type', 'Comment', 'Amount', 'Balance', 'Total');
|
||||||
|
|
||||||
|
$rows = array();
|
||||||
|
$row_class = array();
|
||||||
|
$running_total = 0;
|
||||||
|
foreach($lease['Charge'] AS $charge) {
|
||||||
|
$amount = $charge['total'];
|
||||||
|
|
||||||
|
$balance = $amount;
|
||||||
|
foreach ($charge['Receipt'] AS $receipt)
|
||||||
|
$balance -= $receipt['ChargesReceipt']['amount'];
|
||||||
|
|
||||||
|
$running_total += $balance;
|
||||||
|
|
||||||
|
$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($balance),
|
||||||
|
//currency($amount - $paid));
|
||||||
|
currency($running_total));
|
||||||
|
|
||||||
|
$row_class[] = 'charge';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo ('<div class="ledger history charges">' . "\n");
|
||||||
|
echo $this->element('table',
|
||||||
|
array('class' => 'item ledger list',
|
||||||
|
'caption' => $caption,
|
||||||
|
'headers' => $headers,
|
||||||
|
'rows' => $rows,
|
||||||
|
'row_class' => $row_class,
|
||||||
|
'column_class' => $headers));
|
||||||
|
echo ('</div>' . "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Receipts Only
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (isset($ledger['receipts'])) {
|
||||||
|
$headers = array('Receipt', 'Date', 'Comment', 'Amount', 'Balance', 'Total');
|
||||||
|
|
||||||
|
$receipts = array();
|
||||||
|
foreach ($lease['Charge'] AS $charge) {
|
||||||
|
foreach($charge['Receipt'] AS $receipt) {
|
||||||
|
if (!isset($receipts[$receipt['id']])) {
|
||||||
|
$receipts[$receipt['id']] = $receipt;
|
||||||
|
$receipts[$receipt['id']]['amount'] = 0;
|
||||||
|
$receipts[$receipt['id']]['charge'] = 0;
|
||||||
|
foreach($receipt['Payment'] AS $payment)
|
||||||
|
$receipts[$receipt['id']]['amount'] += $payment['amount'];
|
||||||
|
unset($receipts[$receipt['id']]['ChargesReceipt']);
|
||||||
|
unset($receipts[$receipt['id']]['Payment']);
|
||||||
|
}
|
||||||
|
$receipts[$receipt['id']]['charge'] += $receipt['ChargesReceipt']['amount'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
usort($receipts,
|
||||||
|
create_function('$a, $b',
|
||||||
|
'$adate = TimeHelper::toUnix(isset($a["charge_date"]) ? $a["charge_date"] : $a["stamp"]); ' .
|
||||||
|
'$bdate = TimeHelper::toUnix(isset($b["charge_date"]) ? $b["charge_date"] : $b["stamp"]); ' .
|
||||||
|
'return strcmp($adate, $bdate);')
|
||||||
|
);
|
||||||
|
|
||||||
|
$rows = array();
|
||||||
|
$row_class = array();
|
||||||
|
$running_total = 0;
|
||||||
|
|
||||||
|
foreach ($receipts AS $receipt) {
|
||||||
|
$amount = $receipt['amount'];
|
||||||
|
$balance = $amount - $receipt['charge'];
|
||||||
|
$running_total += $balance;
|
||||||
|
|
||||||
|
$rows[] = array($html->link('#'.$receipt['id'],
|
||||||
|
array('controller' => 'receipts',
|
||||||
|
'action' => 'view',
|
||||||
|
$receipt['id'])),
|
||||||
|
datefmt($receipt['stamp']),
|
||||||
|
$receipt['comment'],
|
||||||
|
currency($amount),
|
||||||
|
currency($balance),
|
||||||
|
currency($running_total));
|
||||||
|
|
||||||
|
$row_class[] = 'receipt';
|
||||||
|
}
|
||||||
|
|
||||||
|
echo ('<div class="ledger history receipts">' . "\n");
|
||||||
|
echo $this->element('table',
|
||||||
|
array('class' => 'item ledger list',
|
||||||
|
'caption' => $caption,
|
||||||
|
'headers' => $headers,
|
||||||
|
'rows' => $rows,
|
||||||
|
'row_class' => $row_class,
|
||||||
|
'column_class' => $headers));
|
||||||
|
echo ('</div>' . "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* $headers = array('Receipt', 'Date', 'Comment', 'Amount', 'Balance', 'Total'); */
|
||||||
|
|
||||||
|
/* $rows = array(); */
|
||||||
|
/* $row_class = array(); */
|
||||||
|
/* $running_total = 0; */
|
||||||
|
/* $odd = 0; */
|
||||||
|
/* foreach($lease['Receipt'] AS $charge) { */
|
||||||
|
/* $amount = $charge['total']; */
|
||||||
|
|
||||||
|
/* $balance = $amount; */
|
||||||
|
/* foreach ($charge['Receipt'] AS $receipt) */
|
||||||
|
/* $balance -= $receipt['ChargesReceipt']['amount']; */
|
||||||
|
|
||||||
|
/* $running_total += $balance; */
|
||||||
|
|
||||||
|
|
||||||
|
/* $charge_amount = 0; */
|
||||||
|
/* $payment_amount = 0; */
|
||||||
|
/* foreach($receipt['Charge'] AS $charge) */
|
||||||
|
/* $charge_amount += $charge['ChargesReceipt']['amount']; */
|
||||||
|
/* foreach($receipt['Payment'] AS $payment) */
|
||||||
|
/* $payment_amount += $payment['amount']; */
|
||||||
|
|
||||||
|
/* 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']), */
|
||||||
|
/* $receipt['comment'], */
|
||||||
|
/* currency($amount), */
|
||||||
|
/* currency($running_total)); */
|
||||||
|
/* $row_class[] = array('receipt', ($odd % 2) ? 'oddrow' : 'evnrow'); */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
/* $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($balance), */
|
||||||
|
/* //currency($amount - $paid)); */
|
||||||
|
/* currency($running_total)); */
|
||||||
|
|
||||||
|
/* $row_class[] = array('charge', (++$odd % 2) ? 'oddrow' : 'evnrow'); */
|
||||||
|
/* } */
|
||||||
|
|
||||||
|
/* echo ('<div class="ledger history charges">' . "\n"); */
|
||||||
|
/* echo $this->element('table', */
|
||||||
|
/* array('class' => 'item ledger list', */
|
||||||
|
/* 'caption' => $caption */
|
||||||
|
/* 'suppress_alternate_rows' => true, */
|
||||||
|
/* 'headers' => $headers, */
|
||||||
|
/* 'rows' => $rows, */
|
||||||
|
/* 'row_class' => $row_class, */
|
||||||
|
/* 'column_class' => $headers)); */
|
||||||
|
/* echo ('</div>' . "\n"); */
|
||||||
|
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Mixture
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (isset($ledger['mix'])) {
|
||||||
|
$headers = array(/*'Charge/Receipt'*/'ID', 'Date', /*'Through',*/ 'Type', 'Comment', 'Amount', 'Total');
|
||||||
|
|
||||||
|
$receipts = array();
|
||||||
|
foreach ($lease['Charge'] AS $charge) {
|
||||||
|
foreach($charge['Receipt'] AS $receipt) {
|
||||||
|
if (!isset($receipts[$receipt['id']])) {
|
||||||
|
$receipts[$receipt['id']] = $receipt;
|
||||||
|
$receipts[$receipt['id']]['amount'] = 0;
|
||||||
|
unset($receipts[$receipt['id']]['ChargesReceipt']);
|
||||||
|
unset($receipts[$receipt['id']]['Payment']);
|
||||||
|
}
|
||||||
|
$receipts[$receipt['id']]['amount'] += $receipt['ChargesReceipt']['amount'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$mix = array_merge($lease['Charge'], $receipts);
|
||||||
|
usort($mix,
|
||||||
|
create_function('$a, $b',
|
||||||
|
'$adate = TimeHelper::toUnix(isset($a["charge_date"]) ? $a["charge_date"] : $a["stamp"]); ' .
|
||||||
|
'$bdate = TimeHelper::toUnix(isset($b["charge_date"]) ? $b["charge_date"] : $b["stamp"]); ' .
|
||||||
|
'return strcmp($adate, $bdate);')
|
||||||
|
);
|
||||||
|
|
||||||
|
$rows = array();
|
||||||
|
$row_class = array();
|
||||||
|
$running_total = 0;
|
||||||
|
|
||||||
|
foreach ($mix AS $row) {
|
||||||
|
if (isset($row['charge_date'])) {
|
||||||
|
$controller = 'charges';
|
||||||
|
$class = 'charge';
|
||||||
|
$rowdate = datefmt($row['charge_date']) .' - '. datefmt($row['charge_to_date']);
|
||||||
|
$name = $row['ChargeType']['name'];
|
||||||
|
$amount = $row['total'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$controller = 'receipts';
|
||||||
|
$class = 'receipt';
|
||||||
|
$rowdate = ' -- ' . datefmt($row['stamp']);
|
||||||
|
$name = 'Payment Applied';
|
||||||
|
$amount = -1 * $row['amount'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$running_total += $amount;
|
||||||
|
$rows[] = array($html->link('#'.$row['id'],
|
||||||
|
array('controller' => $controller,
|
||||||
|
'action' => 'view',
|
||||||
|
$row['id'])),
|
||||||
|
$rowdate,
|
||||||
|
$name,
|
||||||
|
$row['comment'],
|
||||||
|
currency($amount),
|
||||||
|
currency($running_total));
|
||||||
|
$row_class[] = $class;
|
||||||
|
}
|
||||||
|
|
||||||
|
echo ('<div class="ledger history mix">' . "\n");
|
||||||
|
echo $this->element('table',
|
||||||
|
array('class' => 'item ledger list',
|
||||||
|
'caption' => $caption,
|
||||||
|
//'suppress_alternate_rows' => true,
|
||||||
|
'headers' => $headers,
|
||||||
|
'rows' => $rows,
|
||||||
|
'row_class' => $row_class,
|
||||||
|
'column_class' => $headers));
|
||||||
|
echo ('</div>' . "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* Match
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (isset($ledger['match'])) {
|
||||||
|
$headers = array(/*'Charge/Receipt'*/'ID', 'Date', /*'Through',*/ 'Type', 'Comment', 'Amount', 'Total');
|
||||||
|
|
||||||
|
$rows = array();
|
||||||
|
$row_class = 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 ('<div class="ledger history match">' . "\n");
|
||||||
|
echo $this->element('table',
|
||||||
|
array('class' => 'item ledger list',
|
||||||
|
'caption' => $caption,
|
||||||
|
'suppress_alternate_rows' => true,
|
||||||
|
'headers' => $headers,
|
||||||
|
'rows' => $rows,
|
||||||
|
'row_class' => $row_class,
|
||||||
|
'column_class' => $headers));
|
||||||
|
echo ('</div>' . "\n");
|
||||||
|
}
|
||||||
@@ -4,20 +4,20 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function currency($number) {
|
function currency($amount) {
|
||||||
if ($number < 0)
|
return NumberHelper::currency($amount);
|
||||||
return "($ " . number_format(-1*$number, 2) . ")";
|
|
||||||
else
|
|
||||||
return "$ " . number_format($number, 2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function datefmt($date) {
|
function datefmt($date) {
|
||||||
$date_fmt = 'm/d/Y';
|
$date_fmt = 'm/d/Y';
|
||||||
return ($date
|
return TimeHelper::format($date_fmt, $date);
|
||||||
? date_format(date_create($date), $date_fmt)
|
|
||||||
: null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function datetimefmt($date) {
|
||||||
|
return TimeHelper::nice($date);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* Unit Info
|
* Unit Info
|
||||||
*/
|
*/
|
||||||
@@ -59,8 +59,8 @@ foreach($unit['Lease'] AS $lease) {
|
|||||||
datefmt($lease['lease_date']),
|
datefmt($lease['lease_date']),
|
||||||
datefmt($lease['movein_date']),
|
datefmt($lease['movein_date']),
|
||||||
datefmt($lease['moveout_date']),
|
datefmt($lease['moveout_date']),
|
||||||
$lease['amount'],
|
currency($lease['amount']),
|
||||||
$lease['deposit'],
|
currency($lease['deposit']),
|
||||||
$lease['comment']);
|
$lease['comment']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,49 +76,11 @@ echo $this->element('table',
|
|||||||
* Ledger History
|
* Ledger History
|
||||||
*/
|
*/
|
||||||
foreach($unit['Lease'] AS $lease) {
|
foreach($unit['Lease'] AS $lease) {
|
||||||
$headers = array(/*'Charge/Receipt'*/'ID', 'Date', /*'Through',*/ 'Type', 'Comment', 'Amount', 'Total');
|
$caption = 'Lease #'.$lease['number'].' (Tenant: '.$lease['Contact'][0]['display_name'].')';
|
||||||
|
echo $this->element('ledger',
|
||||||
$rows = array();
|
array('lease' => $lease,
|
||||||
$running_total = 0;
|
'caption' => $caption,
|
||||||
$odd = 0;
|
'ledger' => array('charges'=>1, 'receipts'=>1, 'match'=>1, 'zmix'=>1)));
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user