Not terribly happy with the solution to the extra transactions problem noted on the last checkin (however, it does seem to be working). I simply keep a record of the split transaction id, pass it back to the caller, and expect it to be passed back in. Works for now, even if it isn't terribly elegant.

git-svn-id: file:///svn-source/pmgr/branches/invoice_receipt_20090629@307 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
abijah
2009-07-11 08:10:23 +00:00
parent e067af589c
commit 860006ed38
2 changed files with 33 additions and 13 deletions

View File

@@ -498,7 +498,7 @@ class Account extends AppModel {
// Create some models for convenience
$A = new Account();
pr(compact('transaction_data', 'monetary_data', 'entry_data', 'reconcile'));
//pr(compact('transaction_data', 'monetary_data', 'entry_data', 'reconcile'));
// Automatically figure out the customer if we have the lease
if (isset($entry_data['lease_id']) && !isset($entry_data['customer_id'])) {
@@ -518,12 +518,14 @@ class Account extends AppModel {
if (isset($transaction_data['transaction_id'])) {
$transaction_data
= array_intersect_key($transaction_data,
array('transaction_id'=>1));
array('transaction_id'=>1,
'split_transaction_id'=>1));
}
elseif (isset($transaction_data['Transaction'])) {
$transaction_data
= array_intersect_key($transaction_data,
array('Transaction'=>1));
array('Transaction'=>1,
'split_transaction_id'=>1));
}
else {
$transaction_data = array('Transaction'=>array('stamp' => null));
@@ -647,13 +649,18 @@ class Account extends AppModel {
$this->fundamentalOpposite($dc_type),
$entry_data['amount']);
pr(array("reconcile receipt",
compact('reconciled', 'split_transaction', 'transaction_data')));
/* pr(array("reconcile receipt", */
/* compact('reconciled', 'split_transaction', 'transaction_data'))); */
$split_transaction = array_intersect_key($transaction_data,
array('Transaction'=>1));
array('Transaction'=>1,
'split_transaction_id'=>1));
if (isset($split_transaction['split_transaction_id']))
$split_transaction['transaction_id'] = $split_transaction['split_transaction_id'];
if (is_array($reconciled) && count($reconciled[$dc_type]['entry'])) {
foreach ($reconciled[$dc_type]['entry'] AS $rec) {
//.pr(compact('rec'));
//pr(compact('rec', 'split_transaction'));
if (!$rec['applied'])
continue;
@@ -679,12 +686,17 @@ class Account extends AppModel {
);
// Keep using the same split transaction for all reconciled entries
$split_transaction = array_intersect_key($ids, array('transaction_id'=>1));
pr(compact('ids', 'split_transaction'));
//pr(compact('ids', 'split_transaction'));
}
//pr("end reconciled is array");
}
//pr("end reconcile receipt");
}
if (is_array($reconcile_set)) {
//pr("reconcile_set is array");
foreach ($reconcile_set AS $reconcile_entry) {
if (!isset($reconcile_entry['LedgerEntry']['id']))
continue;
@@ -716,10 +728,16 @@ class Account extends AppModel {
$new_entry->read();
//pr(array('post-save', $entry->data));
return array('error' => $err,
'id' => $new_entry->data['LedgerEntry']['id'],
'transaction_id' => $new_entry->data['LedgerEntry']['transaction_id'],
'monetary_source_id' => $new_entry->data['LedgerEntry']['monetary_source_id']);
$ret = array
('error' => $err,
'id' => $new_entry->data['LedgerEntry']['id'],
'transaction_id' => $new_entry->data['LedgerEntry']['transaction_id'],
'monetary_source_id' => $new_entry->data['LedgerEntry']['monetary_source_id']);
if (isset($split_transaction['transaction_id']))
$ret['split_transaction_id'] = $split_transaction['transaction_id'];
return $ret;
}

View File

@@ -108,7 +108,9 @@ class Transaction extends AppModel {
if ($ids['error'])
$ret = false;
$receipt_transaction = array_intersect_key($ids, array('transaction_id'=>1));
$receipt_transaction = array_intersect_key($ids,
array('transaction_id'=>1,
'split_transaction_id'=>1));
}
return $ret;