Customers is working somewhat. I want to see if the grid query logic can be simplified, so I'm checking in first
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@359 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -19,7 +19,7 @@ class Customer extends AppModel {
|
||||
'conditions' => 'CurrentLease.close_date IS NULL',
|
||||
),
|
||||
'Lease',
|
||||
'DoubleEntry',
|
||||
'StatementEntry',
|
||||
'ContactsCustomer',
|
||||
|
||||
'Transaction',
|
||||
@@ -81,17 +81,15 @@ class Customer extends AppModel {
|
||||
|
||||
$A = new Account();
|
||||
|
||||
if (!isset($query['link']['DoubleEntry']))
|
||||
$query['link']['DoubleEntry'] = array();
|
||||
if (!isset($query['link']['DoubleEntry']['Customer']))
|
||||
$query['link']['DoubleEntry']['Customer'] = array();
|
||||
if (!isset($query['link']['DoubleEntry']['Customer']['fields']))
|
||||
$query['link']['DoubleEntry']['Customer']['fields'] = array();
|
||||
if (!isset($query['link']['Customer']))
|
||||
$query['link']['Customer'] = array();
|
||||
if (!isset($query['link']['Customer']['fields']))
|
||||
$query['link']['Customer']['fields'] = array();
|
||||
|
||||
$query['conditions'][] = array('Customer.id' => $id);
|
||||
$query['conditions'][] = array('Entry.account_id' => $A->securityDepositAccountID());
|
||||
$query['conditions'][] = array('StatementEntry.account_id' => $A->securityDepositAccountID());
|
||||
|
||||
$set = $this->DoubleEntry->Entry->reconciledSet('CHARGE', $query);
|
||||
$set = $this->StatementEntry->reconciledSet('CHARGE', $query);
|
||||
//pr(compact('set'));
|
||||
return $set;
|
||||
}
|
||||
@@ -107,16 +105,16 @@ class Customer extends AppModel {
|
||||
function unreconciledCharges($id, $query = null) {
|
||||
$this->queryInit($query);
|
||||
|
||||
if (!isset($query['link']['DoubleEntry']))
|
||||
$query['link']['DoubleEntry'] = array();
|
||||
if (!isset($query['link']['DoubleEntry']['Customer']))
|
||||
$query['link']['DoubleEntry']['Customer'] = array();
|
||||
if (!isset($query['link']['DoubleEntry']['Customer']['fields']))
|
||||
$query['link']['DoubleEntry']['Customer']['fields'] = array();
|
||||
if (!isset($query['link']['StatementEntry']))
|
||||
$query['link']['StatementEntry'] = array();
|
||||
/* if (!isset($query['link']['StatementEntry']['Customer'])) */
|
||||
/* $query['link']['StatementEntry']['Customer'] = array(); */
|
||||
/* if (!isset($query['link']['StatementEntry']['Customer']['fields'])) */
|
||||
/* $query['link']['StatementEntry']['Customer']['fields'] = array(); */
|
||||
|
||||
$query['conditions'][] = array('Customer.id' => $id);
|
||||
|
||||
$set = $this->DoubleEntry->Entry->reconciledSet('CHARGE', $query, true);
|
||||
$set = $this->StatementEntry->reconciledSet('CHARGE', $query, true);
|
||||
//pr(compact('set'));
|
||||
return $set;
|
||||
}
|
||||
@@ -132,16 +130,16 @@ class Customer extends AppModel {
|
||||
function excessPayments($id, $query = null) {
|
||||
$this->queryInit($query);
|
||||
|
||||
if (!isset($query['link']['DoubleEntry']))
|
||||
$query['link']['DoubleEntry'] = array();
|
||||
if (!isset($query['link']['DoubleEntry']['Customer']))
|
||||
$query['link']['DoubleEntry']['Customer'] = array();
|
||||
if (!isset($query['link']['DoubleEntry']['Customer']['fields']))
|
||||
$query['link']['DoubleEntry']['Customer']['fields'] = array();
|
||||
if (!isset($query['link']['StatementEntry']))
|
||||
$query['link']['StatementEntry'] = array();
|
||||
/* if (!isset($query['link']['StatementEntry']['Customer'])) */
|
||||
/* $query['link']['StatementEntry']['Customer'] = array(); */
|
||||
/* if (!isset($query['link']['StatementEntry']['Customer']['fields'])) */
|
||||
/* $query['link']['StatementEntry']['Customer']['fields'] = array(); */
|
||||
|
||||
$query['conditions'][] = array('Customer.id' => $id);
|
||||
|
||||
$set = $this->DoubleEntry->Entry->reconciledSet('PAYMENT', $query, true);
|
||||
$set = $this->StatementEntry->reconciledSet('PAYMENT', $query, true);
|
||||
//pr(compact('set'));
|
||||
return $set;
|
||||
}
|
||||
@@ -171,7 +169,7 @@ class Customer extends AppModel {
|
||||
$unreconciled['entries'] = $this->unreconciledCharges($id, $query);
|
||||
|
||||
foreach ($unreconciled['entries'] AS $i => &$item) {
|
||||
$entry =& $item['DoubleEntry'];
|
||||
$entry =& $item['StatementEntry'];
|
||||
// Determine if amount is sufficient to cover the entry
|
||||
if ($amount > $entry['balance'])
|
||||
$apply = $entry['balance'];
|
||||
@@ -214,7 +212,7 @@ class Customer extends AppModel {
|
||||
$A = new Account();
|
||||
$reconciled = $A->reconcileLedgerEntries
|
||||
($A->accountReceivableAccountID(),
|
||||
array('DoubleEntry.customer_id' => $id));
|
||||
array('StatementEntry.customer_id' => $id));
|
||||
|
||||
return $reconciled;
|
||||
}
|
||||
@@ -347,13 +345,15 @@ class Customer extends AppModel {
|
||||
if (!$id)
|
||||
return null;
|
||||
|
||||
$A = new Account();
|
||||
$stats = $A->stats($A->accountReceivableAccountID(), true,
|
||||
array('DoubleEntry.customer_id' => $id));
|
||||
$stats = $this->StatementEntry->find
|
||||
('first', array
|
||||
('contain' => false,
|
||||
'fields' => $this->StatementEntry->chargePaymentFields(true),
|
||||
'conditions' => array('StatementEntry.customer_id' => $id),
|
||||
));
|
||||
|
||||
// Pull to the top level and return
|
||||
$stats = $stats['Ledger'];
|
||||
return $stats;
|
||||
//pr(compact('stats'));
|
||||
return $stats[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user