Quick and dirty hack to get double entries to show again.

git-svn-id: file:///svn-source/pmgr/branches/surplus_account_20090815@571 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-08-16 00:45:11 +00:00
parent 26d9b1bc38
commit 4125d7ba16
4 changed files with 38 additions and 19 deletions

View File

@@ -36,6 +36,28 @@ class DoubleEntriesController extends AppController {
'conditions' => array('DoubleEntry.id' => $id),
));
$entry += $this->DoubleEntry->DebitEntry->Transaction->find
('first',
array('contain' => false,
'conditions' => array('id' => $entry['DebitEntry']['transaction_id']),
));
$entry += $this->DoubleEntry->DebitEntry->find
('first',
array('contain' => array('Ledger' => array('Account')),
'conditions' => array('DebitEntry.id' => $entry['DebitEntry']['id']),
));
$entry['DebitLedger'] = $entry['Ledger'];
unset($entry['Ledger']);
$entry += $this->DoubleEntry->CreditEntry->find
('first',
array('contain' => array('Ledger' => array('Account')),
'conditions' => array('CreditEntry.id' => $entry['CreditEntry']['id']),
));
$entry['CreditLedger'] = $entry['Ledger'];
unset($entry['Ledger']);
// Prepare to render.
$title = "Double Ledger Entry #{$entry['DoubleEntry']['id']}";
$this->set(compact('entry', 'title'));

View File

@@ -168,6 +168,9 @@ class LedgerEntriesController extends AppController {
array('fields' => array('id', 'name'),
),
'DebitDoubleEntry' => array('id'),
'CreditDoubleEntry' => array('id'),
'DebitEntry' => array('fields' => array('id', 'crdr')),
'CreditEntry' => array('fields' => array('id', 'crdr')),
),
@@ -194,6 +197,11 @@ class LedgerEntriesController extends AppController {
else
$entry['MatchingEntry'] = $entry['DebitEntry'][0];
if (empty($entry['DebitDoubleEntry']))
$entry['DoubleEntry'] = $entry['CreditDoubleEntry'];
else
$entry['DoubleEntry'] = $entry['DebitDoubleEntry'];
// Prepare to render.
$title = "Ledger Entry #{$entry['LedgerEntry']['id']}";
$this->set(compact('entry', 'title'));

View File

@@ -52,8 +52,6 @@ $ledgers = array('debit' => $entry['DebitLedger'],
'credit' => $entry['CreditLedger']);
$entries = array('debit' => $entry['DebitEntry'],
'credit' => $entry['CreditEntry']);
$customer = $entry['Customer'];
$lease = $entry['Lease'];
$entry = $entry['DoubleEntry'];
$rows = array();
@@ -63,21 +61,7 @@ $rows[] = array('Transaction', $html->link('#'.$transaction['id'],
'action' => 'view',
$transaction['id'])));
$rows[] = array('Timestamp', FormatHelper::datetime($transaction['stamp']));
$rows[] = array('Effective', FormatHelper::date($entry['effective_date']));
//$rows[] = array('Through', FormatHelper::date($entry['through_date']));
$rows[] = array('Customer', (isset($customer['name'])
? $html->link($customer['name'],
array('controller' => 'customers',
'action' => 'view',
$customer['id']))
: null));
$rows[] = array('Lease', (isset($lease['id'])
? $html->link('#'.$lease['id'],
array('controller' => 'leases',
'action' => 'view',
$lease['id']))
: null));
$rows[] = array('Comment', $entry['comment']);
$rows[] = array('Comment', $entry['comment']);
echo $this->element('table',
array('class' => 'item ledger-entry detail',
@@ -132,8 +116,8 @@ foreach ($ledgers AS $type => $ledger) {
array('controller' => 'ledgers',
'action' => 'view',
$ledger['id'])));
$rows[] = array('Amount', FormatHelper::currency($entry['amount']));
$rows[] = array('Effect', $ledger['Account']['ftype'] == $type ? 'INCREASE' : 'DECREASE');
$rows[] = array('Amount', FormatHelper::currency($entries[$type]['amount']));
//$rows[] = array('Effect', $ledger['Account']['ftype'] == $type ? 'INCREASE' : 'DECREASE');
echo $this->element('table',
array('class' => array('item', $type, 'detail'),

View File

@@ -14,6 +14,7 @@ $ledger = $entry['Ledger'];
$account = $ledger['Account'];
$tender = $entry['Tender'];
$matching = $entry['MatchingEntry'];
$double = $entry['DoubleEntry'];
$entry = $entry['LedgerEntry'];
$rows = array();
@@ -43,6 +44,10 @@ $rows[] = array('Cr/Dr', ($entry['crdr'] .
'action' => 'view',
$matching['id'])) .
')'));
$rows[] = array('Double Entry', $html->link('#'.$double['id'],
array('controller' => 'double_entries',
'action' => 'view',
$double['id'])));
$rows[] = array('Comment', $entry['comment']);
echo $this->element('table',