mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
changes to accomodate the new engine layout
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@776 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
3acb6bab8f
commit
9e84712b97
@ -132,14 +132,14 @@ xaccFreeAccount( Account *acc )
|
|||||||
Transaction *trans = (Transaction *) s->parent;
|
Transaction *trans = (Transaction *) s->parent;
|
||||||
|
|
||||||
j=0;
|
j=0;
|
||||||
debit_s = trans->dest_splits[0];
|
debit_s = trans->splits[0];
|
||||||
while (debit_s) {
|
while (debit_s) {
|
||||||
if (debit_s->acc) { dont_free_transaction = 1; break; }
|
if (debit_s->acc) { dont_free_transaction = 1; break; }
|
||||||
j++;
|
j++;
|
||||||
debit_s = trans->dest_splits[j];
|
debit_s = trans->splits[j];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (!dont_free_transaction) && (NULL == trans->source_split.acc) ) {
|
if (!dont_free_transaction) {
|
||||||
xaccFreeTransaction( trans );
|
xaccFreeTransaction( trans );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -490,16 +490,13 @@ xaccCheckTransDateOrder (Transaction *trans )
|
|||||||
|
|
||||||
if (NULL == trans) return 0;
|
if (NULL == trans) return 0;
|
||||||
|
|
||||||
acc = (Account *) (trans->source_split.acc);
|
|
||||||
outOfOrder += xaccCheckDateOrder (acc, &(trans->source_split));
|
|
||||||
|
|
||||||
i=0;
|
i=0;
|
||||||
s = trans->dest_splits[0];
|
s = trans->splits[0];
|
||||||
while (s) {
|
while (s) {
|
||||||
acc = (Account *) (s->acc);
|
acc = (Account *) (s->acc);
|
||||||
outOfOrder += xaccCheckDateOrder (acc, s);
|
outOfOrder += xaccCheckDateOrder (acc, s);
|
||||||
i++;
|
i++;
|
||||||
s = trans->dest_splits[i];
|
s = trans->splits[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outOfOrder) return 1;
|
if (outOfOrder) return 1;
|
||||||
@ -573,49 +570,47 @@ xaccMoveFarEnd (Split *split, Account *new_acc)
|
|||||||
Split *partner_split = 0x0;
|
Split *partner_split = 0x0;
|
||||||
Transaction *trans;
|
Transaction *trans;
|
||||||
Account * acc;
|
Account * acc;
|
||||||
int create_far_end = 0;
|
int numsplits = 0;
|
||||||
|
|
||||||
if (!split) return;
|
if (!split) return;
|
||||||
|
|
||||||
/* if the new desitnation does not match the current dest,
|
/* if the transaction has two splits, then the "far end"
|
||||||
|
* is the other one. Otherwise, fare end is undefined.
|
||||||
|
* If the new destination does not match the current dest,
|
||||||
* then move the far end of the split to the new location.
|
* then move the far end of the split to the new location.
|
||||||
*/
|
*/
|
||||||
trans = (Transaction *) (split->parent);
|
trans = (Transaction *) (split->parent);
|
||||||
if (split != &(trans->source_split)) {
|
assert (trans);
|
||||||
partner_split = &(trans->source_split);
|
assert (trans->splits);
|
||||||
} else {
|
|
||||||
/* perform that transfer *only* if there is one split */
|
|
||||||
if (trans->dest_splits) {
|
|
||||||
if (0x0 != trans->dest_splits[0]) {
|
|
||||||
if (0x0 == trans->dest_splits[1]) {
|
|
||||||
partner_split = trans->dest_splits[0];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* Gosh, the far end doesn't exist! create it! */
|
|
||||||
create_far_end = 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* Gosh, the far end doesn't exist! create it! */
|
|
||||||
create_far_end = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
numsplits = xaccCountSplits (trans->splits);
|
||||||
|
if (2 < numsplits) return;
|
||||||
|
|
||||||
|
if (split == trans->splits[0]) {
|
||||||
|
partner_split = trans->splits [1];
|
||||||
|
} else
|
||||||
|
|
||||||
|
if (split == trans->splits[1]) {
|
||||||
|
partner_split = trans->splits [0];
|
||||||
|
} else
|
||||||
|
|
||||||
|
if (new_acc) {
|
||||||
/* Gosh, the far end doesn't exist! create it! */
|
/* Gosh, the far end doesn't exist! create it! */
|
||||||
if (create_far_end && new_acc) {
|
|
||||||
partner_split = xaccMallocSplit ();
|
partner_split = xaccMallocSplit ();
|
||||||
xaccTransAppendSplit (trans, partner_split);
|
xaccTransAppendSplit (trans, partner_split);
|
||||||
xaccAccountInsertSplit (new_acc, partner_split);
|
xaccAccountInsertSplit (new_acc, partner_split);
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
/* no partner split, AND no far-end accouont. return */
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (partner_split) {
|
|
||||||
/* remove the partner split from the old account */
|
/* remove the partner split from the old account */
|
||||||
acc = (Account *) (partner_split->acc);
|
acc = (Account *) (partner_split->acc);
|
||||||
if (acc != new_acc) {
|
if (acc != new_acc) {
|
||||||
xaccAccountRemoveSplit (acc, partner_split);
|
xaccAccountRemoveSplit (acc, partner_split);
|
||||||
xaccAccountInsertSplit (new_acc, partner_split);
|
xaccAccountInsertSplit (new_acc, partner_split);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************\
|
/********************************************************************\
|
||||||
|
@ -85,11 +85,11 @@ void xaccConsolidateTransactions (Account *);
|
|||||||
/* The xaccMoveFarEnd() method changes the account to which the
|
/* The xaccMoveFarEnd() method changes the account to which the
|
||||||
* "far end" of the split belongs. The "far end" is as follows:
|
* "far end" of the split belongs. The "far end" is as follows:
|
||||||
* Double-entry transactions by thier nature consist of a set of
|
* Double-entry transactions by thier nature consist of a set of
|
||||||
* splits, each split indicating a debited or credited account.
|
* two or more splits. If the transaction has precisely two splits,
|
||||||
* Given a debit split, the "far end" is the account indicated
|
* then the "far end" is the "other split" of the pair. If
|
||||||
* by the credit split. Given a credit split, the "far end"
|
* the transaction consists of three or more splits, then the
|
||||||
* is the debit split, if there is only one debit split, otherwise
|
* "far end" is undefined. All that the xaccMoveFareEnd() method
|
||||||
* there is no far end. This subroutine will change the "far end".
|
* does is reparent the "other split" to the indicated account.
|
||||||
* The first argument is the split whose fare end will be changed,
|
* The first argument is the split whose fare end will be changed,
|
||||||
* the second argument is the new far-end account.
|
* the second argument is the new far-end account.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user