diff --git a/src/engine/Scrub2.c b/src/engine/Scrub2.c index 3e71cd49c1..4c9b6a7633 100644 --- a/src/engine/Scrub2.c +++ b/src/engine/Scrub2.c @@ -344,7 +344,7 @@ merge_splits (Split *sa, Split *sb) } gboolean -xaccScrubMergeSubSplits (Split *split) +xaccScrubMergeSubSplits (Split *split, gboolean strict) { gboolean rc = FALSE; Transaction *txn; @@ -352,7 +352,7 @@ xaccScrubMergeSubSplits (Split *split) GNCLot *lot; const GncGUID *guid; - if (FALSE == is_subsplit (split)) return FALSE; + if (strict && (FALSE == is_subsplit (split))) return FALSE; txn = split->parent; lot = xaccSplitGetLot (split); @@ -392,7 +392,7 @@ restart: } gboolean -xaccScrubMergeLotSubSplits (GNCLot *lot) +xaccScrubMergeLotSubSplits (GNCLot *lot, gboolean strict) { gboolean rc = FALSE; SplitList *node; @@ -404,7 +404,7 @@ restart: for (node = gnc_lot_get_split_list(lot); node; node = node->next) { Split *s = node->data; - if (!xaccScrubMergeSubSplits(s)) continue; + if (!xaccScrubMergeSubSplits(s, strict)) continue; rc = TRUE; goto restart; diff --git a/src/engine/Scrub2.h b/src/engine/Scrub2.h index 6ab0ed076d..61527d9b7a 100644 --- a/src/engine/Scrub2.h +++ b/src/engine/Scrub2.h @@ -89,19 +89,26 @@ void xaccLotScrubDoubleBalance (GNCLot *lot); * the same lot, or in no lot. Note that, by definition, all * subsplits belong to the same transaction. * + * There are two ways to find matching subsplits. The first + * way will consider splits to be subsplits only if they + * are explicitly marked as such while splitting the original + * split. Set strict to TRUE for this matching algorhythm. + * + * The second way is more relaxed. It will consider any two + * splits that happen to be part of the same lot and the + * same transaction to be subsplits. Set strict to FALSE for + * this matching algorhythm. + * * The routine returns TRUE if a merger was performed, else * it returns FALSE. - * - * The xaccScrubMergeTransSubSplits() routine does the same, except - * that it does it for all of the splits in the transaction. */ -gboolean xaccScrubMergeSubSplits (Split *split); +gboolean xaccScrubMergeSubSplits (Split *split, gboolean strict); /** The xaccScrubMergeLotSubSplits() routine does the same as * the xaccScrubMergSubSplits, except that it does it * for all of the splits in the lot. */ -gboolean xaccScrubMergeLotSubSplits (GNCLot *lot); +gboolean xaccScrubMergeLotSubSplits (GNCLot *lot, gboolean strict); #endif /* XACC_SCRUB2_H */ /** @} */ diff --git a/src/engine/Scrub3.c b/src/engine/Scrub3.c index 1890f308a9..c4c49321dd 100644 --- a/src/engine/Scrub3.c +++ b/src/engine/Scrub3.c @@ -96,7 +96,7 @@ xaccScrubLot (GNCLot *lot) acc = gnc_lot_get_account (lot); pcy = gnc_account_get_policy(acc); xaccAccountBeginEdit(acc); - xaccScrubMergeLotSubSplits (lot); + xaccScrubMergeLotSubSplits (lot, TRUE); /* If the lot balance is zero, we don't need to rebalance */ lot_baln = gnc_lot_get_balance (lot); @@ -132,7 +132,7 @@ rethin: xaccLotFill (lot); /* Make sure there are no subsplits. */ - splits_deleted = xaccScrubMergeLotSubSplits (lot); + splits_deleted = xaccScrubMergeLotSubSplits (lot, TRUE); } /* Now re-compute cap gains, and then double-check that.