Added lease and ledger_entry controllers/views. Minor bugfixes as well.

git-svn-id: file:///svn-source/pmgr/branches/ledger_transactions_20090605@85 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-06-10 08:53:22 +00:00
parent 4277962e3b
commit f8eb45a0b9
10 changed files with 427 additions and 38 deletions

View File

@@ -5,11 +5,7 @@ class LedgerEntriesController extends AppController {
'group' => 'Entry.id',
'order' => array('Entry.stamp' => 'ASC'));
var $sidemenu_links =
array(array('name' => 'Entries', 'header' => true),
array('name' => 'Cleared', 'url' => array('controller' => 'ledger_entries', 'action' => 'cleared')),
array('name' => 'Unresolved', 'url' => array('controller' => 'ledger_entries', 'action' => 'unresolved')),
);
var $sidemenu_links = array();
/**************************************************************************
@@ -36,22 +32,56 @@ class LedgerEntriesController extends AppController {
$this->redirect(array('controller' => 'accounts', 'action'=>'index'));
}
// Get the LedgerEntry and related fields
$this->LedgerEntry->Behaviors->attach('Containable');
$this->LedgerEntry->contain
(array(// Models
'MonetarySource' => array('MonetaryType'),
'Transaction',
'DebitLedger',
'CreditLedger',
)
);
$entry = $this->LedgerEntry->read(null, $id);
$entry = $this->LedgerEntry->find
('first',
array('contain' => array('MonetarySource.id',
'MonetarySource.MonetaryType.id',
'Transaction.id',
'Transaction.stamp',
'DebitLedger.id',
'DebitLedger.sequence',
'DebitLedger.account_id',
'CreditLedger.id',
'CreditLedger.sequence',
'CreditLedger.account_id',
),
'fields' => array('LedgerEntry.id',
'LedgerEntry.amount',
'LedgerEntry.comment'),
));
$this->LedgerEntry->Behaviors->detach('Containable');
$title = "Entry #{$entry['LedgerEntry']['id']} ({$entry['LedgerEntry']['name']})";
$this->set(compact('entry', 'title'));
// Because 'DebitLedger' and 'CreditLedger' both relate to 'Account',
// CakePHP will not include them in the LedgerEntry->find (or so it
// seems). We'll have to break out each Account separately.
pr($entry);
$this->autoRender = false;
// Get the Account from DebitLedger
$this->LedgerEntry->DebitLedger->Account->Behaviors->attach('Containable');
$account = $this->LedgerEntry->DebitLedger->Account->find
('first',
array('contain' => true,
'fields' => array('Account.id', 'Account.name', 'Account.type'),
'conditions' => array('Account.id' => $entry['DebitLedger']['account_id']),
));
$entry['DebitLedger'] = array_merge($entry['DebitLedger'], $account);
$this->LedgerEntry->DebitLedger->Account->Behaviors->detach('Containable');
// Get the Account from CreditLedger
$this->LedgerEntry->CreditLedger->Account->Behaviors->attach('Containable');
$account = $this->LedgerEntry->CreditLedger->Account->find
('first',
array('contain' => true,
'fields' => array('Account.id', 'Account.name', 'Account.type'),
'conditions' => array('Account.id' => $entry['CreditLedger']['account_id']),
));
$entry['CreditLedger'] = array_merge($entry['CreditLedger'], $account);
$this->LedgerEntry->CreditLedger->Account->Behaviors->detach('Containable');
// Prepare to render.
$title = "Ledger Entry #{$entry['LedgerEntry']['id']}";
$this->set(compact('entry', 'title'));
}
}