gnucash maint: [test-engine-extras] don't create splits of opposing amt/value signs
Christopher Lam
clam at code.gnucash.org
Sun Nov 21 10:38:39 EST 2021
Updated via https://github.com/Gnucash/gnucash/commit/d861c650 (commit)
from https://github.com/Gnucash/gnucash/commit/4903a3e8 (commit)
commit d861c65020a018d7d690782a599f4d23fab0407f
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sun Nov 21 23:25:18 2021 +0800
[test-engine-extras] don't create splits of opposing amt/value signs
Splits' value and amount should never be of opposite signs. Fix
test book which had created this incorrect value/amount
pair. Strengthen env-create-multisplit-transaction to disallow
test book errors.
diff --git a/bindings/guile/test/test-engine-extras.scm b/bindings/guile/test/test-engine-extras.scm
index b873e0d15..7b12a18d8 100644
--- a/bindings/guile/test/test-engine-extras.scm
+++ b/bindings/guile/test/test-engine-extras.scm
@@ -223,6 +223,9 @@
#:memo memo
#:notes notes))
+(define (opposite-signs? a b)
+ (< (* a b) 0))
+
;; creates multisplit transaction.
;;
;; input: DD/MM/YY - posting date of transaction
@@ -262,6 +265,9 @@
(action (and (> (vector-length split) 3)
(vector-ref split 3)))
(newsplit (xaccMallocSplit book)))
+ (when (opposite-signs? val amt)
+ (error "env-create-multisplit-transaction error for" DD '/ MM '/ YY
+ 'opposing-signs: 'val val 'amt amt))
(xaccSplitSetParent newsplit txn)
(xaccSplitSetAccount newsplit acc)
(xaccSplitSetValue newsplit val)
diff --git a/gnucash/report/reports/standard/test/test-ifrs-cost-basis.scm b/gnucash/report/reports/standard/test/test-ifrs-cost-basis.scm
index fee392dc3..a37ed1d34 100644
--- a/gnucash/report/reports/standard/test/test-ifrs-cost-basis.scm
+++ b/gnucash/report/reports/standard/test/test-ifrs-cost-basis.scm
@@ -139,7 +139,7 @@
(env-create-multisplit-transaction
env 16 04 2020
- (list (vector usd-cash 2500 -2500)
+ (list (vector usd-cash 2500 2500)
(vector spy -2500 0 "Buy")
)
#:description "Return of Capital"
diff --git a/gnucash/report/test/test-commodity-utils.scm b/gnucash/report/test/test-commodity-utils.scm
index 89b40454a..a8e609906 100644
--- a/gnucash/report/test/test-commodity-utils.scm
+++ b/gnucash/report/test/test-commodity-utils.scm
@@ -167,7 +167,7 @@
#:description "Buy MSFT 1500") ;;1500 @ $28.11
(env-transfer-foreign env 20 01 2012 checking-dem dmlr-a 1500 80
#:description "Buy DMLR 80") ;;80 @ DM1500.00
- (env-transfer-foreign env 20 02 2012 checking-dem dmlr-a -1610 80
+ (env-transfer-foreign env 20 02 2012 checking-dem dmlr-a -1610 -80
#:description "Sell DMLR 80") ;;80 @ DM1610.00
(env-transfer-foreign env 20 02 2012 capgain-dem dmlr-a 110 0
#:description "DMLR 80 G/L") ;;80 @ DM1610.00
Summary of changes:
bindings/guile/test/test-engine-extras.scm | 6 ++++++
gnucash/report/reports/standard/test/test-ifrs-cost-basis.scm | 2 +-
gnucash/report/test/test-commodity-utils.scm | 2 +-
3 files changed, 8 insertions(+), 2 deletions(-)
More information about the gnucash-changes
mailing list