From abd166cb98c5e39210a6a1e6c131378e90e2c8c0 Mon Sep 17 00:00:00 2001 From: abijah Date: Wed, 8 Jul 2009 16:04:53 +0000 Subject: [PATCH] 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 --- controllers/ledger_entries_controller.php | 4 +- models/ledger_entry.php | 4 +- views/elements/ledger_entries.ctp | 2 + views/elements/transactions.ctp | 3 +- views/leases/invoice.ctp | 45 ++++++++++++++--------- views/ledger_entries/view.ctp | 2 + views/transactions/view.ctp | 1 - 7 files changed, 35 insertions(+), 26 deletions(-) diff --git a/controllers/ledger_entries_controller.php b/controllers/ledger_entries_controller.php index 07a4b1d..aad81e4 100644 --- a/controllers/ledger_entries_controller.php +++ b/controllers/ledger_entries_controller.php @@ -298,9 +298,7 @@ class LedgerEntriesController extends AppController { 'Lease.id', ), - 'fields' => array('LedgerEntry.id', - 'LedgerEntry.amount', - 'LedgerEntry.comment'), + 'fields' => array('LedgerEntry.*'), 'conditions' => array('LedgerEntry.id' => $id), )); diff --git a/models/ledger_entry.php b/models/ledger_entry.php index 8578197..bfce372 100644 --- a/models/ledger_entry.php +++ b/models/ledger_entry.php @@ -91,7 +91,7 @@ class LedgerEntry extends AppModel { * query the ledger/account to find it out. */ 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)) { $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) { - $fields = array('id', 'name', 'comment', 'amount'); + $fields = array('id', 'effective_date', 'through_date', 'comment', 'amount'); if (isset($ledger_id)) { $fields[] = ("IF(LedgerEntry.debit_ledger_id = $ledger_id," . diff --git a/views/elements/ledger_entries.ctp b/views/elements/ledger_entries.ctp index 8ca5e3d..b409395 100644 --- a/views/elements/ledger_entries.ctp +++ b/views/elements/ledger_entries.ctp @@ -50,6 +50,8 @@ else } $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) { $cols['Account'] = array('index' => 'Account.name', 'formatter' => 'name'); diff --git a/views/elements/transactions.ctp b/views/elements/transactions.ctp index cfcd6c3..d0692cb 100644 --- a/views/elements/transactions.ctp +++ b/views/elements/transactions.ctp @@ -4,8 +4,7 @@ $cols = array(); $cols['ID'] = array('index' => 'Transaction.id', 'formatter' => 'id'); //$cols['Customer'] = array('index' => 'Customer.name', 'formatter' => 'longname'); -$cols['Timesamp'] = array('index' => 'Transaction.stamp', 'formatter' => 'date'); -$cols['Through'] = array('index' => 'Transaction.through_date', 'formatter' => 'date'); +$cols['Timestamp'] = array('index' => 'Transaction.stamp', 'formatter' => 'date'); $cols['Due'] = array('index' => 'Transaction.due_date', 'formatter' => 'date'); $cols['Comment'] = array('index' => 'Transaction.comment', 'formatter' => 'comment'); diff --git a/views/leases/invoice.ctp b/views/leases/invoice.ctp index b39d785..270bcb4 100644 --- a/views/leases/invoice.ctp +++ b/views/leases/invoice.ctp @@ -106,8 +106,7 @@ function resetForm() { $("#invoice-deposit").html("INTERNAL ERROR"); addChargeSource(false); - datepickerNow('charge_date'); - $("#through_date").val(''); + datepickerNow('TransactionStamp'); } @@ -150,6 +149,7 @@ function onGridState(grid_id, state) { } function addChargeSource(flash) { + var id = $("#charge-entry-id").val(); addDiv('charge-entry-id', 'charge', 'charges', flash, // HTML section '
' + @@ -168,6 +168,14 @@ function addChargeSource(flash) { 'value' => $defaultAccount, ), ), + "effective_date" => array('opts' => + array('type' => 'text'), + 'between' => 'BOM', + ), + "through_date" => array('opts' => + array('type' => 'text'), + 'between' => 'EOM', + ), "amount" => null, "comment" => array('opts' => array('size' => 50)), ), @@ -176,6 +184,20 @@ function addChargeSource(flash) { '
' ); + + $("#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' }); } --> @@ -253,14 +275,8 @@ echo $this->element('form_table', 'field_prefix' => 'Transaction', 'fields' => array ("stamp" => array('opts' => - array('id' => 'charge_date', - 'type' => 'text'), - 'between' => 'Now', - ), - "through_date" => array('opts' => - array('id' => 'through_date', - 'type' => 'text'), - 'between' => 'EOM', + array('type' => 'text'), + 'between' => 'Now', ), "comment" => array('opts' => array('size' => 50), ), @@ -288,14 +304,7 @@ echo $form->submit('Generate Invoice') . "\n";