Nowhere near complete, but must snapshot prior to my Boston trip.
git-svn-id: file:///svn-source/pmgr/branches/statements_20090623@184 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -8,6 +8,7 @@ class Customer extends AppModel {
|
||||
);
|
||||
|
||||
var $belongsTo = array(
|
||||
'Statement',
|
||||
'PrimaryContact' => array(
|
||||
'className' => 'Contact',
|
||||
),
|
||||
@@ -43,13 +44,26 @@ class Customer extends AppModel {
|
||||
*/
|
||||
function accountId($id) {
|
||||
$this->cacheQueries = true;
|
||||
$customer = $this->find('first',
|
||||
array('contain' => false,
|
||||
'fields' => array('account_id'),
|
||||
'conditions' => array(array('Customer.id' => $id))));
|
||||
$item = $this->find('first',
|
||||
array('contain' => false,
|
||||
'fields' => array('account_id'),
|
||||
'conditions' => compact('id')));
|
||||
$this->cacheQueries = false;
|
||||
|
||||
return $customer['Customer']['account_id'];
|
||||
$item = current($item);
|
||||
return $item['account_id'];
|
||||
}
|
||||
|
||||
function statementID($id) {
|
||||
$this->cacheQueries = true;
|
||||
$item = $this->find('first', array
|
||||
('recursive' => -1,
|
||||
'conditions' => compact('id'),
|
||||
));
|
||||
$this->cacheQueries = false;
|
||||
|
||||
$item = current($item);
|
||||
return $item['statement_id'];
|
||||
}
|
||||
|
||||
|
||||
@@ -75,6 +89,7 @@ class Customer extends AppModel {
|
||||
return $ids;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************************
|
||||
**************************************************************************
|
||||
**************************************************************************
|
||||
@@ -82,22 +97,10 @@ class Customer extends AppModel {
|
||||
* - Returns an array of security deposit entries
|
||||
*/
|
||||
function findSecurityDeposits($id, $link = null) {
|
||||
/* pr(array('function' => 'Customer::findSecurityDeposits', */
|
||||
/* 'args' => compact('id', 'link'), */
|
||||
/* )); */
|
||||
|
||||
$entries = $this->Account->findLedgerEntriesRelatedToAccount
|
||||
($this->Account->invoiceAccountID(),
|
||||
return $this->Statement->findEntriesRelatedToAccount
|
||||
($this->statementId($id),
|
||||
$this->Account->securityDepositAccountID(),
|
||||
true, array('LedgerEntry.customer_id' => $id), $link);
|
||||
|
||||
/* pr(array('function' => 'Customer::findSecurityDeposits', */
|
||||
/* 'args' => compact('id', 'link'), */
|
||||
/* 'vars' => compact('customer'), */
|
||||
/* 'return' => compact('entries'), */
|
||||
/* )); */
|
||||
|
||||
return $entries;
|
||||
null, $link);
|
||||
}
|
||||
|
||||
|
||||
@@ -191,16 +194,11 @@ class Customer extends AppModel {
|
||||
* - Returns summary data from the requested customer.
|
||||
*/
|
||||
|
||||
function stats($id = null) {
|
||||
function stats($id = null, $cond = null, $link = null) {
|
||||
if (!$id)
|
||||
return null;
|
||||
|
||||
$stats = $this->Account->stats($this->Account->accountReceivableAccountID(), true,
|
||||
array('LedgerEntry.customer_id' => $id));
|
||||
|
||||
// Pull to the top level and return
|
||||
$stats = $stats['Ledger'];
|
||||
return $stats;
|
||||
return $this->Statement->stats($this->statementID($id), $cond, $link);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user