A working version of the collected report for accounts. There is still some error checking to do, since we don't want this report for just any account. Also, we may wish to do away with the form to prevent accidental submittal. Finally, it would be nice to do away with the button, and automatically update on date changes.
git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@324 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -146,77 +146,26 @@ class AccountsController extends AppController {
|
|||||||
* - Displays the items actually collected for the period
|
* - Displays the items actually collected for the period
|
||||||
* e.g. How much was collected in rent from 4/1/09 - 5/1/09
|
* e.g. How much was collected in rent from 4/1/09 - 5/1/09
|
||||||
*/
|
*/
|
||||||
function collected($id) {
|
function collected($id = null) {
|
||||||
//if ($this->data) {
|
if (!$id) {
|
||||||
//pr($this->data);
|
$this->Session->setFlash(__('Invalid Item.', true));
|
||||||
//}
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
|
||||||
/* $tillable_account = $this->Account->relatedAccounts('tillable'); */
|
$payment_accounts = $this->Account->paymentAccounts();
|
||||||
/* $depositable_account = $this->Account->relatedAccounts('depositable'); */
|
$default_accounts = array_diff_key($payment_accounts,
|
||||||
|
array($this->Account->concessionAccountID() => 1));
|
||||||
|
$this->set(compact('payment_accounts', 'default_accounts'));
|
||||||
|
|
||||||
$ledger_entries =
|
$this->Account->recursive = -1;
|
||||||
$this->Account->Ledger->LedgerEntry->find
|
$account = $this->Account->read(null, $id);
|
||||||
('all',
|
$account = $account['Account'];
|
||||||
array('link' => array
|
|
||||||
('Ledger' =>
|
|
||||||
array('fields' => array('sequence'),
|
|
||||||
|
|
||||||
'Account' =>
|
$title = ($account['name'] . ': Collected Report');
|
||||||
array('fields' => array('id', 'name')),
|
$this->set(compact('account', 'title'));
|
||||||
),
|
|
||||||
|
|
||||||
'MonetarySource' =>
|
|
||||||
array('fields' => array('name')),
|
|
||||||
|
|
||||||
'Customer' =>
|
|
||||||
array('fields' => array('name')),
|
|
||||||
|
|
||||||
'Transaction' =>
|
|
||||||
array('fields' => array('stamp')),
|
|
||||||
|
|
||||||
// Income / Receipt flow
|
|
||||||
// debit: Receipt credit: A/R <-- this entry
|
|
||||||
// debit: A/R credit: Income <-- CRLE, below
|
|
||||||
//
|
|
||||||
// We're searching for the Receipt<->A/R entries,
|
|
||||||
// which are credits on the A/R account. Find the
|
|
||||||
// reconciling A/R entries (except for unassigned
|
|
||||||
// pre-payments, all A/R credits should have one).
|
|
||||||
'CreditReconciliationLedgerEntry' =>
|
|
||||||
array('alias' => 'RLedgerEntry',
|
|
||||||
'fields' => true,
|
|
||||||
|
|
||||||
'Transaction' =>
|
|
||||||
array('alias' => 'RTransaction',
|
|
||||||
'fields' => array('stamp')),
|
|
||||||
|
|
||||||
// Debit should be A/R; Credit is Account of interest
|
|
||||||
'CreditLedger' =>
|
|
||||||
array('alias' => 'RLedger',
|
|
||||||
'fields' => true,
|
|
||||||
|
|
||||||
'Account' =>
|
|
||||||
array('alias' => 'RAccount',
|
|
||||||
'fields' => true,
|
|
||||||
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
'fields' => array('LedgerEntry.*', 'Reconciliation.amount'),
|
|
||||||
'conditions' => array(array('RAccount.id' => $id),
|
|
||||||
//array('Account.tillable' => 1),
|
|
||||||
),
|
|
||||||
));
|
|
||||||
|
|
||||||
pr(compact('ledger_entries'));
|
|
||||||
|
|
||||||
$title = 'Collected Whatever';
|
|
||||||
$this->set(compact('title', 'ledger_entries'));
|
|
||||||
//$this->render('/empty');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -337,8 +286,7 @@ class AccountsController extends AppController {
|
|||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'New Ledger', 'url' => array('action' => 'newledger', $id));
|
array('name' => 'New Ledger', 'url' => array('action' => 'newledger', $id));
|
||||||
$this->sidemenu_links[] =
|
$this->sidemenu_links[] =
|
||||||
array('name' => 'Collected', 'url' => array('controller' => 'ledger_entries',
|
array('name' => 'Collected', 'url' => array('action' => 'collected', $id));
|
||||||
'action' => 'collected', $id));
|
|
||||||
|
|
||||||
// Prepare to render
|
// Prepare to render
|
||||||
$title = 'Account: ' . $account['Account']['name'];
|
$title = 'Account: ' . $account['Account']['name'];
|
||||||
|
|||||||
@@ -16,22 +16,6 @@ class LedgerEntriesController extends AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
**************************************************************************
|
|
||||||
* action: index / etc
|
|
||||||
* - Generate a listing of ledger_entries
|
|
||||||
*/
|
|
||||||
|
|
||||||
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');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
**************************************************************************
|
**************************************************************************
|
||||||
@@ -214,22 +198,27 @@ class LedgerEntriesController extends AppController {
|
|||||||
$conditions = parent::jqGridDataConditions($params, $model);
|
$conditions = parent::jqGridDataConditions($params, $model);
|
||||||
|
|
||||||
if ($params['action'] === 'collected') {
|
if ($params['action'] === 'collected') {
|
||||||
$conditions[] = array('Account.id' => $params['custom']['collected_account_id']);
|
extract($params['custom']);
|
||||||
//$conditions[] = array('DebitAccount.tillable' => 1);
|
|
||||||
//$conditions[] = array('ReceiptLedgerEntry.amount != LedgerEntry.amount');
|
if (isset($collected_account_id))
|
||||||
//$conditions[] = array('Reconciliation.amount < ReceiptLedgerEntry.amount');
|
$conditions[] = array('Account.id' => $params['custom']['collected_account_id']);
|
||||||
$conditions[] = array('MoneyAccount.payable' => 1);
|
else
|
||||||
$conditions[] = array('NOT' => array('MoneyAccount.name' => 'Concession'));
|
die("INTERNAL ERROR: COLLECTED ACCOUNT ID NOT SET");
|
||||||
//$conditions[] = array('DA.name' => 'Check');
|
|
||||||
//$conditions[] = array('DA.name' => 'Cash');
|
if (isset($collected_from_date))
|
||||||
//$conditions[] = array('ReceiptTransaction.stamp >=' => '2009-03-26');
|
$conditions[]
|
||||||
//$conditions[] = array('ReceiptTransaction.stamp <' => '2009-04-11');
|
= array('ReceiptTransaction.stamp >=' =>
|
||||||
//$conditions[] = array('ReceiptTransaction.stamp >=' => '2009-04-11');
|
$this->LedgerEntry->Transaction->dateFormatBeforeSave($collected_from_date));
|
||||||
//$conditions[] = array('ReceiptTransaction.stamp <' => '2009-05-09');
|
|
||||||
//$conditions[] = array('ReceiptTransaction.stamp >=' => '2009-05-09');
|
if (isset($collected_through_date))
|
||||||
//$conditions[] = array('ReceiptTransaction.stamp <' => '2009-06-11');
|
$conditions[]
|
||||||
$conditions[] = array('ReceiptTransaction.stamp >=' => '2009-06-11');
|
= array('ReceiptTransaction.stamp <=' =>
|
||||||
$conditions[] = array('ReceiptTransaction.stamp <' => '2009-07-11');
|
$this->LedgerEntry->Transaction->dateFormatBeforeSave($collected_through_date . ' 23:59:59'));
|
||||||
|
|
||||||
|
if (isset($collected_payment_accounts))
|
||||||
|
$conditions[] = array('MoneyAccount.id' => $collected_payment_accounts);
|
||||||
|
else
|
||||||
|
$conditions[] = array('MoneyAccount.payable' => 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($params['action'] === 'ledger') {
|
if ($params['action'] === 'ledger') {
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ class Account extends AppModel {
|
|||||||
function cashAccountID() { return $this->nameToID('Cash'); }
|
function cashAccountID() { return $this->nameToID('Cash'); }
|
||||||
function checkAccountID() { return $this->nameToID('Check'); }
|
function checkAccountID() { return $this->nameToID('Check'); }
|
||||||
function moneyOrderAccountID() { return $this->nameToID('Money Order'); }
|
function moneyOrderAccountID() { return $this->nameToID('Money Order'); }
|
||||||
|
function concessionAccountID() { return $this->nameToID('Concession'); }
|
||||||
function pettyCashAccountID() { return $this->nameToID('Petty Cash'); }
|
function pettyCashAccountID() { return $this->nameToID('Petty Cash'); }
|
||||||
function invoiceAccountID() { return $this->nameToID('Invoice'); }
|
function invoiceAccountID() { return $this->nameToID('Invoice'); }
|
||||||
function receiptAccountID() { return $this->nameToID('Receipt'); }
|
function receiptAccountID() { return $this->nameToID('Receipt'); }
|
||||||
|
|||||||
145
views/accounts/collected.ctp
Normal file
145
views/accounts/collected.ctp
Normal file
@@ -0,0 +1,145 @@
|
|||||||
|
<?php /* -*- mode:PHP -*- */
|
||||||
|
|
||||||
|
echo '<div class="account collected">' . "\n";
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
**********************************************************************
|
||||||
|
**********************************************************************
|
||||||
|
**********************************************************************
|
||||||
|
* Javascript
|
||||||
|
*/
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<script type="text/javascript"><!--
|
||||||
|
|
||||||
|
// Reset the form
|
||||||
|
function resetForm() {
|
||||||
|
/* $('#payment-entry-id').val(1); */
|
||||||
|
/* $('#payments').html(''); */
|
||||||
|
|
||||||
|
/* $("#receipt-customer-id").html("INTERNAL ERROR"); */
|
||||||
|
/* $("#receipt-customer-name").html("INTERNAL ERROR"); */
|
||||||
|
/* $("#receipt-balance").html("INTERNAL ERROR"); */
|
||||||
|
/* $("#receipt-charges-caption").html("Outstanding Charges"); */
|
||||||
|
|
||||||
|
/* datepickerBOM(null, 'TxFromDate'); */
|
||||||
|
/* datepickerNow('TxThroughDate', false); */
|
||||||
|
|
||||||
|
/* updateEntriesGrid(); */
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateEntriesGrid() {
|
||||||
|
var cust = new Array();
|
||||||
|
|
||||||
|
var account_ids = new Array();
|
||||||
|
$("INPUT[type='checkbox']:checked").each(function(i) {
|
||||||
|
account_ids.push($(this).val());
|
||||||
|
});
|
||||||
|
|
||||||
|
cust['collected_account_id'] = <?php echo $account['id']; ?>;
|
||||||
|
cust['collected_from_date'] = $('#TxFromDate').val();
|
||||||
|
cust['collected_through_date'] = $('#TxThroughDate').val();
|
||||||
|
cust['collected_payment_accounts'] = account_ids;
|
||||||
|
|
||||||
|
$('#collected-entries-jqGrid').clearGridData();
|
||||||
|
$('#collected-entries-jqGrid').setPostDataItem('custom', serialize(cust));
|
||||||
|
$('#collected-entries-jqGrid')
|
||||||
|
.setGridParam({ page: 1 })
|
||||||
|
.trigger("reloadGrid");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
--></script>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
; // align
|
||||||
|
//echo '<DIV ID="dialog">' . "\n";
|
||||||
|
|
||||||
|
echo $form->create(null, array('id' => 'receipt-form',
|
||||||
|
//'onsubmit' => 'updateEntriesGrid(); return false',
|
||||||
|
'url' => array('controller' => 'transactions',
|
||||||
|
'action' => 'postReceipt')));
|
||||||
|
|
||||||
|
echo $form->input("id",
|
||||||
|
array('id' => 'account-id',
|
||||||
|
'type' => 'hidden',
|
||||||
|
'value' => 0));
|
||||||
|
|
||||||
|
echo $this->element('form_table',
|
||||||
|
array('class' => "item account collected entry",
|
||||||
|
//'with_name_after' => ':',
|
||||||
|
'field_prefix' => 'Tx.',
|
||||||
|
'fields' => array
|
||||||
|
("account_id" => array('name' => 'Account',
|
||||||
|
'opts' =>
|
||||||
|
array('type' => 'select',
|
||||||
|
'multiple' => 'checkbox',
|
||||||
|
'options' => $paymentAccounts,
|
||||||
|
'selected' => array_keys($defaultAccounts),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
"from_date" => array('opts' =>
|
||||||
|
array('type' => 'text'),
|
||||||
|
'between' => '<A HREF="#" ONCLICK="datepickerBOM(null,\'TxFromDate\'); return false;">BOM</A>',
|
||||||
|
),
|
||||||
|
"through_date" => array('opts' =>
|
||||||
|
array('type' => 'text'),
|
||||||
|
'between' => '<A HREF="#" ONCLICK="datepickerEOM(\'TxFromDate\',\'TxThroughDate\'); return false;">EOM</A>',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
echo $form->button('Update',
|
||||||
|
array('onclick' => 'updateEntriesGrid(); return false',
|
||||||
|
));
|
||||||
|
|
||||||
|
echo $form->end();
|
||||||
|
|
||||||
|
echo $this->element('ledger_entries', array
|
||||||
|
(// Element configuration
|
||||||
|
'collected_account_id' => $account['id'],
|
||||||
|
'collected_payment_accounts' => array_keys($defaultAccounts),
|
||||||
|
|
||||||
|
// Grid configuration
|
||||||
|
'config' => array
|
||||||
|
(
|
||||||
|
'grid_div_id' => 'collected-entries',
|
||||||
|
'grid_div_class' => 'text-below',
|
||||||
|
//'caption' => '<SPAN id="receipt-charges-caption"></SPAN>',
|
||||||
|
'caption' => 'Collected Charges',
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
echo('<DIV CLASS="grid-selection-text">' .
|
||||||
|
'<TABLE ID="supporting-table">' .
|
||||||
|
'<TR><TD CLASS="field">Balance:</TD><TD CLASS="value"><SPAN id="collected-balance"></SPAN></TD></TR>' .
|
||||||
|
'</TABLE>' .
|
||||||
|
'</DIV>' .
|
||||||
|
"\n");
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<script type="text/javascript"><!--
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("#TxFromDate")
|
||||||
|
.attr('autocomplete', 'off')
|
||||||
|
.datepicker({ constrainInput: true,
|
||||||
|
numberOfMonths: [1, 1],
|
||||||
|
showCurrentAtPos: 0,
|
||||||
|
dateFormat: 'mm/dd/yy' });
|
||||||
|
|
||||||
|
$("#TxThroughDate")
|
||||||
|
.attr('autocomplete', 'off')
|
||||||
|
.datepicker({ constrainInput: true,
|
||||||
|
numberOfMonths: [1, 1],
|
||||||
|
showCurrentAtPos: 0,
|
||||||
|
dateFormat: 'mm/dd/yy' });
|
||||||
|
|
||||||
|
resetForm();
|
||||||
|
});
|
||||||
|
--></script>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a href="#" onClick="$('#debug').html(''); return false;">Clear Debug Output</a>
|
||||||
@@ -64,8 +64,10 @@ foreach ($fields AS $field => $config) {
|
|||||||
elseif (isset($field_prefix) && !isset($config['no_prefix']))
|
elseif (isset($field_prefix) && !isset($config['no_prefix']))
|
||||||
$field = $field_prefix . '.' . $field;
|
$field = $field_prefix . '.' . $field;
|
||||||
|
|
||||||
$config['opts']['label'] = false;
|
if (!isset($config['opts']['label']))
|
||||||
$config['opts']['div'] = false;
|
$config['opts']['label'] = false;
|
||||||
|
if (!isset($config['opts']['div']))
|
||||||
|
$config['opts']['div'] = false;
|
||||||
|
|
||||||
$cells = array();
|
$cells = array();
|
||||||
if ($include_before) {
|
if ($include_before) {
|
||||||
|
|||||||
@@ -88,6 +88,12 @@ if (isset($account_ftype))
|
|||||||
$grid->invalidFields('Sub-Total');
|
$grid->invalidFields('Sub-Total');
|
||||||
|
|
||||||
|
|
||||||
|
// Now that columns are defined, establish basic grid parameters
|
||||||
|
$grid
|
||||||
|
->columns($cols)
|
||||||
|
->sortField('Date')
|
||||||
|
->defaultFields(array('Entry', 'Date', 'Amount', 'Credit', 'Debit'));
|
||||||
|
|
||||||
|
|
||||||
if (!isset($config['rows']) && !isset($collected_account_id)) {
|
if (!isset($config['rows']) && !isset($collected_account_id)) {
|
||||||
$config['action'] = 'ledger';
|
$config['action'] = 'ledger';
|
||||||
@@ -99,7 +105,9 @@ if (isset($reconcile_id)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($collected_account_id)) {
|
if (isset($collected_account_id)) {
|
||||||
|
$config['action'] = 'collected';
|
||||||
$grid->customData(compact('collected_account_id'))->limit(500);
|
$grid->customData(compact('collected_account_id'))->limit(500);
|
||||||
|
$grid->sortField('Paid');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up search fields if requested by caller
|
// Set up search fields if requested by caller
|
||||||
@@ -113,9 +121,6 @@ $grid->customData(compact('ledger_id', 'account_id', 'ar_account',
|
|||||||
|
|
||||||
// Render the grid
|
// Render the grid
|
||||||
$grid
|
$grid
|
||||||
->columns($cols)
|
|
||||||
->sortField('Date')
|
|
||||||
->defaultFields(array('Entry', 'Date', 'Amount', 'Credit', 'Debit'))
|
|
||||||
->render($this, isset($config) ? $config : null,
|
->render($this, isset($config) ? $config : null,
|
||||||
array('Transaction', 'Entry', 'Date', 'Effective', 'Paid',
|
array('Transaction', 'Entry', 'Date', 'Effective', 'Paid',
|
||||||
'Account', 'Debit Account', 'Credit Account',
|
'Account', 'Debit Account', 'Credit Account',
|
||||||
|
|||||||
Reference in New Issue
Block a user