Another snapshot

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@356 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-20 23:35:11 +00:00
parent bfbf119aca
commit d5bcd9a496
20 changed files with 696 additions and 759 deletions

View File

@@ -57,9 +57,9 @@ class LeasesController extends AppController {
function jqGridDataTables(&$params, &$model) {
$link = $this->jqGridDataCountTables($params, $model);
$link['link']['LedgerEntry'] = array('fields' => array());
$link['link']['LedgerEntry']['Ledger'] = array('fields' => array());
$link['link']['LedgerEntry']['Ledger']['Account'] = array('fields' => array());
$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
@@ -67,10 +67,10 @@ class LeasesController extends AppController {
// 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']['LedgerEntry']['Ledger']['Account']['type'] = 'INNER';
$link['link']['LedgerEntry']['Ledger']['Account']['conditions']
//$link['link']['DoubleEntry']['Ledger']['Account']['type'] = 'INNER';
$link['link']['DoubleEntry']['Ledger']['Account']['conditions']
= array('Account.id' =>
$this->Lease->LedgerEntry->Ledger->Account->accountReceivableAccountID());
$this->Lease->DoubleEntry->Ledger->Account->accountReceivableAccountID());
return $link;
}
@@ -78,9 +78,9 @@ class LeasesController extends AppController {
$db = &$model->getDataSource();
$fields = $db->fields($model, $model->alias);
$fields[] = ("SUM(IF(Account.id IS NULL, 0," .
" IF(LedgerEntry.debit_ledger_id = Account.id," .
" IF(DoubleEntry.debit_ledger_id = Account.id," .
" 1, -1))" .
" * IF(LedgerEntry.amount IS NULL, 0, LedgerEntry.amount))" .
" * IF(DoubleEntry.amount IS NULL, 0, DoubleEntry.amount))" .
" AS 'balance'");
return $fields;
}
@@ -252,10 +252,10 @@ class LeasesController extends AppController {
$receipt_transaction = array_intersect_key($this->data,
array('Transaction'=>1,
'transaction_id'=>1));
foreach ($data['LedgerEntry'] AS $entry) {
foreach ($data['DoubleEntry'] 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->LedgerEntry->Ledger->Account->postLedgerEntry
$ids = $this->DoubleEntry->Ledger->Account->postDoubleEntry
($receipt_transaction,
array_intersect_key($entry, array('MonetarySource'=>1))
+ array_intersect_key($entry, array('account_id'=>1)),
@@ -269,6 +269,14 @@ class LeasesController extends AppController {
if ($ids['error'])
$ret = false;
$db = &$model->getDataSource();
$fields = $db->fields($model, $model->alias);
$fields[] = ("SUM(IF(Account.id IS NULL, 0," .
" IF(LedgerEntry.debit_ledger_id = Account.id," .
" 1, -1))" .
" * IF(LedgerEntry.amount IS NULL, 0, LedgerEntry.amount))" .
" AS 'balance'");
return $fields;
$receipt_transaction = array_intersect_key($ids,
array('transaction_id'=>1,
'split_transaction_id'=>1));
@@ -315,7 +323,7 @@ class LeasesController extends AppController {
array('stats' => $this->Lease->stats($id)));
// Determine the lease security deposit
$deposit = $this->Lease->findSecurityDeposits($lease['Lease']['id']);
$deposit = $this->Lease->securityDeposits($lease['Lease']['id']);
$this->set(compact('deposit'));
$this->set('customer', $lease['Customer']);
$this->set('unit', $lease['Unit']);
@@ -371,7 +379,7 @@ class LeasesController extends AppController {
array('stats' => $this->Lease->stats($id)));
// Determine the lease security deposit
$deposit = $this->Lease->findSecurityDeposits($lease['Lease']['id']);
$deposit = $this->Lease->securityDeposits($lease['Lease']['id']);
if ($deposit['summary']['balance'] > 0)
die("Still have un-utilized security deposit");
@@ -406,7 +414,7 @@ class LeasesController extends AppController {
/* $outstanding_balance = $stats['balance']; */
/* // Determine the lease security deposit */
/* $deposits = $this->Lease->findSecurityDeposits($id); */
/* $deposits = $this->Lease->securityDeposits($id); */
/* $outstanding_deposit = $deposits['summary']['balance']; */
@@ -515,8 +523,8 @@ class LeasesController extends AppController {
$outstanding_balance = $lease['Lease']['stats']['balance'];
// Determine the lease security deposit
$deposits = $this->Lease->findSecurityDeposits($lease['Lease']['id']);
$outstanding_deposit = $deposits['summary']['balance'];
$deposits = $this->Lease->securityDeposits($lease['Lease']['id']);
$outstanding_deposit = $deposits['summary']['Payment']['reconciled'];
// Set up dynamic menu items
if (!isset($lease['Lease']['close_date'])) {