mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[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.
This commit is contained in:
parent
4903a3e8ce
commit
d861c65020
@ -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)
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user