|
|
|
|
@@ -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,
|
|
|
|
|
|