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:
abijah
2009-06-24 17:16:39 +00:00
parent 8cb45ad1d6
commit 6baa7fa6e6
13 changed files with 225 additions and 231 deletions

View File

@@ -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);
}
}