From 07a2be05f77109971a4eaad37b3c3d5fb4d48797 Mon Sep 17 00:00:00 2001 From: abijah Date: Mon, 10 Aug 2009 00:56:41 +0000 Subject: [PATCH] Added customer since/until fields. Changed the ledger entry grid on the customers page into a receipts grid, and added it to the lease page as well, even though it is for the customer in general, and may include receipts for leases other than the one being viewed. I may put more effort into this later, but for now it solves the problem of getting the receipt tenders visible when viewing the lease. git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@509 97e9348a-65ac-dc4b-aefc-98561f571b83 --- site/controllers/customers_controller.php | 12 +++++++++ site/views/customers/view.ctp | 31 ++++++++++------------- site/views/leases/view.ctp | 23 +++++++++++++++-- 3 files changed, 47 insertions(+), 19 deletions(-) diff --git a/site/controllers/customers_controller.php b/site/controllers/customers_controller.php index ad97b2b..290fc4a 100644 --- a/site/controllers/customers_controller.php +++ b/site/controllers/customers_controller.php @@ -202,7 +202,19 @@ class CustomersController extends AppController { )); //pr($customer); + // Determine how long this customer has been with us. + $leaseinfo = $this->Customer->find + ('first', array + ('link' => array('Lease' => array('fields' => array())), + 'fields' => array('MIN(Lease.movein_date) AS since', + 'IF(Customer.current_lease_count = 0, MAX(Lease.moveout_date), NULL) AS until'), + 'conditions' => array('Customer.id' => $id), + 'group' => 'Customer.id', + )); + $this->set($leaseinfo[0]); + // Figure out the outstanding balances for this customer + //$this->set('stats', $this->Customer->stats($id)); $outstanding_balance = $this->Customer->balance($id); $outstanding_deposit = $this->Customer->securityDepositBalance($id); diff --git a/site/views/customers/view.ctp b/site/views/customers/view.ctp index bd6908c..19e468f 100644 --- a/site/views/customers/view.ctp +++ b/site/views/customers/view.ctp @@ -11,6 +11,9 @@ echo '
' . "\n"; $rows = array(); $rows[] = array('Name', $customer['Customer']['name']); +$rows[] = array('Since', FormatHelper::date($since, true)); +if (!empty($until)) + $rows[] = array('Until', FormatHelper::date($until, true)); $rows[] = array('Comment', $customer['Customer']['comment']); echo $this->element('table', @@ -27,7 +30,9 @@ echo $this->element('table', echo '
' . "\n"; $rows = array(); $rows[] = array('Security Deposit:', FormatHelper::currency($outstandingDeposit)); -$rows[] = array('Balance:', FormatHelper::currency($outstandingBalance)); +//$rows[] = array('Charges:', FormatHelper::currency($stats['charges'])); +//$rows[] = array('Payments:', FormatHelper::currency($stats['disbursements'])); +$rows[] = array('Balance Owed:', FormatHelper::currency($outstandingBalance)); echo $this->element('table', array('class' => 'summary', 'rows' => $rows, @@ -80,7 +85,7 @@ echo $this->element('leases', array echo $this->element('statement_entries', array (// Grid configuration 'config' => array - ('caption' => 'Account', + ('caption' => 'Customer Statement', 'filter' => array('Customer.id' => $customer['Customer']['id'], 'type !=' => 'VOID'), 'exclude' => array('Customer'), @@ -90,27 +95,19 @@ echo $this->element('statement_entries', array /********************************************************************** - * Customer Ledger History + * Receipt History */ -/* - * REVISIT : 20090724 - * It's not my intention to really include this, as I believe it - * just will confuse folks. However, I've added it at the moment - * to help me see the picture of what's happening. It may prove - * useful with respect to identifying pre-payments, so after using - * it for a while, maybe we can get a feeling for that. I suspect - * it will be MUCH more useful just to add the pre-pay amount to - * the info box, or provide a list of ledger entries that are JUST - * pre-payments. We'll see... - */ echo $this->element('ledger_entries', array (// Grid configuration 'config' => array - ('caption' => 'Ledger Entries', + ('caption' => 'Receipts', 'filter' => array('Customer.id' => $customer['Customer']['id'], - 'Account.id !=' => '-AR-'), - 'exclude' => array('Customer'), + 'Transaction.type' => 'RECEIPT', + 'Tender.id !=' => null, + //'Account.id !=' => '-AR-' + ), + 'exclude' => array('Account', 'Cr/Dr'), 'sort_column' => 'Date', 'sort_order' => 'DESC', ))); diff --git a/site/views/leases/view.ctp b/site/views/leases/view.ctp index 7eb7d3f..f13cea9 100644 --- a/site/views/leases/view.ctp +++ b/site/views/leases/view.ctp @@ -57,7 +57,7 @@ echo $this->element('table', echo '
' . "\n"; $rows = array(); $rows[] = array('Security Deposit:', FormatHelper::currency($outstandingDeposit)); -$rows[] = array('Balance:', FormatHelper::currency($outstandingBalance)); +$rows[] = array('Balance Owed:', FormatHelper::currency($outstandingBalance)); echo $this->element('table', array('class' => 'summary', 'rows' => $rows, @@ -84,7 +84,7 @@ echo '
' . "\n"; echo $this->element('statement_entries', array (// Grid configuration 'config' => array - ('caption' => 'Account', + ('caption' => 'Lease Statement', 'filter' => array('Lease.id' => $lease['id']), 'include' => array('Through'), 'exclude' => array('Customer', 'Lease', 'Unit'), @@ -93,6 +93,25 @@ echo $this->element('statement_entries', array ))); +/********************************************************************** + * Receipt History + */ + +echo $this->element('ledger_entries', array + (// Grid configuration + 'config' => array + ('caption' => 'Customer Receipts', + 'filter' => array('Customer.id' => $customer['id'], + 'Transaction.type' => 'RECEIPT', + 'Tender.id !=' => null, + //'Account.id !=' => '-AR-' + ), + 'exclude' => array('Account', 'Cr/Dr'), + 'sort_column' => 'Date', + 'sort_order' => 'DESC', + ))); + + /* End "detail supporting" div */ echo '
' . "\n";