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

@@ -59,6 +59,10 @@ class AccountsController extends AppController {
}
function gridDataCountTables(&$params, &$model) {
// Our count should NOT include anything extra,
// so we need the virtual function to prevent
// the base class from just calling our
// gridDataTables function
return parent::gridDataTables($params, $model);
}

View File

@@ -56,6 +56,15 @@ class LedgerEntriesController extends AppController {
$this->LedgerEntry->debitCreditFields());
}
function gridDataFilterTablesTable(&$params, &$model, $table) {
$table = $this->gridDataFilterTableName($params, $model, $table);
// Account is already part of our standard table set.
// Ensure we don't add it in again as part of filtering.
if ($table == 'Account')
return null;
return $table;
}
function gridDataOrder(&$params, &$model, $index, $direction) {
/* if ($index === 'balance') */
/* return ($index .' '. $direction); */

View File

@@ -50,7 +50,11 @@ class LedgersController extends AppController {
}
function gridDataCountTables(&$params, &$model) {
return array('contain' => false);
// Our count should NOT include anything extra,
// so we need the virtual function to prevent
// the base class from just calling our
// gridDataTables function.
return parent::gridDataTables($params, $model);
}
function gridDataTables(&$params, &$model) {

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;
}

View File

@@ -270,12 +270,14 @@ OPTION 2
$lquery = $this->reconciledSetQuery($set, $query);
$result = $this->find('all', $lquery);
//pr(compact('lquery', 'result'));
//pr(array('reconciledSet', compact('set', 'lquery', 'result')));
$resultset = array();
foreach ($result AS $i => $entry) {
//pr(compact('entry'));
$entry['StatementEntry'] += $entry[0];
$entry['StatementEntry'] = $entry[0] + $entry['StatementEntry'];
unset($entry[0]);
$entry['StatementEntry']['balance'] =
@@ -293,6 +295,8 @@ OPTION 2
}
}
//pr(compact('resultset'));
//pr(array('StatementEntry::reconciledSet()' => compact('resultset')));
//$resultset['stats'] = $this->stats(null, $query);

View File

@@ -77,9 +77,12 @@ echo $this->element('ledgers', array
echo $this->element('ledger_entries', array
(// Grid configuration
'config' => array
('caption' => ("Current Ledger: " .
('grid_div_id' => 'ledger-ledger-entry-list',
'caption' => ("Current Ledger: " .
"(". $current_ledger['name'] .")"),
'filter' => array('ledger_id' => $current_ledger['id']),
'exclude' => array('Account', 'Amount', 'Cr/Dr', 'Debit', 'Credit'),
'include' => array('Balance', 'Sub-Total'),
)));
@@ -91,9 +94,12 @@ echo $this->element('ledger_entries', array
echo $this->element('ledger_entries', array
(// Grid configuration
'config' => array
('grid_setup' => array('hiddengrid' => true),
('grid_div_id' => 'account-ledger-entry-list',
'grid_setup' => array('hiddengrid' => true),
'caption' => "Entire Ledger",
'filter' => array('account_id' => $account['id']),
'exclude' => array('Account', 'Amount', 'Cr/Dr', 'Debit', 'Credit'),
'include' => array('Balance', 'Sub-Total'),
)));

View File

@@ -56,6 +56,7 @@ echo $this->element('contacts', array
'config' => array
('caption' => 'Customer Contacts',
'filter' => array('Customer.id' => $customer['Customer']['id']),
'include' => array('Type', 'Active'),
)));
@@ -68,6 +69,7 @@ echo $this->element('leases', array
'config' => array
('caption' => 'Lease History',
'filter' => array('Customer.id' => $customer['Customer']['id']),
'exclude' => array('Customer'),
)));
@@ -80,6 +82,7 @@ echo $this->element('statement_entries', array
'config' => array
('caption' => 'Account',
'filter' => array('Customer.id' => $customer['Customer']['id']),
'exclude' => array('Effective', 'Customer'),
)));

View File

@@ -11,9 +11,10 @@ $cols['Cr/Dr'] = array('index' => 'LedgerEntry.crdr', 'formatter' =>
$cols['Tender'] = array('index' => 'Tender.name', 'formatter' => 'name');
$cols['Comment'] = array('index' => 'LedgerEntry.comment', 'formatter' => 'comment', 'width'=>150);
$cols['Amount'] = array('index' => 'LedgerEntry.amount', 'formatter' => 'currency');
$cols['Debit'] = array('index' => 'debit', 'formatter' => 'currency');
$cols['Credit'] = array('index' => 'credit', 'formatter' => 'currency');
$cols['Amount'] = array('index' => 'LedgerEntry.amount', 'formatter' => 'currency');
$cols['Balance'] = array('index' => 'balance', 'formatter' => 'currency');
$cols['Sub-Total'] = array('index' => 'subtotal-balance', 'formatter' => 'currency', 'sortable' => false);
@@ -25,5 +26,5 @@ $grid
->defaultFields(array('Entry', 'Date', 'Amount'))
->searchFields(array('Customer', 'Unit'))
->render($this, isset($config) ? $config : null,
array_diff(array_keys($cols), array('Debit', 'Credit', 'Sub-Total', 'Comment')));
array_diff(array_keys($cols), array('Debit', 'Credit', 'Balance', 'Sub-Total', 'Comment')));

View File

@@ -22,7 +22,7 @@ $cols['Payment'] = array('index' => 'payment', 'formatter' =>
$cols['Last Payment'] = array('index' => 'last_paid', 'formatter' => 'date');
$cols['Applied'] = array('index' => "applied", 'formatter' => 'currency');
$cols['Sub-Total'] = array('index' => 'subtotal-StatementEntry.amount', 'formatter' => 'currency', 'sortable' => false);
$cols['Sub-Total'] = array('index' => 'subtotal-balance', 'formatter' => 'currency', 'sortable' => false);
/* if (!isset($statement_entry_id)) */
@@ -31,8 +31,7 @@ $cols['Sub-Total'] = array('index' => 'subtotal-StatementEntry.amount', 'f
/* $cols['Sub-Total']['index'] = 'subtotal-applied'; */
// REVISIT <AP>: 20090722
// Disallowing these fields until more of the rework is complete
$grid->invalidFields('Sub-Total');
// Disallowing this field until more of the rework is complete
$grid->invalidFields('Applied');
// Include custom data

View File

@@ -86,6 +86,8 @@ echo $this->element('statement_entries', array
'config' => array
('caption' => 'Account',
'filter' => array('lease_id' => $lease['id']),
'include' => array('Through'),
'exclude' => array('Customer', 'Lease', 'Unit'),
)));

View File

@@ -70,6 +70,10 @@ echo $this->element('ledger_entries', array
'config' => array
('caption' => "Ledger Entries",
'filter' => array('ledger_id' => $ledger['id']),
'exclude' => array('Ledger', 'Account', 'Amount', 'Cr/Dr', 'Debit', 'Credit'),
'include' => array('Balance', 'Sub-Total'),
/* 'exclude' => array('Ledger', 'Account', 'Amount', 'Cr/Dr', 'Balance'), */
/* 'include' => array('Debit', 'Credit', 'Sub-Total'), */
)));

View File

@@ -104,6 +104,7 @@ echo $this->element('statement_entries', array
'config' => array
('caption' => 'Entries Applied',
//'filter' => array('statement_entry_id' => $entry['id']),
'exclude' => array('Entry'),
)));

View File

@@ -61,6 +61,7 @@ echo $this->element('ledger_entries', array
'config' => array
('caption' => "Ledger Entries",
'filter' => array('tender_id' => $tender['id']),
'exclude' => array('Tender'),
)));

View File

@@ -73,6 +73,7 @@ echo $this->element('statement_entries', array
(
'caption' => 'Statement Entries',
'filter' => array('transaction_id' => $transaction['id']),
'exclude' => array('Transaction'),
)));
@@ -86,6 +87,7 @@ echo $this->element('ledger_entries', array
(
'caption' => 'Ledger Entries',
'filter' => array('transaction_id' => $transaction['id']),
'exclude' => array('Transaction'),
)));

View File

@@ -67,6 +67,7 @@ echo $this->element('leases', array
'config' => array
('caption' => 'Lease History',
'filter' => array('Unit.id' => $unit['id']),
'exclude' => array('Unit'),
)));
@@ -75,7 +76,7 @@ echo $this->element('leases', array
*/
if (isset($current_lease['id'])) {
echo $this->element('ledger_entries', array
echo $this->element('statement_entries', array
(// Grid configuration
'config' => array
(
@@ -84,6 +85,8 @@ if (isset($current_lease['id'])) {
. $current_lease['Customer']['name']
. ')'),
'filter' => array('Lease.id' => $current_lease['id']),
'include' => array('Through'),
'exclude' => array('Customer', 'Lease', 'Unit'),
)));
}