Significant changes to work with the new account/ledger structure. Removed much of the auto-generated model association code. Added helper functions into the models to perform model related work, such as model 'stats' (a bad name for a function to return a summary of pertinent financial information from a given model instance). There is a ton of cleanup to do, but first I want to get it all captured.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605/site@81 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-10 02:41:23 +00:00
parent 3dcd83229b
commit ffd1b64580
41 changed files with 1441 additions and 916 deletions

View File

@@ -0,0 +1,69 @@
<?php /* -*- mode:PHP -*- */
if (isset($heading))
echo $heading;
elseif (!isset($caption))
echo '<h2>'.__('Ledger Entries',true).'</h2>';
$headers = array('Transaction', 'Entry', 'Date', 'Comment', 'Debit', 'Credit', 'Total');
$column_class = array();
foreach (array_intersect($headers, array('Transaction', 'Entry')) AS $k => $v) {
$column_class[$k] = 'id';
}
foreach (array_intersect($headers, array('Debit', 'Credit', 'Total')) AS $k => $v) {
$column_class[$k] = 'currency';
}
foreach (array_intersect($headers, array('Comment')) AS $k => $v) {
$column_class[$k] = 'slack';
}
$rows = array();
$running_total = 0;
foreach($ledger_entries AS $entry) {
$credit = $debit = null;
$running_total += $entry[0]['balance'];
if (isset($entry[0]['debit']))
$debit = $entry[0]['debit'];
if (isset($entry[0]['credit']))
$credit = $entry[0]['credit'];
// local references to linked tables
$transaction = $entry['Transaction'];
// Now that we've extracted top level 'LedgerEntry' data
// move our variable to the meat of 'LedgerEntry' for clarity
if (isset($entry['LedgerEntry']))
$entry = $entry['LedgerEntry'];
$rows[] = array(isset($transaction['id'])
? $html->link('#'.$transaction['id'],
array('controller' => 'transactions',
'action' => 'view',
$transaction['id']))
: null,
isset($entry['id'])
? $html->link('#'.$entry['id'],
array('controller' => 'ledger_entries',
'action' => 'view',
$entry['id']))
: null,
FormatHelper::date($transaction['stamp']),
FormatHelper::comment(array($transaction['comment'], $entry['comment'])),
FormatHelper::currency($debit),
FormatHelper::currency($credit),
FormatHelper::currency($running_total)
);
}
echo $this->element('table',
array('class' => 'item ledger-entries list',
'caption' => isset($caption) ? $caption : null,
'headers' => $headers,
'rows' => $rows,
'column_class' => $column_class));
?>