Making progress. Much still to do, but there are hints of functionality finally returning so I'm snapshotting.
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@360 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -57,31 +57,15 @@ class LeasesController extends AppController {
|
||||
|
||||
function jqGridDataTables(&$params, &$model) {
|
||||
$link = $this->jqGridDataCountTables($params, $model);
|
||||
$link['link']['DoubleEntry'] = array('fields' => array());
|
||||
$link['link']['DoubleEntry']['Ledger'] = array('fields' => array());
|
||||
$link['link']['DoubleEntry']['Ledger']['Account'] = array('fields' => array());
|
||||
// INNER JOIN would be great, as it would ensure we're only looking
|
||||
// at the ledger entries that we truly want. However, this also
|
||||
// removes from the query any leases that do not yet have a ledger
|
||||
// entry in A/R. A solution would be to INNER JOIN these tables,
|
||||
// and LEFT JOIN it to the rest. Grouping of JOINs, however, is
|
||||
// implemented with the 'joins' tag, and is not available through
|
||||
// the Linkable behavior interface.
|
||||
//$link['link']['DoubleEntry']['Ledger']['Account']['type'] = 'INNER';
|
||||
$link['link']['DoubleEntry']['Ledger']['Account']['conditions']
|
||||
= array('Account.id' =>
|
||||
$this->Lease->DoubleEntry->Ledger->Account->accountReceivableAccountID());
|
||||
$link['link']['StatementEntry'] = array('fields' => array());
|
||||
return $link;
|
||||
}
|
||||
|
||||
function jqGridDataFields(&$params, &$model) {
|
||||
$db = &$model->getDataSource();
|
||||
$fields = $db->fields($model, $model->alias);
|
||||
$fields[] = ("SUM(IF(Account.id IS NULL, 0," .
|
||||
" IF(DoubleEntry.debit_ledger_id = Account.id," .
|
||||
" 1, -1))" .
|
||||
" * IF(DoubleEntry.amount IS NULL, 0, DoubleEntry.amount))" .
|
||||
" AS 'balance'");
|
||||
$fields = array_merge($fields,
|
||||
$this->Lease->StatementEntry->chargePaymentFields(true));
|
||||
return $fields;
|
||||
}
|
||||
|
||||
@@ -95,6 +79,9 @@ class LeasesController extends AppController {
|
||||
$conditions[] = 'Lease.close_date IS NOT NULL';
|
||||
}
|
||||
|
||||
if (isset($params['custom']['customer_id']))
|
||||
$conditions[] = array('Lease.customer_id' => $params['custom']['customer_id']);
|
||||
|
||||
return $conditions;
|
||||
}
|
||||
|
||||
@@ -252,10 +239,10 @@ class LeasesController extends AppController {
|
||||
$receipt_transaction = array_intersect_key($this->data,
|
||||
array('Transaction'=>1,
|
||||
'transaction_id'=>1));
|
||||
foreach ($data['DoubleEntry'] AS $entry) {
|
||||
foreach ($data['StatementEntry'] AS $entry) {
|
||||
// Create the receipt entry, and reconcile the credit side
|
||||
// of the double-entry (which should be A/R) as a payment.
|
||||
$ids = $this->DoubleEntry->Ledger->Account->postDoubleEntry
|
||||
$ids = $this->StatementEntry->Ledger->Account->postLedgerEntry
|
||||
($receipt_transaction,
|
||||
array_intersect_key($entry, array('MonetarySource'=>1))
|
||||
+ array_intersect_key($entry, array('account_id'=>1)),
|
||||
|
||||
Reference in New Issue
Block a user