Implemented a bank deposit routine, to transfer funds out of the till and into the bank.
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@196 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -12,6 +12,7 @@ class AccountsController extends AppController {
|
||||
array('name' => 'Equity', 'url' => array('controller' => 'accounts', 'action' => 'equity')),
|
||||
array('name' => 'Income', 'url' => array('controller' => 'accounts', 'action' => 'income')),
|
||||
array('name' => 'Expense', 'url' => array('controller' => 'accounts', 'action' => 'expense')),
|
||||
array('name' => 'Bank Deposit', 'url' => array('controller' => 'accounts', 'action' => 'deposit')),
|
||||
);
|
||||
|
||||
|
||||
@@ -189,4 +190,48 @@ class AccountsController extends AppController {
|
||||
$this->set(compact('account', 'title', 'stats'));
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
* action: deposit
|
||||
* - Prepares the books for a bank deposit
|
||||
*/
|
||||
function deposit() {
|
||||
if ($this->data) {
|
||||
pr($this->data);
|
||||
/* $this->autoRender = false; */
|
||||
/* return; */
|
||||
|
||||
$transaction = array();
|
||||
foreach ($this->data['Tillable']['Ledger']['id'] AS $acct_id) {
|
||||
if ($this->data['Tillable']['Ledger'][$acct_id]['amount'] == 0)
|
||||
continue;
|
||||
|
||||
$ids = $this->Account->postLedgerEntry
|
||||
($transaction,
|
||||
null,
|
||||
array('debit_account_id' => $this->data['Deposit']['Account']['id'],
|
||||
'credit_account_id' => $acct_id,
|
||||
'amount' => $this->data['Tillable']['Ledger'][$acct_id]['amount']));
|
||||
$transaction = array_intersect_key($ids, array('transaction_id'=>1));
|
||||
|
||||
$this->Account->closeCurrentLedger($acct_id);
|
||||
}
|
||||
|
||||
|
||||
$this->autoRender = false;
|
||||
return;
|
||||
}
|
||||
|
||||
$tillable_account = $this->Account->relatedAccounts('tillable');
|
||||
$depositable_account = $this->Account->relatedAccounts('depositable');
|
||||
|
||||
foreach ($tillable_account AS &$acct) {
|
||||
$acct['Account']['stats'] = $this->Account->stats($acct['Account']['id']);
|
||||
}
|
||||
|
||||
$this->set(compact('tillable_account', 'depositable_account'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user