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/site@307 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -498,7 +498,7 @@ class Account extends AppModel {
|
|||||||
// Create some models for convenience
|
// Create some models for convenience
|
||||||
$A = new Account();
|
$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
|
// Automatically figure out the customer if we have the lease
|
||||||
if (isset($entry_data['lease_id']) && !isset($entry_data['customer_id'])) {
|
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'])) {
|
if (isset($transaction_data['transaction_id'])) {
|
||||||
$transaction_data
|
$transaction_data
|
||||||
= array_intersect_key($transaction_data,
|
= array_intersect_key($transaction_data,
|
||||||
array('transaction_id'=>1));
|
array('transaction_id'=>1,
|
||||||
|
'split_transaction_id'=>1));
|
||||||
}
|
}
|
||||||
elseif (isset($transaction_data['Transaction'])) {
|
elseif (isset($transaction_data['Transaction'])) {
|
||||||
$transaction_data
|
$transaction_data
|
||||||
= array_intersect_key($transaction_data,
|
= array_intersect_key($transaction_data,
|
||||||
array('Transaction'=>1));
|
array('Transaction'=>1,
|
||||||
|
'split_transaction_id'=>1));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$transaction_data = array('Transaction'=>array('stamp' => null));
|
$transaction_data = array('Transaction'=>array('stamp' => null));
|
||||||
@@ -647,13 +649,18 @@ class Account extends AppModel {
|
|||||||
$this->fundamentalOpposite($dc_type),
|
$this->fundamentalOpposite($dc_type),
|
||||||
$entry_data['amount']);
|
$entry_data['amount']);
|
||||||
|
|
||||||
pr(array("reconcile receipt",
|
/* pr(array("reconcile receipt", */
|
||||||
compact('reconciled', 'split_transaction', 'transaction_data')));
|
/* compact('reconciled', 'split_transaction', 'transaction_data'))); */
|
||||||
$split_transaction = array_intersect_key($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'])) {
|
if (is_array($reconciled) && count($reconciled[$dc_type]['entry'])) {
|
||||||
foreach ($reconciled[$dc_type]['entry'] AS $rec) {
|
foreach ($reconciled[$dc_type]['entry'] AS $rec) {
|
||||||
//.pr(compact('rec'));
|
//pr(compact('rec', 'split_transaction'));
|
||||||
if (!$rec['applied'])
|
if (!$rec['applied'])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -679,12 +686,17 @@ class Account extends AppModel {
|
|||||||
);
|
);
|
||||||
// Keep using the same split transaction for all reconciled entries
|
// Keep using the same split transaction for all reconciled entries
|
||||||
$split_transaction = array_intersect_key($ids, array('transaction_id'=>1));
|
$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)) {
|
if (is_array($reconcile_set)) {
|
||||||
|
//pr("reconcile_set is array");
|
||||||
foreach ($reconcile_set AS $reconcile_entry) {
|
foreach ($reconcile_set AS $reconcile_entry) {
|
||||||
if (!isset($reconcile_entry['LedgerEntry']['id']))
|
if (!isset($reconcile_entry['LedgerEntry']['id']))
|
||||||
continue;
|
continue;
|
||||||
@@ -716,10 +728,16 @@ class Account extends AppModel {
|
|||||||
$new_entry->read();
|
$new_entry->read();
|
||||||
//pr(array('post-save', $entry->data));
|
//pr(array('post-save', $entry->data));
|
||||||
|
|
||||||
return array('error' => $err,
|
$ret = array
|
||||||
'id' => $new_entry->data['LedgerEntry']['id'],
|
('error' => $err,
|
||||||
'transaction_id' => $new_entry->data['LedgerEntry']['transaction_id'],
|
'id' => $new_entry->data['LedgerEntry']['id'],
|
||||||
'monetary_source_id' => $new_entry->data['LedgerEntry']['monetary_source_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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,9 @@ class Transaction extends AppModel {
|
|||||||
if ($ids['error'])
|
if ($ids['error'])
|
||||||
$ret = false;
|
$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;
|
return $ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user