gnucash stable: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Sat Oct 3 20:48:27 EDT 2026


Updated	 via  https://github.com/Gnucash/gnucash/commit/f6a134b6 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/22e9ff9a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5a4115d3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1e27fd17 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/872612a2 (commit)
	from  https://github.com/Gnucash/gnucash/commit/80c4377b (commit)



commit f6a134b6d8cc4b49c4fee3f58bdfeb3347460d3d
Merge: 80c4377b04 22e9ff9a49
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Oct 3 17:44:01 2026 -0700

    Merge Brent McBride's 'fix-lot-scrub-orphaned-gains' into stable

commit 22e9ff9a49b60ac4595b6a061a8835ca2e61aa00
Author: Brent McBride <mcbridebt at hotmail.com>
Date:   Fri Oct 2 20:57:00 2026 -0700

    Use xaccAccountGetSplitsSize in cap-gains regression test
    
    Per review: faster than g_list_length(xaccAccountGetSplitList()) and
    avoids leaking the returned list.

commit 5a4115d37041161361cf6be70411ecaad6814f3c
Author: Brent McBride <mcbridebt at hotmail.com>
Date:   Fri Oct 2 15:15:00 2026 -0700

    Resolve both gains splits in xaccSplitDetermineGainStatus
    
    Rework xaccSplitDetermineGainStatus() to resolve the gain status of
    both ends of a marker/source pair in a single call, and to use the
    xaccSplitGetGainsSourceSplit() accessor instead of a raw KVP lookup.
    
    When the function resolves one split it now also resolves its partner
    (the source for a marker, the marker for a source) if that partner is
    still UNKNOWN. This makes gain-status resolution order-independent:
    whichever split xaccSplitComputeCapGains() reaches first, the other is
    already resolved, so the marker->source switch-over no longer finds an
    unresolved source and never re-creates an orphaned gains split.
    
    This supersedes the one-line switch-over patch in cap-gains.cpp, which
    is reverted.

commit 1e27fd17dcd73f30e1c78d665deb83bdddcb2811
Author: Brent McBride <mcbridebt at hotmail.com>
Date:   Fri Oct 2 10:40:54 2026 -0700

    Add regression test for cap-gains marker/source switch-over
    
    Builds a FIFO lot (buy + sell) with a pre-existing Realized Gain/Loss
    transaction and the gains-split/gains-source KVP links, then simulates
    a just-loaded state where the gains marker reaches
    xaccSplitComputeCapGains() before its source is resolved (the order
    that reproduces on MySQL and is masked on SQLite). Asserts the existing
    gains split is reused rather than duplicated into an orphan.
    
    Fails (2 != 1) without the switch-over resolve fix, passes with it.

commit 872612a26be10cfa8c575ae7098b23c5888ca444
Author: Brent McBride <mcbridebt at hotmail.com>
Date:   Fri Oct 2 00:30:39 2026 -0700

    Fix mass re-orphaning of cap-gains splits during lot scrub
    
    xaccSplitComputeCapGains() performs a marker->source switch-over when a
    gains marker split is processed before its source. The switch-over did
    not resolve the source's in-memory gain status, so the source was left
    with gains==UNKNOWN and gains_split==nullptr even though its forward
    gains-split KVP was intact. The subsequent lookup read nullptr and the
    code created a brand-new gains transaction routed to Orphaned Gains,
    duplicating hundreds of already-settled gains splits on SQL books whose
    history contains a stock split.
    
    Resolve the source's gain status immediately after the switch-over so
    its existing gains split is reused instead of being re-created.
    
    This latent bug (original cap-gains code, ~2003) was exposed by the
    5.17 adjusted_amount work (1e654412ab, b1efe0763c) which recomputes
    already-booked gains in stock-split accounts. It is order-sensitive,
    which is why it reproduces on MySQL but not SQLite.



Summary of changes:
 libgnucash/engine/Split.cpp                  |  29 ++++--
 libgnucash/engine/test/utest-Transaction.cpp | 143 +++++++++++++++++++++++++++
 2 files changed, 163 insertions(+), 9 deletions(-)



More information about the gnucash-patches mailing list