Snapshot of some partial work done with ledger.ctp. There was only a slight change to just the 'mix' ledger, in order to get it working with the new ledger tables. This checkin leaves the codebase in an inconsistent state.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@70 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-06 07:57:41 +00:00
parent 948ae28616
commit 30b934823c

View File

@@ -201,58 +201,51 @@ if (isset($ledger['receipts'])) {
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);')
);
/* $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'];
}
foreach ($transactions AS $transaction) {
$transaction_date = datefmt($transaction['stamp']);
if (isset($transaction['through_date']))
$transaction_date .= ' - '. datefmt($transaction['through_date']);
$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;
$comment = $transaction['comment'];
foreach ($transaction['Entry'] AS $entry) {
if ($entry['DebitAccount']['name'] === 'A/R') {
$name = $entry['CreditAccount']['name'];
$amount = $entry['amount'];
$class = 'charge';
}
elseif ($entry['CreditAccount']['name'] === 'A/R') {
$name = 'Payment';
$amount = -1 * $entry['amount'];
$class = 'payment';
}
else
continue;
$running_total += $amount;
$rows[] = array($html->link('#'.$transaction['id'],
array('controller' => 'transactions',
'action' => 'view',
$transaction['id'])),
$transaction_date,
$name,
$comment,
currency($amount),
currency($running_total));
$row_class[] = $class;
}
}
echo ('<div class="ledger history mix">' . "\n");