From 03af4e731fe19e10a88e67a0fd8f20df26c95daa Mon Sep 17 00:00:00 2001 From: abijah Date: Sun, 12 Jul 2009 21:00:38 +0000 Subject: [PATCH] Fixed the last bug... I had just forgotten to use ReceiptTransaction for the dates in question. Also, I elminated the collected element, and just added a minor tweak to ledger_entries to make it work. I'll work on added user entered dates & accounts soon (perhaps next). git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@323 97e9348a-65ac-dc4b-aefc-98561f571b83 --- .../controllers/ledger_entries_controller.php | 27 +++++---- site/views/elements/collected.ctp | 58 ------------------- site/views/elements/ledger_entries.ctp | 22 +++++-- 3 files changed, 33 insertions(+), 74 deletions(-) delete mode 100644 site/views/elements/collected.ctp diff --git a/site/controllers/ledger_entries_controller.php b/site/controllers/ledger_entries_controller.php index e1467bf..ef8c603 100644 --- a/site/controllers/ledger_entries_controller.php +++ b/site/controllers/ledger_entries_controller.php @@ -23,7 +23,13 @@ class LedgerEntriesController extends AppController { * - Generate a listing of ledger_entries */ - function collected() { $this->jqGridView('Collected Entries', null, 'collected'); } + function collected($account_id) { + $A = new Account(); + $this->set('collected_account_id', $account_id); + $this->jqGridView('Collected ' . + $this->LedgerEntry->Ledger->Account->name($account_id) . + ' Entries'); + } /************************************************************************** @@ -191,9 +197,8 @@ class LedgerEntriesController extends AppController { $fields = $model->ledgerContextFields2($ledger_id, $account_id, $account_type); - if ($params['action'] === 'collected') { + if (count(array_intersect($params['fields'], array('applied'))) == 1) $fields[] = 'SUM(Reconciliation.amount) AS applied'; - } return $fields; } @@ -217,14 +222,14 @@ class LedgerEntriesController extends AppController { $conditions[] = array('NOT' => array('MoneyAccount.name' => 'Concession')); //$conditions[] = array('DA.name' => 'Check'); //$conditions[] = array('DA.name' => 'Cash'); - //$conditions[] = array('Transaction.stamp >=' => '2009-03-26'); - //$conditions[] = array('Transaction.stamp <' => '2009-04-11'); - $conditions[] = array('Transaction.stamp >=' => '2009-04-11'); - $conditions[] = array('Transaction.stamp <' => '2009-05-09'); - //$conditions[] = array('Transaction.stamp >=' => '2009-05-09'); - //$conditions[] = array('Transaction.stamp <' => '2009-06-11'); - //$conditions[] = array('ReceiptTransaction.stamp >=' => '2009-06-11'); - //$conditions[] = array('ReceiptTransaction.stamp <' => '2009-07-11'); + //$conditions[] = array('ReceiptTransaction.stamp >=' => '2009-03-26'); + //$conditions[] = array('ReceiptTransaction.stamp <' => '2009-04-11'); + //$conditions[] = array('ReceiptTransaction.stamp >=' => '2009-04-11'); + //$conditions[] = array('ReceiptTransaction.stamp <' => '2009-05-09'); + //$conditions[] = array('ReceiptTransaction.stamp >=' => '2009-05-09'); + //$conditions[] = array('ReceiptTransaction.stamp <' => '2009-06-11'); + $conditions[] = array('ReceiptTransaction.stamp >=' => '2009-06-11'); + $conditions[] = array('ReceiptTransaction.stamp <' => '2009-07-11'); } if ($params['action'] === 'ledger') { diff --git a/site/views/elements/collected.ctp b/site/views/elements/collected.ctp deleted file mode 100644 index d7350d1..0000000 --- a/site/views/elements/collected.ctp +++ /dev/null @@ -1,58 +0,0 @@ - 'Transaction.id', 'formatter' => 'id'); -$cols['Entry'] = array('index' => 'LedgerEntry.id', 'formatter' => 'id'); -$cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => 'date'); -$cols['Effective'] = array('index' => 'LedgerEntry.effective_date', 'formatter' => 'date'); -$cols['Through'] = array('index' => 'LedgerEntry.through_date', 'formatter' => 'date'); -//$cols['Account'] = array('index' => 'Account.name', 'formatter' => 'name'); - -/* $cols['RTransaction'] = array('index' => 'ReceiptTransaction.id', 'formatter' => 'id'); */ -/* $cols['REntry'] = array('index' => 'ReceiptLedgerEntry.id', 'formatter' => 'id'); */ -/* $cols['RDate'] = array('index' => 'ReceiptTransaction.stamp', 'formatter' => 'date'); */ -/* $cols['REffective'] = array('index' => 'ReceiptLedgerEntry.effective_date', 'formatter' => 'date'); */ -/* $cols['RThrough'] = array('index' => 'ReceiptLedgerEntry.through_date', 'formatter' => 'date'); */ -/* $cols['RAccount'] = array('index' => 'ReceiptAccount.name', 'formatter' => 'name'); */ -/* $cols['RAmount'] = array('index' => 'ReceiptLedgerEntry.amount', 'formatter' => 'currency'); */ - -/* $cols['MTransaction'] = array('index' => 'MoneyTransaction.id', 'formatter' => 'id'); */ -/* $cols['MEntry'] = array('index' => 'MoneyLedgerEntry.id', 'formatter' => 'id'); */ -/* $cols['MDate'] = array('index' => 'MoneyTransaction.stamp', 'formatter' => 'date'); */ -/* $cols['MEffective'] = array('index' => 'MoneyLedgerEntry.effective_date', 'formatter' => 'date'); */ -/* $cols['MThrough'] = array('index' => 'MoneyLedgerEntry.through_date', 'formatter' => 'date'); */ -/* $cols['MAccount'] = array('index' => 'MoneyAccount.name', 'formatter' => 'name'); */ -/* $cols['MAmount'] = array('index' => 'MoneyLedgerEntry.amount', 'formatter' => 'currency'); */ - -$cols['Paid'] = array('index' => 'ReceiptTransaction.stamp', 'formatter' => 'date'); - -$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname'); -//$cols['Lease'] = array('index' => 'Lease.number', 'formatter' => 'id'); -$cols['Unit'] = array('index' => 'Unit.name', 'formatter' => 'name'); - -//$cols['Source'] = array('index' => 'MonetarySource.name', 'formatter' => 'name'); -//$cols['Comment'] = array('index' => 'LedgerEntry.comment', 'formatter' => 'comment', 'width'=>150); - -$cols['Amount'] = array('index' => 'LedgerEntry.amount', 'formatter' => 'currency'); -/* $cols['RAmount'] = array('index' => 'ReceiptLedgerEntry.amount', 'formatter' => 'currency'); */ -/* $cols['MAmount'] = array('index' => 'MoneyLedgerEntry.amount', 'formatter' => 'currency'); */ -$cols['Applied'] = array('index' => 'applied', 'formatter' => 'currency'); - -$cols['Sub-Total'] = array('index' => 'subtotal-applied', 'formatter' => 'currency', 'sortable' => false); - -// This element is non-standard. -// Let grid know who the controller is -$grid->controller = 'ledger_entries'; - -$collected_account_id = $this->passedArgs[0]; -$collected_not = (isset($this->passedArgs[1]) ? $this->passedArgs[1] : 0); -$grid->customData(compact('collected_account_id', 'collected_not')); - -// Render the grid -$grid -->limit(500) -->columns($cols) -//->sortField('Date') -->render($this, isset($config) ? $config : null); diff --git a/site/views/elements/ledger_entries.ctp b/site/views/elements/ledger_entries.ctp index ededadc..0dd3b03 100644 --- a/site/views/elements/ledger_entries.ctp +++ b/site/views/elements/ledger_entries.ctp @@ -24,7 +24,8 @@ $cols['Amount'] = array('index' => 'LedgerEntry.amount', 'formatter' => $cols['Debit'] = array('index' => 'debit', 'formatter' => 'currency'); $cols['Credit'] = array('index' => 'credit', 'formatter' => 'currency'); -$cols['Applied'] = array('index' => "Reconciliation.amount", 'formatter' => 'currency'); +$cols['Paid'] = array('index' => 'ReceiptTransaction.stamp', 'formatter' => 'date'); +$cols['Applied'] = array('index' => "applied", 'formatter' => 'currency'); $cols['Sub-Total'] = array('index' => 'subtotal-LedgerEntry.amount', 'formatter' => 'currency', 'sortable' => false); @@ -53,12 +54,15 @@ if ($group_by_tx) if ($group_by_tx) $grid->invalidFields(array('Effective', 'Through')); +if (!isset($collected_account_id)) + $grid->invalidFields('Paid'); + if (isset($account_ftype) || isset($ledger_id) || isset($account_id) || isset($ar_account)) $grid->invalidFields(array('Debit Account', 'Credit Account')); else $grid->invalidFields('Account'); -if (isset($no_account) || $group_by_tx) +if (isset($no_account) || $group_by_tx || isset($collected_account_id)) $grid->invalidFields(array('Account', 'Debit Account', 'Credit Account')); if (isset($ledger_id) || isset($account_id) || isset($ar_account)) @@ -74,14 +78,18 @@ if (isset($lease_id) || isset($customer_id)) if (isset($lease_id) || $group_by_tx) $grid->invalidFields(array('Lease', 'Unit')); -if (!isset($reconcile_id)) +if (!isset($reconcile_id) && !isset($collected_account_id)) $grid->invalidFields('Applied'); +if (isset($collected_account_id)) + $cols['Sub-Total']['index'] = 'subtotal-applied'; + if (isset($account_ftype)) $grid->invalidFields('Sub-Total'); -if (!isset($config['rows'])) { + +if (!isset($config['rows']) && !isset($collected_account_id)) { $config['action'] = 'ledger'; $grid->limit(50); } @@ -90,6 +98,10 @@ if (isset($reconcile_id)) { $grid->customData(compact('reconcile_id'))->limit(20); } +if (isset($collected_account_id)) { + $grid->customData(compact('collected_account_id'))->limit(500); +} + // Set up search fields if requested by caller if (isset($searchfields)) $grid->searchFields(array('Customer', 'Unit')); @@ -105,7 +117,7 @@ $grid ->sortField('Date') ->defaultFields(array('Entry', 'Date', 'Amount', 'Credit', 'Debit')) ->render($this, isset($config) ? $config : null, - array('Transaction', 'Entry', 'Date', 'Effective', + array('Transaction', 'Entry', 'Date', 'Effective', 'Paid', 'Account', 'Debit Account', 'Credit Account', 'Customer', 'Unit', 'Comment',