More changes. I just can't seem to come up with a solution that works that I like. The problem now, without invoice/receipt, is that one check cannot cleanly pay for two units.
git-svn-id: file:///svn-source/pmgr/branches/single_AR_20090622@182 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -25,6 +25,14 @@ class LedgerEntriesController extends AppController {
|
||||
* to jqGrid.
|
||||
*/
|
||||
|
||||
function jqGridDataSetup(&$params) {
|
||||
parent::jqGridDataSetup($params);
|
||||
if (isset($params['custom']['ar_account'])) {
|
||||
$params['custom']['account_id'] =
|
||||
$this->LedgerEntry->DebitLedger->Account->accountReceivableAccountID();
|
||||
}
|
||||
}
|
||||
|
||||
function jqGridDataTables(&$params, &$model) {
|
||||
$link =
|
||||
array(// Models
|
||||
@@ -87,6 +95,19 @@ class LedgerEntriesController extends AppController {
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($params['custom']['account_id'])) {
|
||||
$account_id = $params['custom']['account_id'];
|
||||
$link['Ledger'] =
|
||||
array('fields' => array('id', 'sequence'),
|
||||
'conditions' => ("Ledger.id = IF(DebitLedger.account_id = $account_id," .
|
||||
" LedgerEntry.credit_ledger_id," .
|
||||
" LedgerEntry.debit_ledger_id)"),
|
||||
'Account' => array(
|
||||
'fields' => array('id', 'name'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($params['custom']['reconcile_id'])) {
|
||||
$ftype = $params['custom']['account_ftype'];
|
||||
$ftype = $this->LedgerEntry->DebitLedger->Account->fundamentalOpposite($ftype);
|
||||
@@ -102,11 +123,14 @@ class LedgerEntriesController extends AppController {
|
||||
$ledger_id = (isset($params['custom']['ledger_id'])
|
||||
? $params['custom']['ledger_id']
|
||||
: null);
|
||||
$account_id = (isset($params['custom']['account_id'])
|
||||
? $params['custom']['account_id']
|
||||
: null);
|
||||
$account_type = (isset($params['custom']['account_type'])
|
||||
? $params['custom']['account_type']
|
||||
: null);
|
||||
|
||||
return $model->ledgerContextFields2($ledger_id, $account_type);
|
||||
return $model->ledgerContextFields2($ledger_id, $account_id, $account_type);
|
||||
}
|
||||
|
||||
function jqGridDataConditions(&$params, &$model) {
|
||||
@@ -128,6 +152,13 @@ class LedgerEntriesController extends AppController {
|
||||
$conditions[] = array('Reconciliation.'.$ftype.'_ledger_entry_id' => $params['custom']['reconcile_id']);
|
||||
}
|
||||
|
||||
if (isset($params['custom']['account_id'])) {
|
||||
$conditions[] =
|
||||
array('OR' =>
|
||||
array(array('CreditAccount.id' => $params['custom']['account_id']),
|
||||
array('DebitAccount.id' => $params['custom']['account_id'])));
|
||||
}
|
||||
|
||||
if (isset($params['custom']['customer_id'])) {
|
||||
$conditions[] =
|
||||
array('Customer.id' => $params['custom']['customer_id']);
|
||||
@@ -208,6 +239,32 @@ class LedgerEntriesController extends AppController {
|
||||
return $order;
|
||||
}
|
||||
|
||||
function jqGridRecordsPostProcess(&$params, &$model, &$records) {
|
||||
parent::jqGridRecordsPostProcess($params, $model, $records);
|
||||
|
||||
$subtotal = 0;
|
||||
foreach ($records AS &$record) {
|
||||
$amount = (isset($record['LedgerEntry']['balance'])
|
||||
? $record['LedgerEntry']['balance']
|
||||
: $record['LedgerEntry']['amount']);
|
||||
$record['LedgerEntry']['subtotal'] = ($subtotal += $amount);
|
||||
|
||||
continue;
|
||||
// Experiment to minimize columns by putting the monetary source
|
||||
// as the Account, when available
|
||||
if ($record['MonetarySource']['name'])
|
||||
$record['Account']['name'] = $record['MonetarySource']['name'];
|
||||
}
|
||||
}
|
||||
|
||||
function jqGridDataOutputRecordCell(&$params, &$model, &$record, $field, $data) {
|
||||
/* if ($field === 'CreditAccount.name') { */
|
||||
/* $data .= '-OK'; */
|
||||
/* } */
|
||||
|
||||
parent::jqGridDataOutputRecordCell($params, $model, $record, $field, $data);
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
@@ -247,6 +304,7 @@ class LedgerEntriesController extends AppController {
|
||||
|
||||
'conditions' => array('LedgerEntry.id' => $id),
|
||||
));
|
||||
pr($entry);
|
||||
|
||||
// Because 'DebitLedger' and 'CreditLedger' both relate to 'Account',
|
||||
// CakePHP will not include them in the LedgerEntry->find (or so it
|
||||
|
||||
Reference in New Issue
Block a user