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/site@70 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -201,58 +201,51 @@ if (isset($ledger['receipts'])) {
|
|||||||
if (isset($ledger['mix'])) {
|
if (isset($ledger['mix'])) {
|
||||||
$headers = array(/*'Charge/Receipt'*/'ID', 'Date', /*'Through',*/ 'Type', 'Comment', 'Amount', 'Total');
|
$headers = array(/*'Charge/Receipt'*/'ID', 'Date', /*'Through',*/ 'Type', 'Comment', 'Amount', 'Total');
|
||||||
|
|
||||||
$receipts = array();
|
/* $mix = array_merge($lease['Charge'], $receipts); */
|
||||||
foreach ($lease['Charge'] AS $charge) {
|
/* usort($mix, */
|
||||||
foreach($charge['Receipt'] AS $receipt) {
|
/* create_function('$a, $b', */
|
||||||
if (!isset($receipts[$receipt['id']])) {
|
/* '$adate = TimeHelper::toUnix(isset($a["charge_date"]) ? $a["charge_date"] : $a["stamp"]); ' . */
|
||||||
$receipts[$receipt['id']] = $receipt;
|
/* '$bdate = TimeHelper::toUnix(isset($b["charge_date"]) ? $b["charge_date"] : $b["stamp"]); ' . */
|
||||||
$receipts[$receipt['id']]['amount'] = 0;
|
/* 'return strcmp($adate, $bdate);') */
|
||||||
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();
|
$rows = array();
|
||||||
$row_class = array();
|
$row_class = array();
|
||||||
$running_total = 0;
|
$running_total = 0;
|
||||||
|
|
||||||
foreach ($mix AS $row) {
|
foreach ($transactions AS $transaction) {
|
||||||
if (isset($row['charge_date'])) {
|
$transaction_date = datefmt($transaction['stamp']);
|
||||||
$controller = 'charges';
|
if (isset($transaction['through_date']))
|
||||||
$class = 'charge';
|
$transaction_date .= ' - '. datefmt($transaction['through_date']);
|
||||||
$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;
|
$comment = $transaction['comment'];
|
||||||
$rows[] = array($html->link('#'.$row['id'],
|
|
||||||
array('controller' => $controller,
|
foreach ($transaction['Entry'] AS $entry) {
|
||||||
'action' => 'view',
|
if ($entry['DebitAccount']['name'] === 'A/R') {
|
||||||
$row['id'])),
|
$name = $entry['CreditAccount']['name'];
|
||||||
$rowdate,
|
$amount = $entry['amount'];
|
||||||
$name,
|
$class = 'charge';
|
||||||
$row['comment'],
|
}
|
||||||
currency($amount),
|
elseif ($entry['CreditAccount']['name'] === 'A/R') {
|
||||||
currency($running_total));
|
$name = 'Payment';
|
||||||
$row_class[] = $class;
|
$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");
|
echo ('<div class="ledger history mix">' . "\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user