Modified effective dates to be part of the ledger entry, not the transaction. This is the logically correct way, as a transaction is simply a collection of entries which might be anywhere from completely aligned to totally disjoint from one another (more likely the former). As a practical example, consider a move-in invoice, with security deposit (effective immediately with no end date), a prorated rent (effective move-in day through the end of the first month), and first full months rent (effective beginning of next month through the end of next month). There is certainly more work to be done on this, and testing was minimal. It does seem to be functioning though, so I'm checking in.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629/site@256 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-08 16:04:53 +00:00
parent cb627b8ec7
commit abd166cb98
7 changed files with 35 additions and 26 deletions

View File

@@ -298,9 +298,7 @@ class LedgerEntriesController extends AppController {
'Lease.id', 'Lease.id',
), ),
'fields' => array('LedgerEntry.id', 'fields' => array('LedgerEntry.*'),
'LedgerEntry.amount',
'LedgerEntry.comment'),
'conditions' => array('LedgerEntry.id' => $id), 'conditions' => array('LedgerEntry.id' => $id),
)); ));

View File

@@ -91,7 +91,7 @@ class LedgerEntry extends AppModel {
* query the ledger/account to find it out. * query the ledger/account to find it out.
*/ */
function ledgerContextFields($ledger_id = null, $account_type = null) { function ledgerContextFields($ledger_id = null, $account_type = null) {
$fields = array('id', 'name', 'comment', 'amount'); $fields = array('id', 'effective_date', 'through_date', 'comment', 'amount');
if (isset($ledger_id)) { if (isset($ledger_id)) {
$fields[] = ("IF(LedgerEntry.debit_ledger_id = $ledger_id," . $fields[] = ("IF(LedgerEntry.debit_ledger_id = $ledger_id," .
@@ -114,7 +114,7 @@ class LedgerEntry extends AppModel {
} }
function ledgerContextFields2($ledger_id = null, $account_id = null, $account_type = null) { function ledgerContextFields2($ledger_id = null, $account_id = null, $account_type = null) {
$fields = array('id', 'name', 'comment', 'amount'); $fields = array('id', 'effective_date', 'through_date', 'comment', 'amount');
if (isset($ledger_id)) { if (isset($ledger_id)) {
$fields[] = ("IF(LedgerEntry.debit_ledger_id = $ledger_id," . $fields[] = ("IF(LedgerEntry.debit_ledger_id = $ledger_id," .

View File

@@ -50,6 +50,8 @@ else
} }
$cols['Date'] = array('index' => 'Transaction.stamp', 'formatter' => 'date'); $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');
if ($single_account) { if ($single_account) {
$cols['Account'] = array('index' => 'Account.name', 'formatter' => 'name'); $cols['Account'] = array('index' => 'Account.name', 'formatter' => 'name');

View File

@@ -4,8 +4,7 @@
$cols = array(); $cols = array();
$cols['ID'] = array('index' => 'Transaction.id', 'formatter' => 'id'); $cols['ID'] = array('index' => 'Transaction.id', 'formatter' => 'id');
//$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname'); //$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname');
$cols['Timesamp'] = array('index' => 'Transaction.stamp', 'formatter' => 'date'); $cols['Timestamp'] = array('index' => 'Transaction.stamp', 'formatter' => 'date');
$cols['Through'] = array('index' => 'Transaction.through_date', 'formatter' => 'date');
$cols['Due'] = array('index' => 'Transaction.due_date', 'formatter' => 'date'); $cols['Due'] = array('index' => 'Transaction.due_date', 'formatter' => 'date');
$cols['Comment'] = array('index' => 'Transaction.comment', 'formatter' => 'comment'); $cols['Comment'] = array('index' => 'Transaction.comment', 'formatter' => 'comment');

View File

@@ -106,8 +106,7 @@ function resetForm() {
$("#invoice-deposit").html("INTERNAL ERROR"); $("#invoice-deposit").html("INTERNAL ERROR");
addChargeSource(false); addChargeSource(false);
datepickerNow('charge_date'); datepickerNow('TransactionStamp');
$("#through_date").val('');
} }
@@ -150,6 +149,7 @@ function onGridState(grid_id, state) {
} }
function addChargeSource(flash) { function addChargeSource(flash) {
var id = $("#charge-entry-id").val();
addDiv('charge-entry-id', 'charge', 'charges', flash, addDiv('charge-entry-id', 'charge', 'charges', flash,
// HTML section // HTML section
'<FIELDSET CLASS="charge subset">' + '<FIELDSET CLASS="charge subset">' +
@@ -168,6 +168,14 @@ function addChargeSource(flash) {
'value' => $defaultAccount, 'value' => $defaultAccount,
), ),
), ),
"effective_date" => array('opts' =>
array('type' => 'text'),
'between' => '<A HREF="#" ONCLICK="datepickerBOM(\'TransactionStamp\',\'LedgerEntry%{id}EffectiveDate\'); return false;">BOM</A>',
),
"through_date" => array('opts' =>
array('type' => 'text'),
'between' => '<A HREF="#" ONCLICK="datepickerEOM(\'LedgerEntry%{id}EffectiveDate\',\'LedgerEntry%{id}ThroughDate\'); return false;">EOM</A>',
),
"amount" => null, "amount" => null,
"comment" => array('opts' => array('size' => 50)), "comment" => array('opts' => array('size' => 50)),
), ),
@@ -176,6 +184,20 @@ function addChargeSource(flash) {
'</FIELDSET>' '</FIELDSET>'
); );
$("#LedgerEntry"+id+"EffectiveDate")
.attr('autocomplete', 'off')
.datepicker({ constrainInput: true,
numberOfMonths: [1, 1],
showCurrentAtPos: 0,
dateFormat: 'mm/dd/yy' });
$("#LedgerEntry"+id+"ThroughDate")
.attr('autocomplete', 'off')
.datepicker({ constrainInput: true,
numberOfMonths: [1, 1],
showCurrentAtPos: 0,
dateFormat: 'mm/dd/yy' });
} }
--></script> --></script>
@@ -253,14 +275,8 @@ echo $this->element('form_table',
'field_prefix' => 'Transaction', 'field_prefix' => 'Transaction',
'fields' => array 'fields' => array
("stamp" => array('opts' => ("stamp" => array('opts' =>
array('id' => 'charge_date', array('type' => 'text'),
'type' => 'text'), 'between' => '<A HREF="#" ONCLICK="datepickerNow(\'TransactionStamp\'); return false;">Now</A>',
'between' => '<A HREF="#" ONCLICK="datepickerNow(\'charge_date\'); return false;">Now</A>',
),
"through_date" => array('opts' =>
array('id' => 'through_date',
'type' => 'text'),
'between' => '<A HREF="#" ONCLICK="datepickerEOM(\'charge_date\',\'through_date\'); return false;">EOM</A>',
), ),
"comment" => array('opts' => array('size' => 50), "comment" => array('opts' => array('size' => 50),
), ),
@@ -288,14 +304,7 @@ echo $form->submit('Generate Invoice') . "\n";
<script type="text/javascript"><!-- <script type="text/javascript"><!--
$(document).ready(function(){ $(document).ready(function(){
$("#charge_date") $("#TransactionStamp")
.attr('autocomplete', 'off')
.datepicker({ constrainInput: true,
numberOfMonths: [1, 1],
showCurrentAtPos: 0,
dateFormat: 'mm/dd/yy' });
$("#through_date")
.attr('autocomplete', 'off') .attr('autocomplete', 'off')
.datepicker({ constrainInput: true, .datepicker({ constrainInput: true,
numberOfMonths: [1, 1], numberOfMonths: [1, 1],

View File

@@ -23,6 +23,8 @@ $rows = array(array('ID', $entry['id']),
'action' => 'view', 'action' => 'view',
$transaction['id']))), $transaction['id']))),
array('Timestamp', FormatHelper::datetime($transaction['stamp'])), array('Timestamp', FormatHelper::datetime($transaction['stamp'])),
array('Effective', FormatHelper::date($entry['effective_date'])),
array('Through', FormatHelper::date($entry['through_date'])),
array('Customer', (isset($customer['name']) array('Customer', (isset($customer['name'])
? $html->link($customer['name'], ? $html->link($customer['name'],
array('controller' => 'customers', array('controller' => 'customers',

View File

@@ -11,7 +11,6 @@ echo '<div class="transaction view">' . "\n";
$rows = array(array('ID', $transaction['Transaction']['id']), $rows = array(array('ID', $transaction['Transaction']['id']),
array('Timestamp', FormatHelper::datetime($transaction['Transaction']['stamp'])), array('Timestamp', FormatHelper::datetime($transaction['Transaction']['stamp'])),
array('Through', FormatHelper::date($transaction['Transaction']['through_date'])),
array('Due', FormatHelper::date($transaction['Transaction']['due_date'])), array('Due', FormatHelper::date($transaction['Transaction']['due_date'])),
array('Comment', $transaction['Transaction']['comment'])); array('Comment', $transaction['Transaction']['comment']));