From b155f8928c6a33af42f859b27c83639b72517f5e Mon Sep 17 00:00:00 2001 From: Christoph Dittmann Date: Sat, 30 Jan 2021 14:32:17 +0100 Subject: compare_by_commodity: Always return the result of the recursive call Commit 501fbc08ae5493db77bb34f4c4fbe1f3a3bc14e3 changed the behavior of this function to not return the "equal" result (==0) from the recursive call. Previously, the function returned the result of the recursive call unconditionally. The current behavior causes an assertion error for certain postings. The regression test added in this commit shows such a posting. I found through Travis CI that the old behavior was incomplete and caused unstable orderings, so reverting to the old behavior doesn't work. Instead, this change adds a fallback: If the recursive call that compares the prices numerically returns "equal", then compare the prices with their original commodity as a tie breaker. This commit does not change any existing ordering, it only adds deterministic ordering in a case that currently triggers an assertion error. This fixes issue #1998. --- test/regress/1998.test | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 test/regress/1998.test (limited to 'test/regress') diff --git a/test/regress/1998.test b/test/regress/1998.test new file mode 100644 index 00000000..e5fbdeda --- /dev/null +++ b/test/regress/1998.test @@ -0,0 +1,14 @@ +2021-01-02 Same commodity, different values + Assets -1 Stock {100 USD} [2021-01-01] + Assets 1 Stock {100 EUR} [2021-01-01] + Equity + +test bal --lots +1 Stock {EUR100} [2021/01/01] +-1 Stock {USD100} [2021/01/01] Assets +-1 Stock {EUR100} [2021/01/01] +1 Stock {USD100} [2021/01/01] Equity +-------------------- + 0 +end test + -- cgit v1.2.3