Fix lot scrubbing for business lots

When adding splits to such a lot the code was supposed to
reduce splits in the same transaction and the same lot to
one single split. This is to avoid infinite fragmentation
over time.
That reduction wasn't working for business lots and should
be fixed with this commit.
This is also a potential fix for bug https://bugzilla.gnome.org/show_bug.cgi?id=741418
which could very well be a report of such infinite fragmentation.
This commit is contained in:
Geert Janssens 2014-12-17 18:51:39 +01:00
parent 9dc06a2f24
commit e3bef5fdc3

View File

@ -366,18 +366,21 @@ restart:
if (s == split) continue;
if (qof_instance_get_destroying(s)) continue;
/* OK, this split is in the same lot (and thus same account)
* as the indicated split. Make sure it is really a subsplit
* of the split we started with. It's possible to have two
* splits in the same lot and transaction that are not subsplits
* of each other, the test-period test suite does this, for
* example. Only worry about adjacent sub-splits. By
* repeatedly merging adjacent subsplits, we'll get the non-
* adjacent ones too. */
guid = qof_instance_get_guid(s);
if (gnc_kvp_bag_find_by_guid (split->inst.kvp_data, "lot-split",
"peer_guid", guid) == NULL)
continue;
if (strict)
{
/* OK, this split is in the same lot (and thus same account)
* as the indicated split. Make sure it is really a subsplit
* of the split we started with. It's possible to have two
* splits in the same lot and transaction that are not subsplits
* of each other, the test-period test suite does this, for
* example. Only worry about adjacent sub-splits. By
* repeatedly merging adjacent subsplits, we'll get the non-
* adjacent ones too. */
guid = qof_instance_get_guid(s);
if (gnc_kvp_bag_find_by_guid (split->inst.kvp_data, "lot-split",
"peer_guid", guid) == NULL)
continue;
}
merge_splits (split, s);
rc = TRUE;