More tweaking to all of the grid displays. This was mostly visual, but includes some bug fixes as well (such as a manual filter override in the ledger_entries controller).

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@371 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-23 16:53:33 +00:00
parent 3c22378498
commit 4a94fc3798
15 changed files with 77 additions and 57 deletions

View File

@@ -55,10 +55,11 @@ class Lease extends AppModel {
('all',
array('link' =>
array(// Models
'StatementEntry' => array(),
'StatementEntry',
'SEx' =>
array('class' => 'StatementEntry',
'fields' => array(),
'conditions' => array
('SEx.effective_date = DATE_ADD(StatementEntry.through_date, INTERVAL 1 day)',
'SEx.lease_id = StatementEntry.lease_id',
@@ -75,6 +76,7 @@ class Lease extends AppModel {
),
)
);
//pr(compact('entries'));
return $entries;
}
@@ -111,7 +113,6 @@ class Lease extends AppModel {
return false;
if (count($entries) != 1)
return null;
pr($entries);
return $entries[0]['StatementEntry']['through_date'];
}
@@ -126,76 +127,52 @@ class Lease extends AppModel {
function rentPaidThrough($id) {
$rent_account_id = $this->StatementEntry->Account->rentAccountID();
// First, see if we can find any unpaid entries. Of course,
// the first unpaid entry gives us a very direct indication
// of when the customer is paid up through, which is 1 day
// prior to the effective date of that first unpaid charge.
$rent = $this->StatementEntry->reconciledSet
('CHARGE',
array('fields' =>
array('StatementEntry.*',
'DATE_SUB(StatementEntry.effective_date, INTERVAL 1 DAY) AS paid_through',
),
'conditions' =>
array(array('StatementEntry.lease_id' => $id),
array('StatementEntry.account_id' => $rent_account_id)),
'order' => array('StatementEntry.effective_date'),
),
true);
/* $query = array */
/* ('link' => */
/* array(// Models */
/* 'StatementEntry' => */
/* array('Entry' => */
/* array(), */
/* 'fields' => array('SUM(COALESCE(MoneyStatementEntryR.amount,0)) AS paid'), */
/* ), */
/* ), */
/* // Finally, the Money (Cash/Check/etc) Entry is the one */
/* // which reconciles our ReceiptStatementEntry debit */
/* 'DebitReconciliationStatementEntry' => */
/* array('alias' => 'MoneyStatementEntry', */
/* 'linkalias' => 'MoneyStatementEntryR', */
/* ), */
/* ), */
/* ), */
/* 'fields' => array('StatementEntry.amount', */
/* 'DATE_SUB(StatementEntry.effective_date, INTERVAL 1 DAY) AS paid_through', */
/* ), */
/* 'group' => 'StatementEntry.id HAVING paid <> StatementEntry.amount', */
/* 'conditions' => array(array('StatementEntry.lease_id' => $id), */
/* array('Account.id' => $this->StatementEntry->Ledger->Account->rentAccountID()), */
/* ), */
/* 'order' => array('StatementEntry.effective_date', */
/* ), */
/* ); */
/* $rent = $this->StatementEntry->find('first', $query); */
//pr($rent);
if ($rent['entries'])
return $rent['entries'][0]['StatementEntry']['paid_through'];
// If we don't have any unpaid charges (great!), then the
// customer is paid up through the last day of the last
// charge. So, search for paid charges, which already
// have the paid through date saved as part of the entry.
$rent = $this->StatementEntry->reconciledSet
('CHARGE',
array('conditions' =>
array(array('StatementEntry.lease_id' => $id),
array('StatementEntry.account_id' => $rent_account_id)),
'order' => array('Entry.through_date DESC'),
'order' => array('StatementEntry.through_date DESC'),
),
false);
if ($rent)
return $rent[0]['StatementEntry']['through_date'];
//pr($rent);
/* $query['fields'] = 'Entry.through_date'; */
/* $query['order'] = 'Entry.through_date DESC'; */
/* $query['group'] = 'StatementEntry.id'; */
/* $rent = $this->StatementEntry->find('first', $query); */
/* if ($rent) */
/* return $rent['StatementEntry']['through_date']; */
if ($rent['entries'])
return $rent['entries'][0]['StatementEntry']['through_date'];
// After all that, having found that there are no unpaid
// charges, and in fact, no paid charges either, we cannot
// possibly say when the customer is paid through.
return null;
}