More changes to the ledger_entry view

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@300 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-11 00:34:43 +00:00
parent 42dda55643
commit 0d3403032c
4 changed files with 116 additions and 71 deletions

View File

@@ -343,7 +343,7 @@ class LedgerEntriesController extends AppController {
//pr($reconciled);
// Prepare to render.
$title = "Ledger Entry #{$entry['LedgerEntry']['id']}";
$title = "Double Ledger Entry #{$entry['LedgerEntry']['id']}";
$this->set(compact('entry', 'title', 'reconciled', 'stats'));
}
}

View File

@@ -58,18 +58,29 @@ if (isset($rows) && is_array($rows) && count($rows)) {
$row[$c] = array($col, array('class' => $cell_class));
}
}
// Allow user to specify a list of classes
if (isset($class) && is_array($class))
$class = implode(' ', $class);
// OK, output the table HTML
echo('<TABLE' . (isset($class) ? ' CLASS="'.$class.'"' : '') . '>' . "\n");
if (isset($caption))
echo(' <CAPTION>' . $caption . '</CAPTION>' . "\n");
if (isset($headers) && is_array($headers))
if (isset($headers) && is_array($headers)) {
echo(' <THEAD>' . "\n");
echo $html->tableHeaders($headers) . "\n";
echo(' </THEAD>' . "\n");
}
echo(' <TBODY>' . "\n");
echo $html->tableCells($rows,
$suppress_alternate_rows ? null : array('class' => "oddrow"),
$suppress_alternate_rows ? null : array('class' => "evnrow"),
false, false) . "\n";
echo(' </TBODY>' . "\n");
echo('</TABLE>' . "\n");
}

View File

@@ -2,6 +2,44 @@
echo '<div class="ledger-entry view">' . "\n";
// The two entry ids, debit and credit, are actually individual
// entries in separate accounts (each make up one of the two
// entries required for "double entry"). This, when we provide
// reconcile information, we're really providing reconcile info
// for two independent accounts. The reconciling entries,
// therefore, are those on the opposite side of the ledger in
// each account. For example, assume this "double" entry is
//
// debit: A/R credit: Cash amount: 55
//
// Then, our accounts might look like:
//
// RENT TAX A/R CASH BANK
// ------- ------- ------- ------- -------
// |20 | 20| | | <-- Unrelated
// | | |20 20| | <-- Unrelated
// | | | | |
// |50 | 50| | | <-- Rent paid by this entry
// | |5 5| | | <-- Tax paid by this entry
// | | |55 55| | <-- THIS ENTRY
// | | | | |
// | | | |75 75| <-- Deposit includes this entry
// | | | | |
//
// In this case, we're looking to provide reconcile information
// of A/R for (the credit side of) this entry, and also of Cash
// (for the debit side). Taking the accounts as individual
// entries, instead of the "double entry" representation in the
// database, we're actually providing information on the two
// A/R entries, 50 & 5, which are both debits, i.e. opposite
// entries to the credit of A/R. The cash account entry
// reconciles against the credit of 75. Again, this is the
// opposite entry to the debit of Cash.
//
// Thus, for our debit_ledger_id, we're reconciling against
// credits, and for our credit_ledger_id, against debits.
/**********************************************************************
**********************************************************************
**********************************************************************
@@ -10,10 +48,8 @@ echo '<div class="ledger-entry view">' . "\n";
*/
$transaction = $entry['Transaction'];
$debit_ledger = $entry['DebitLedger'];
$credit_ledger = $entry['CreditLedger'];
$ledgers['debit'] = $entry['DebitLedger'];
$ledgers['credit'] = $entry['CreditLedger'];
$ledgers = array('debit' => $entry['DebitLedger'],
'credit' => $entry['CreditLedger']);
$source = $entry['MonetarySource'];
$customer = $entry['Customer'];
$lease = $entry['Lease'];
@@ -46,27 +82,12 @@ $rows[] = array('Monetary Source', (isset($source['name'])
'action' => 'view',
$source['id']))
: null));
$rows[] = array('Amount', FormatHelper::currency($entry['amount']));
foreach ($ledgers AS $type => $ledger)
$rows[] = array(ucfirst($type), ($html->link($ledger['Account']['name'],
array('controller' => 'accounts',
'action' => 'view',
$ledger['Account']['id']))
. ' ('
. $html->link('#' . $ledger['Account']['id']
. '-' . $ledger['sequence'],
array('controller' => 'ledgers',
'action' => 'view',
$ledger['id']))
. ')'));
//$rows[] = array('Amount', FormatHelper::currency($entry['amount']));
$rows[] = array('Comment', $entry['comment']);
echo $this->element('table',
array('class' => 'item ledger-entry detail',
'caption' => 'Ledger Entry Detail',
'caption' => 'Double Ledger Entry Detail',
'rows' => $rows,
'column_class' => array('field', 'value')));
@@ -78,57 +99,17 @@ echo $this->element('table',
echo '<div class="infobox">' . "\n";
$rows = array();
foreach ($ledgers AS $type => $ledger) {
pr($ledger);
//pr($ledger);
if (!$ledger['Account']['trackable'])
continue;
// The two accounts, debit and credit, are actually individual
// entries in each of those account (each make up one of the two
// entries required for "double entry"). This, when we provide
// reconcile information, we're really providing reconcile info
// for two independent accounts. The reconciling entries,
// therefore, are those on the opposite side of the ledger in
// each account. For example, assume this "double" entry is
//
// debit: A/R credit: Cash amount: 55
//
// Then, our accounts might look like:
//
// RENT TAX A/R CASH BANK
// ------- ------- ------- ------- -------
// |20 | 20| | | <-- Unrelated
// | | |20 20| | <-- Unrelated
// | | | | |
// |50 | 50| | | <-- Rent paid by this entry
// | |5 5| | | <-- Tax paid by this entry
// | | |55 55| | <-- THIS ENTRY
// | | | | |
// | | | |75 75| <-- Deposit includes this entry
// | | | | |
//
// In this case, we're looking to provide reconcile information
// of A/R for (the credit side of) this entry, and also of Cash
// (for the debit side). Taking the accounts as individual
// entries, instead of the "double entry" representation in the
// database, we're actually providing information on the two
// A/R entries, 50 & 5, which are both debits, i.e. opposite
// entries to the credit of A/R. The cash account entry
// reconciles against the credit of 75. Again, this is the
// opposite entry to the debit of Cash.
//
// Thus, for our debit_ledger_id, we're reconciling against
// credits, and for our credit_ledger_id, against debits.
// Since we're looking at items opposite to $type (see above),
// our verbage needs to reflect those entry types.
$verb = ($ledger['Account']['ftype'] == $type) ? 'REDUCTION' : 'INCREASE';
$rows[] = array("Applied $verb {$ledger['Account']['name']}:",
$applied_caption = "Transfers applied to {$ledger['Account']['name']} entry";
$remaining_caption = "{$ledger['Account']['name']} entry unapplied amount";
$rows[] = array($applied_caption,
FormatHelper::currency($stats[$type]['amount_reconciled']));
$rows[] = array("{$debit_ledger['Account']['name']} Amount Remaining:",
$rows[] = array($remaining_caption,
FormatHelper::currency($stats[$type]['amount_remaining']));
}
echo $this->element('table',
@@ -139,6 +120,31 @@ echo $this->element('table',
));
echo '</div>' . "\n";
echo ('<DIV CLASS="ledger-double-entry">' . "\n");
foreach ($ledgers AS $type => $ledger) {
$rows = array();
$rows[] = array('Account', $html->link($ledger['Account']['name'],
array('controller' => 'accounts',
'action' => 'view',
$ledger['Account']['id'])));
$rows[] = array('Ledger', $html->link('#' . $ledger['Account']['id']
. '-' . $ledger['sequence'],
array('controller' => 'ledgers',
'action' => 'view',
$ledger['id'])));
$rows[] = array('Amount', FormatHelper::currency($entry['amount']));
$rows[] = array('Effect', $ledger['Account']['ftype'] == $type ? 'INCREASE' : 'DECREASE');
echo $this->element('table',
array('class' => array('item', $type, 'detail'),
'caption' => ucfirst($type) . ' Ledger Entry',
'rows' => $rows,
'column_class' => array('field', 'value')));
}
echo ('</DIV>' . "\n");
/**********************************************************************
**********************************************************************
@@ -162,8 +168,8 @@ foreach ($ledgers AS $type => $ledger) {
$caption = ('Matching ' . (($type == 'credit') ? 'DEBITS' : 'CREDITS') .
' from Account ' . $ledger['Account']['name']);
//$caption = ('Reconciled Entries ' . ($ledger['Account']['ftype'] == $type ? 'OUT OF' : 'INTO') .
$caption = ('Contribution to entries ' . ($ledger['Account']['ftype'] == $type ? 'OUT OF' : 'INTO') .
' Account ' . $ledger['Account']['name']);
$caption = ('Applied transfers ' . ($ledger['Account']['ftype'] == $type ? 'out of' : 'into') .
' Account: ' . $ledger['Account']['name']);
echo $this->element('ledger_entries', array
(// Element configuration
'account_ftype' => $type,

View File

@@ -78,6 +78,34 @@ table.item.detail td.value { white-space : normal; }
div.detail.supporting { clear : both;
padding-top: 1.5em; }
/* Exception for Ledger Entry, which is split over 3 tables */
.ledger-double-entry { padding-top: 1.0em;
float: left;
clear : left;
width : 60%;
}
.ledger-double-entry table.item.detail {
width : 45%;
/* border: 2px dashed #0f0; */
/* margin-left : 5%; */
/* margin-right : 5%; */
}
.ledger-double-entry table.item.detail.debit {
/* margin-left : 2%; */
float: left;
}
.ledger-double-entry table.item.detail.credit {
/* margin-right : 2%; */
float: right;
}
/* .ledger-double-entry table.debit { clear: */
/************************************************************
************************************************************