This rework is nowhere near complete, but there are certain things that are falling in place, and worth capturing. I started a branch for just this purpose of being able to check in intermediate work.

git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716/site@352 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-19 23:35:25 +00:00
parent af0c10f6a6
commit 3d262fd4db
24 changed files with 2401 additions and 1373 deletions

View File

@@ -50,10 +50,11 @@ echo '<div class="ledger-entry view">' . "\n";
$transaction = $entry['Transaction'];
$ledgers = array('debit' => $entry['DebitLedger'],
'credit' => $entry['CreditLedger']);
$source = $entry['MonetarySource'];
$entries = array('debit' => $entry['DebitEntry'],
'credit' => $entry['CreditEntry']);
$customer = $entry['Customer'];
$lease = $entry['Lease'];
$entry = $entry['LedgerEntry'];
$entry = $entry['DoubleEntry'];
$rows = array();
$rows[] = array('ID', $entry['id']);
@@ -63,7 +64,7 @@ $rows[] = array('Transaction', $html->link('#'.$transaction['id'],
$transaction['id'])));
$rows[] = array('Timestamp', FormatHelper::datetime($transaction['stamp']));
$rows[] = array('Effective', FormatHelper::date($entry['effective_date']));
$rows[] = array('Through', FormatHelper::date($entry['through_date']));
//$rows[] = array('Through', FormatHelper::date($entry['through_date']));
$rows[] = array('Customer', (isset($customer['name'])
? $html->link($customer['name'],
array('controller' => 'customers',
@@ -76,12 +77,6 @@ $rows[] = array('Lease', (isset($lease['id'])
'action' => 'view',
$lease['id']))
: null));
$rows[] = array('Monetary Source', (isset($source['name'])
? $html->link($source['name'],
array('controller' => 'monetary_sources',
'action' => 'view',
$source['id']))
: null));
$rows[] = array('Comment', $entry['comment']);
echo $this->element('table',
@@ -95,35 +90,39 @@ echo $this->element('table',
* LedgerEntry Info Box
*/
echo '<div class="infobox">' . "\n";
foreach ($ledgers AS $type => $ledger) {
//pr($ledger);
if (!$ledger['Account']['trackable'])
continue;
/* echo '<div class="infobox">' . "\n"; */
/* foreach ($ledgers AS $type => $ledger) { */
/* //pr($ledger); */
/* if (!$ledger['Account']['trackable']) */
/* continue; */
$applied_caption = "Transfers applied";
$remaining_caption = "Unapplied amount";
/* $applied_caption = "Transfers applied"; */
/* $remaining_caption = "Unapplied amount"; */
$rows = array();
$rows[] = array($applied_caption,
FormatHelper::currency($stats[$type]['amount_reconciled']));
$rows[] = array($remaining_caption,
FormatHelper::currency($stats[$type]['amount_remaining']));
echo $this->element('table',
array('class' => 'item summary',
'caption' => "{$ledger['Account']['name']} Ledger Entry",
'rows' => $rows,
'column_class' => array('field', 'value'),
//'suppress_alternate_rows' => true,
));
}
/* $rows = array(); */
/* $rows[] = array($applied_caption, */
/* FormatHelper::currency($stats[$type]['amount_reconciled'])); */
/* $rows[] = array($remaining_caption, */
/* FormatHelper::currency($stats[$type]['amount_remaining'])); */
/* echo $this->element('table', */
/* array('class' => 'item summary', */
/* 'caption' => "{$ledger['Account']['name']} Ledger Entry", */
/* 'rows' => $rows, */
/* 'column_class' => array('field', 'value'), */
/* //'suppress_alternate_rows' => true, */
/* )); */
/* } */
echo '</div>' . "\n";
/* echo '</div>' . "\n"; */
echo ('<DIV CLASS="ledger-double-entry">' . "\n");
foreach ($ledgers AS $type => $ledger) {
$rows = array();
$rows[] = array('ID', $html->link('#' . $entries[$type]['id'],
array('controller' => 'entries',
'action' => 'view',
$entries[$type]['id'])));
$rows[] = array('Account', $html->link($ledger['Account']['name'],
array('controller' => 'accounts',
'action' => 'view',
@@ -156,30 +155,6 @@ echo ('</DIV>' . "\n");
echo '<div CLASS="detail supporting">' . "\n";
/**********************************************************************
* Reconciliation Ledger Entries
*/
foreach ($ledgers AS $type => $ledger) {
if (!$ledger['Account']['trackable'])
continue;
$caption = ('Applied transfers ' . ($ledger['Account']['ftype'] == $type ? 'out of' : 'into') .
' Account: ' . $ledger['Account']['name']);
echo $this->element('ledger_entries', array
(// Element configuration
'account_ftype' => $type,
'reconcile_id' => $entry['id'],
// Grid configuration
'config' => array
('caption' => $caption,
'grid_div_id' => $type.'_reconciliation_ledger_entries',
),
));
}
/* End "detail supporting" div */
echo '</div>' . "\n";

View File

@@ -109,15 +109,20 @@ if (!isset($config['rows']) && !isset($collected_account_id)) {
}
if (isset($reconcile_id)) {
$config['action'] = 'reconcile';
$grid->customData(compact('reconcile_id'))->limit(20);
}
if (isset($collected_account_id)) {
$config['action'] = 'collected';
$grid->customData(compact('collected_account_id'))->limit(50);
$account_id = $collected_account_id;
$grid->limit(50);
$grid->sortField('Last Payment');
}
if (isset($entry_ids))
$grid->id_list($entry_ids);
// Set up search fields if requested by caller
if (isset($searchfields))
$grid->searchFields(array('Customer', 'Unit'));

143
views/elements/entries.ctp Normal file
View File

@@ -0,0 +1,143 @@
<?php /* -*- mode:PHP -*- */
// Define the table columns
$cols = array();
$cols['Transaction'] = array('index' => 'Transaction.id', 'formatter' => 'id');
$cols['Entry'] = array('index' => 'Entry.id', 'formatter' => 'id');
$cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => 'date');
$cols['Effective'] = array('index' => 'DoubleEntry.effective_date', 'formatter' => 'date');
$cols['Through'] = array('index' => 'Entry.through_date', 'formatter' => 'date');
$cols['Account'] = array('index' => 'Account.name', 'formatter' => 'name');
$cols['Cr/Dr'] = array('index' => 'Entry.crdr', 'formatter' => 'name');
$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' => 'Entry.name', 'formatter' => 'name');
$cols['Comment'] = array('index' => 'Entry.comment', 'formatter' => 'comment', 'width'=>150);
$cols['Amount'] = array('index' => 'DoubleEntry.amount', 'formatter' => 'currency');
$cols['Last Payment'] = array('index' => 'last_paid', 'formatter' => 'date');
$cols['Applied'] = array('index' => "applied", 'formatter' => 'currency');
$cols['Sub-Total'] = array('index' => 'subtotal-DoubleEntry.amount', 'formatter' => 'currency', 'sortable' => false);
// Since group_by_tx is a boolean, let's just get it
// defined, regardless of whether the caller did so.
// group_by_tx will cause all entry fields to be
// invalidated, and will leave only the transaction
// fields. Yes... the caller should just use the
// transactions element instead, in theory. However,
// it hasn't yet been implemented to the level of
// this element, and additionally, the transactions
// element will not allow for customer information
// (rightly so, since it's a ledger_entry field).
// However, at the current implementation, all ledger
// entries of a transaction are for the same customer.
// So... we allow it for now.
if (!isset($group_by_tx))
$group_by_tx = false;
// REVISIT <AP>: 20090715
// If we really want to group by transaction, we need
// a transaction listing, not a ledger_entry listing.
// switch controllers... don't overload this one.
$group_by_tx = false;
if (isset($transaction_id) || isset($reconcile_id))
$grid->invalidFields('Transaction');
if ($group_by_tx)
$grid->invalidFields('Entry');
if ($group_by_tx)
$grid->invalidFields(array('Effective', 'Through'));
if (!isset($collected_account_id))
$grid->invalidFields('Last Payment');
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 || isset($collected_account_id))
$grid->invalidFields(array('Account', 'Debit Account', 'Credit Account'));
if (isset($ledger_id) || isset($account_id) || isset($ar_account)) {
$grid->invalidFields('Amount');
$cols['Sub-Total']['index'] = 'subtotal-balance';
} else {
$grid->invalidFields(array('Debit', 'Credit'));
$cols['Sub-Total']['index'] = 'subtotal-DoubleEntry.amount';
}
// group_by_tx SHOULD wipe out Customer, but the reality
// is that it works good at the present, so we'll leave it.
if (isset($lease_id) || isset($customer_id))
$grid->invalidFields(array('Customer'));
if (isset($lease_id) || $group_by_tx)
$grid->invalidFields(array('Lease', 'Unit'));
if (!isset($reconcile_id) && !isset($collected_account_id))
$grid->invalidFields('Applied');
else
$cols['Sub-Total']['index'] = 'subtotal-applied';
if (isset($account_ftype) || isset($collected_account_id))
$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)) {
$config['action'] = 'ledger';
$grid->limit(50);
}
if (isset($reconcile_id)) {
$config['action'] = 'reconcile';
$grid->customData(compact('reconcile_id'))->limit(20);
}
if (isset($collected_account_id)) {
$config['action'] = 'collected';
$account_id = $collected_account_id;
$grid->limit(50);
$grid->sortField('Last Payment');
}
if (isset($entry_ids)) {
unset($config['action']);
$grid->id_list($entry_ids);
}
// Set up search fields if requested by caller
if (isset($searchfields))
$grid->searchFields(array('Customer', 'Unit'));
// Include custom data
$grid->customData(compact('ledger_id', 'account_id', 'ar_account',
'account_type', 'account_ftype', 'monetary_source_id',
'customer_id', 'lease_id', 'transaction_id', 'group_by_tx'));
// Render the grid
$grid
->render($this, isset($config) ? $config : null,
array('Transaction', 'Entry', 'Date', 'Effective', 'Last Payment',
'Account', 'Cr/Dr',
'Customer', 'Unit',
'Comment',
'Amount',
'Applied', 'Sub-Total')
);

165
views/entries/view.ctp Normal file
View File

@@ -0,0 +1,165 @@
<?php /* -*- mode:PHP -*- */
echo '<div class="entry view">' . "\n";
// The two entry ids, debit and credit, are actually individual
// entries in separate accounts (each make up one of the two
// entries required for "double entry"). The reconciling entries
// are those on the opposite side of the ledger in the specific
// account. For example, assume the double entry is:
// debit: A/R credit: Cash amount: 55
//
// Then, our accounts might look like:
//
// RENT TAX A/R CASH BANK
// ------- ------- ------- ------- -------
// |20 | 20| | | <-- Unrelated
// | | |20 20| | <-- Unrelated
// | | | | |
// |50 | 50| | | <-- Rent paid by this entry
// | |5 5| | | <-- Tax paid by this entry
// | | |55 55| | <-- THIS DOUBLE ENTRY
// | | | | |
// | | | |75 75| <-- Deposit includes this entry
// | | | | |
//
// In this case, assume that THIS specific Entry is the A/R credit
// of the Double Entry. We'll need to provide information on the
// two A/R entries, 50 & 5, which are both debits, i.e. opposite
// entries to the credit of A/R.
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Entry Detail Main Section
*/
$account = $entry['Account'];
$double = $entry['DoubleEntry'];
$transaction = $double['Transaction'];
$customer = $double['Customer'];
$lease = $double['Lease'];
$entry = $entry['Entry'];
$rows = array();
$rows[] = array('ID', $entry['id']);
$rows[] = array('Transaction', $html->link('#'.$transaction['id'],
array('controller' => 'transactions',
'action' => 'view',
$transaction['id'])));
$rows[] = array('Timestamp', FormatHelper::datetime($transaction['stamp']));
$rows[] = array('Effective', FormatHelper::date($double['effective_date']));
$rows[] = array('Through', FormatHelper::date($entry['through_date']));
$rows[] = array('Account', $html->link($account['name'],
array('controller' => 'accounts',
'action' => 'view',
$account['id'])));
$rows[] = array('Cr/Dr', ($entry['crdr'] .
' (Matching ' . $entry['opposite_crdr'] . ': ' .
$html->link('#'.$entry['matching_entry_id'],
array('controller' => 'entries',
'action' => 'view',
$entry['matching_entry_id'])) .
')'));
$rows[] = array('Double Entry', $html->link('#'.$double['id'],
array('controller' => 'double_entries',
'action' => 'view',
$double['id'])));
$rows[] = array('Customer', (isset($customer['name'])
? $html->link($customer['name'],
array('controller' => 'customers',
'action' => 'view',
$customer['id']))
: null));
$rows[] = array('Lease', (isset($lease['id'])
? $html->link('#'.$lease['id'],
array('controller' => 'leases',
'action' => 'view',
$lease['id']))
: null));
$rows[] = array('Comment', $entry['comment']);
echo $this->element('table',
array('class' => 'item entry detail',
'caption' => 'Ledger Entry Detail',
'rows' => $rows,
'column_class' => array('field', 'value')));
/**********************************************************************
* Entry Info Box
*/
echo '<div class="infobox">' . "\n";
$applied_caption = "Transfers applied";
$remaining_caption = "Unapplied amount";
foreach ($reconciled['stats'] AS $Rtype => $stats) {
$rtype = strtolower($Rtype);
$applied_caption = "Transfers applied";
$remaining_caption = "Unapplied amount";
/* $applied_caption = $Rtype . 's Applied'; */
/* $remaining_caption = 'Remaining for ' . $Rtype . 's'; */
$rows = array();
$rows[] = array($applied_caption,
'<SPAN id="'.$rtype.'-applied">' .
FormatHelper::currency($stats['applied']) .
'</SPAN>');
$rows[] = array($remaining_caption,
'<SPAN id="'.$rtype.'-unapplied">' .
FormatHelper::currency($stats['unapplied']) .
'</SPAN>');
echo $this->element('table',
array('class' => 'item summary',
'caption' => $Rtype . 's',
'rows' => $rows,
'column_class' => array('field', 'value'),
//'suppress_alternate_rows' => true,
));
}
echo '</div>' . "\n";
/**********************************************************************
**********************************************************************
**********************************************************************
**********************************************************************
* Supporting Elements Section
*/
echo '<div CLASS="detail supporting">' . "\n";
/**********************************************************************
* Reconciliation Ledger Entries
*/
foreach ($reconciled['entries'] AS $Rtype => $entries) {
$rtype = strtolower($Rtype);
$caption = $Rtype . 's applied';
echo $this->element('entries', array
(// Element configuration
'entry_ids' => $entries,
// Grid configuration
'config' => array
('caption' => $caption,
'grid_div_id' => $rtype.'-entries',
),
));
}
/* End "detail supporting" div */
echo '</div>' . "\n";
/* End page div */
echo '</div>' . "\n";

View File

@@ -91,6 +91,7 @@ class GridHelper extends AppHelper {
= array_map(create_function('$data',
'return $data["id"];'),
$items);
$this->jqGrid_options['action'] = 'idlist';
return $this;
}

View File

@@ -19,9 +19,11 @@ echo ('<DIV CLASS="apply-deposit grid-selection-text">' .
'</DIV>' . "\n");
echo $form->create(null, array('id' => 'receipt-form',
'url' => array('controller' => 'transactions',
'action' => 'postReceipt')));
echo $form->create(null, array('id' => 'apply-deposit-form',
/* 'url' => array('controller' => 'lease', */
/* 'action' => 'apply_deposit') */
)
);
echo $form->input("Customer.id",
array('id' => 'customer-id',
@@ -33,7 +35,7 @@ echo $form->input("Lease.id",
'type' => 'hidden',
'value' => $lease['id']));
echo $form->input("LedgerEntry.0.account_id",
echo $form->input("LedgerEntry.Account.id",
array('id' => 'account-id',
'type' => 'hidden',
'value' => $account['id']));
@@ -47,7 +49,10 @@ echo $this->element('form_table',
("stamp" => array('opts' => array('type' => 'text'),
'between' => '<A HREF="#" ONCLICK="datepickerNow(\'TransactionStamp\'); return false;">Now</A>',
),
"amount" => array('prefix' => 'LedgerEntry.0'),
"amount" => array('prefix' => 'LedgerEntry',
'value' => min($lease['stats']['balance'],
$deposit['summary']['balance']),
),
"comment" => array('opts' => array('size' => 50),
),
)));

74
views/leases/refund.ctp Normal file
View File

@@ -0,0 +1,74 @@
<?php /* -*- mode:PHP -*- */
echo '<div class="account deposit">' . "\n";
echo '<H2>Perform Bank Deposit</H2>' . "\n";
echo '<P>Make sure to select the checkboxes below for only those types of currency (Cash, Check, etc) which you intend to actually deposit (you can see all the individual items by dropping down the list below the checkbox). Then, select the Deposit Account where you will make the deposit, and click "Perform Deposit" to close the books on the selected currency types and reset them to a zero balance. On the next page, you will be provided with a deposit slip to prepare the actual deposit.' . "\n";
echo '<P><BR>' . "\n";
//pr(compact('tillableAccount', 'depositableAccount'));
echo $form->create(null, array('id' => 'deposit-form',
'url' => array('controller' => 'accounts',
'action' => 'deposit')));
foreach ($tillableAccount AS $acct) {
//$acct = $acct['Account'];
echo "\n";
echo $form->input('Tillable.Ledger.'.$acct['CurrentLedger']['id'].'.checked',
array(//'label' => $acct['Account']['name'],
'type' => 'checkbox',
'checked' => true,
'value' => true,
'label' => (" I have exactly " .
FormatHelper::currency($acct['Account']['stats']['Ledger']['balance']) .
" in " . ($acct['Account']['name'] === 'Cash'
? 'Cash'
: Inflector::pluralize($acct['Account']['name'])) .
" and will be depositing it all.")
));
echo "\n";
echo $form->input('Tillable.Ledger.'.$acct['CurrentLedger']['id'].'.amount',
array('type' => 'hidden',
'value' => $acct['Account']['stats']['Ledger']['balance'],
));
echo "\n";
echo $form->input('Tillable.Ledger.'.$acct['CurrentLedger']['id'].'.account_id',
array('type' => 'hidden',
'value' => $acct['Account']['id'],
));
echo "\n";
echo $form->input('Tillable.Ledger.'.$acct['CurrentLedger']['id'].'.account_name',
array('type' => 'hidden',
'value' => $acct['Account']['name'],
));
echo "\n";
$grid_div_id = 'ledger_entries'.$acct['CurrentLedger']['id'].'-list';
echo $this->element('ledger_entries', array
(// Element configuration
'ledger_id' => $acct['CurrentLedger']['id'],
'no_account' => true,
// Grid configuration
'config' => array
(
'grid_div_id' => $grid_div_id,
'caption' => ('<A HREF="#" ONCLICK="$(\'#'.$grid_div_id.' .HeaderButton\').click();'.
' return false;">Items in '.$acct['Account']['name'].' Ledger</A>'),
'grid_setup' => array('hiddengrid' => true),
),
));
}
$options = array();
foreach ($depositableAccount AS $acct) {
$options[$acct['Account']['id']] = $acct['Account']['name'];
}
echo $form->input('Deposit.Account.id', array('label' => 'Deposit Account ',
'options' => $options));
echo $form->end('Perform Deposit');
/* End page div */
echo '</div>' . "\n";