Changed the deposit to use a grouped double entry instead of individual ones for each tender deposited
git-svn-id: file:///svn-source/pmgr/branches/yafr_20090716@414 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -112,11 +112,6 @@ class Transaction extends AppModel {
|
||||
$deposit['customer_id'] = null;
|
||||
$deposit['lease_id'] = null;
|
||||
|
||||
// Go through the statement entries and flag as credits
|
||||
foreach ($data['Entry'] AS &$entry) {
|
||||
$entry['crdr'] = 'CREDIT';
|
||||
}
|
||||
|
||||
// For some reason, $data is being modified by the
|
||||
// addTransaction call, even though we're not passing by
|
||||
// reference. Not all items in $data['Entry'] are being
|
||||
@@ -131,6 +126,18 @@ class Transaction extends AppModel {
|
||||
'return $item["tender_id"];'),
|
||||
$data['Entry']);
|
||||
|
||||
// Go through the statement entries and re-group by account id
|
||||
$group = array();
|
||||
foreach ($data['Entry'] AS &$entry) {
|
||||
if (!isset($group[$entry['account_id']]))
|
||||
$group[$entry['account_id']] =
|
||||
array('account_id' => $entry['account_id'],
|
||||
'crdr' => 'CREDIT',
|
||||
'amount' => 0);
|
||||
$group[$entry['account_id']]['amount'] += $entry['amount'];
|
||||
}
|
||||
$data['Entry'] = $group;
|
||||
|
||||
$ids = $this->addTransaction($data);
|
||||
if (isset($ids['transaction_id']))
|
||||
$ids['deposit_id'] = $ids['transaction_id'];
|
||||
@@ -251,7 +258,7 @@ class Transaction extends AppModel {
|
||||
|
||||
function addTransaction($data) {
|
||||
/* pr(array("Transaction::addTransaction()" */
|
||||
/* => compact('data', 'customer_id', 'lease_id'))); */
|
||||
/* => compact('data'))); */
|
||||
|
||||
// Verify that we have a transaction and entries
|
||||
if (empty($data['Transaction']) || empty($data['Entry']))
|
||||
@@ -353,7 +360,8 @@ class Transaction extends AppModel {
|
||||
foreach ($data['Entry'] AS $e_index => &$entry) {
|
||||
extract($entry);
|
||||
$le1['transaction_id'] = $le2['transaction_id'] = $ret['transaction_id'];
|
||||
$le1_tender['customer_id'] = $transaction['customer_id'];
|
||||
if (isset($le1_tender))
|
||||
$le1_tender['customer_id'] = $transaction['customer_id'];
|
||||
$result = $this->LedgerEntry->DoubleEntry->addDoubleEntry($le1, $le2, $le1_tender);
|
||||
$ret['entries'][$e_index]['DoubleEntry'] = $result;
|
||||
if ($result['error']) {
|
||||
|
||||
Reference in New Issue
Block a user