First pass changes for a dedicated customer credit account. This checkin is just refactoring.
git-svn-id: file:///svn-source/pmgr/branches/surplus_account_20090815@568 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -562,38 +562,24 @@ class StatementEntry extends AppModel {
|
||||
if (empty($credit['balance']))
|
||||
continue;
|
||||
|
||||
$ret['receipt_balance'] = $credit['balance'];
|
||||
// Convert non-exhausted receipt credit to an explicit one
|
||||
$explicit_credit = $this->find
|
||||
('first', array('contain' => false,
|
||||
'conditions' =>
|
||||
array(array('transaction_id' => $credit['Transaction']['id']),
|
||||
array('type' => 'SURPLUS')),
|
||||
));
|
||||
$this->pr(18, compact('credit'),
|
||||
'Create Explicit Credit');
|
||||
|
||||
if (empty($explicit_credit)) {
|
||||
$this->pr(18, compact('credit'),
|
||||
'Create Explicit Credit');
|
||||
|
||||
$result = $this->addStatementEntry
|
||||
(array('type' => 'SURPLUS',
|
||||
'account_id' => $credit['LedgerEntry']['account_id'],
|
||||
'amount' => $credit['balance'],
|
||||
'effective_date' => $credit['Transaction']['stamp'],
|
||||
'transaction_id' => $credit['Transaction']['id'],
|
||||
'customer_id' => $customer_id,
|
||||
'lease_id' => $lease_id,
|
||||
));
|
||||
$ret['Credit'] = $result;
|
||||
if ($result['error'])
|
||||
$ret['error'] = true;
|
||||
}
|
||||
else {
|
||||
$this->pr(18, compact('explicit_credit', 'credit'),
|
||||
'Update Explicit Credit');
|
||||
$EC = new StatementEntry();
|
||||
$EC->id = $explicit_credit['StatementEntry']['id'];
|
||||
$EC->saveField('amount', $credit['balance']);
|
||||
}
|
||||
/* //$result = $this->Transaction->LedgerEntry->DoubleEntry->addDoubleEntry */
|
||||
/* $result = $this->addStatementEntry */
|
||||
/* (array('type' => 'SURPLUS', */
|
||||
/* 'account_id' => $credit['LedgerEntry']['account_id'], */
|
||||
/* 'amount' => $credit['balance'], */
|
||||
/* 'effective_date' => $credit['Transaction']['stamp'], */
|
||||
/* 'transaction_id' => $credit['Transaction']['id'], */
|
||||
/* 'customer_id' => $customer_id, */
|
||||
/* 'lease_id' => $lease_id, */
|
||||
/* )); */
|
||||
/* $ret['Credit'] = $result; */
|
||||
/* if ($result['error']) */
|
||||
/* $ret['error'] = true; */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user