This is the remainder of the previous, invalid, partial checkin.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@419 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-29 23:25:03 +00:00
parent 393c0dbb3f
commit ec8f540107
4 changed files with 207 additions and 132 deletions

View File

@@ -92,87 +92,6 @@ class TendersController extends AppController {
}
/**************************************************************************
**************************************************************************
**************************************************************************
* action: deposit_slip
* - The followup to the action 'deposit'.
* Processes the user input and updates the database
*/
function deposit_slip() {
if (!$this->data) {
$this->Session->setFlash(__('Invalid Action', true));
$this->redirect(array('action'=>'deposit'));
}
pr($this->data);
// Start building data for our deposit
$deposit = array('close_id' => null,
'total' => 0,
'types' => array(),
'Transaction' => array(),
'Entry' => array());
// Go through each type of tender presented to the user
foreach ($this->data['TenderType'] AS $type_id => $type) {
if (!$type['checked'])
continue;
$tenders = $this->Tender->find
('all',
array('contain' => array
('Customer',
'LedgerEntry',
),
'conditions' => array(array('Tender.deposit_transaction_id' => null),
array('Tender.tender_type_id' => $type_id)),
));
// Prepare for both the actual deposit, as well as the deposit slip
$deposit['types'][$type_id]['name'] = $type['name'];
$deposit['types'][$type_id]['entries'] = array();
$deposit['types'][$type_id]['total'] = 0;
foreach ($tenders AS $tender) {
$deposit['Entry'][] =
array('tender_id' => $tender['Tender']['id'],
//'ledger_entry_id' => $tender['LedgerEntry']['id'],
'account_id' => $tender['LedgerEntry']['account_id'],
'amount' => $tender['LedgerEntry']['amount'],
);
$deposit['types'][$type_id]['entries'][] =
array('name' => $tender['Tender']['name'],
'customer' => $tender['Customer']['name'],
'amount' => $tender['LedgerEntry']['amount']);
$deposit['types'][$type_id]['total'] += $tender['LedgerEntry']['amount'];
}
// Add into the grand total
$deposit['total'] += $deposit['types'][$type_id]['total'];
if (!empty($type['close'])) {
// Close the associated ledger
$result = $this->Tender->LedgerEntry->Account->closeCurrentLedger
($type['account_id'], $deposit['close_id']);
if (!$result['error'] && empty($deposit['close_id']))
$deposit['close_id'] = $result['close_id'];
}
}
$result = $this->Tender->DepositTransaction->addDeposit
($deposit, $this->data['Deposit']['Account']['id']);
//pr(compact('deposit', 'result'));
$title = 'Deposit Slip';
$this->set(compact('title', 'deposit'));
$this->render('deposit_slip');
return;
}
/**************************************************************************
**************************************************************************
**************************************************************************