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:
@@ -157,7 +157,7 @@ echo $this->element('table',
|
||||
* Ledger History
|
||||
*/
|
||||
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();
|
||||
$row_class = array();
|
||||
@@ -165,32 +165,28 @@ foreach($contact['Lease'] AS $lease) {
|
||||
$odd = 0;
|
||||
foreach($lease['Charge'] AS $charge) {
|
||||
$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'],
|
||||
array('controller' => 'charges',
|
||||
'action' => 'view',
|
||||
$charge['id'])),
|
||||
datefmt($charge['charge_date']) .' - '. datefmt($charge['charge_to_date']),
|
||||
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');
|
||||
|
||||
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',
|
||||
|
||||
Reference in New Issue
Block a user