Captured some thoughts, some experiments on how to tie statement entry to ledger entry. It's not at all clear we want to go down this (or any other) path at the moment. This checkin will probably go nowhere, as I'm going to see if we can make do with the current implementation.
git-svn-id: file:///svn-source/pmgr/branches/statement_ledger_entry_tie_20090802@468 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -5,7 +5,6 @@ class StatementEntry extends AppModel {
|
||||
'Transaction',
|
||||
'Customer',
|
||||
'Lease',
|
||||
'Account',
|
||||
|
||||
// The charge to which this payment applies (if it is one)
|
||||
'ChargeEntry' => array(
|
||||
@@ -20,6 +19,14 @@ class StatementEntry extends AppModel {
|
||||
'foreignKey' => 'charge_entry_id',
|
||||
),
|
||||
|
||||
'StatementFraction',
|
||||
);
|
||||
|
||||
var $hasAndBelongsToMany = array(
|
||||
'LedgerEntry' => array(
|
||||
'joinTable' => 'statement_fractions',
|
||||
//'fields' => 'StatementFraction.amount',
|
||||
),
|
||||
);
|
||||
|
||||
//var $default_log_level = 30;
|
||||
@@ -66,12 +73,11 @@ class StatementEntry extends AppModel {
|
||||
* (not in a pre-existing statement entry)
|
||||
*/
|
||||
function verifyStatementEntry($entry) {
|
||||
$this->prFunctionLevel(10);
|
||||
$this->prFunctionLevel(30);
|
||||
$this->prEnter(compact('entry'));
|
||||
|
||||
if (empty($entry['type']) ||
|
||||
//empty($entry['effective_date']) ||
|
||||
empty($entry['account_id']) ||
|
||||
empty($entry['amount'])
|
||||
) {
|
||||
return $this->prReturn(false);
|
||||
@@ -101,6 +107,12 @@ class StatementEntry extends AppModel {
|
||||
if (!$this->save($entry))
|
||||
return array('error' => true, 'save_data' => $entry) + $ret;
|
||||
|
||||
foreach ($entry['Fraction'] AS $fraction) {
|
||||
$fraction['statement_entry_id'] = $this->id;
|
||||
$this->StatementFraction->id = null;
|
||||
$this->StatementFraction->save($fraction);
|
||||
}
|
||||
|
||||
$ret['statement_entry_id'] = $this->id;
|
||||
return $this->prReturn($ret + array('error' => false));
|
||||
}
|
||||
@@ -335,7 +347,7 @@ OPTION 2
|
||||
*
|
||||
*/
|
||||
function assignCredits($query = null, $receipt_id = null) {
|
||||
//$this->prFunctionLevel(25);
|
||||
$this->prFunctionLevel(25);
|
||||
$this->prEnter( compact('query', 'receipt_id'));
|
||||
$this->queryInit($query);
|
||||
|
||||
@@ -352,16 +364,17 @@ OPTION 2
|
||||
// Next, establish credit from the newly added receipt
|
||||
$receipt_credit = null;
|
||||
if (!empty($receipt_id)) {
|
||||
$lquery = $query;
|
||||
$lquery['link'] += array('LedgerEntry' =>
|
||||
array('conditions' =>
|
||||
//array(LedgerEntry.'crdr'=>'DEBIT'),
|
||||
array('LedgerEntry.account_id !=' => $this->Account->accountReceivableAccountID()),
|
||||
));
|
||||
$lquery['fields'] = array('Transaction.id', 'Transaction.stamp', 'Transaction.amount',
|
||||
'LedgerEntry.account_id');
|
||||
// Very specific case here... no extra conditions
|
||||
unset($lquery['conditions']);
|
||||
$lquery = array
|
||||
('contain' => array
|
||||
('LedgerEntry' =>
|
||||
array('conditions' =>
|
||||
//array(LedgerEntry.'crdr'=>'DEBIT'),
|
||||
array('LedgerEntry.account_id !=' =>
|
||||
$this->LedgerEntry->Account->accountReceivableAccountID()),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$this->Transaction->id = $receipt_id;
|
||||
$receipt_credit = $this->Transaction->find('first', $lquery);
|
||||
if (!$receipt_credit)
|
||||
|
||||
Reference in New Issue
Block a user