Skip to content

Commit

Permalink
Save Changes Bug 776517 - Trial Balance Report:...
Browse files Browse the repository at this point in the history
Total Debits Issue re $0 Commodity Accounts and Price Source Mode Set to
"Nearest in Time" or "Most Recent"

There was a silent error from gnc-numeric-sub-fixed in
collect-unrealized-gains because a 0 value wasn't getting its
denominator set in the gnc-numeric-mul call in
gnc:exchange-by-pricedb-helper. While this is ultimately a flaw in
gnc-numeric, this commit works around it by forcing the value to the
correct denom in gnc:make-commodity-collector.
  • Loading branch information
jralls committed Mar 22, 2017
1 parent f9ca29a commit 52bb6b5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/report/report-system/report-utilities.scm
Expand Up @@ -332,15 +332,18 @@
;; If no pair with this commodity exists, we will create one.
(define (add-commodity-value commodity value)
;; lookup the corresponding pair
(let ((pair (assoc commodity commoditylist)))
(let ((pair (assoc commodity commoditylist))
(rvalue (gnc-numeric-convert
value
(gnc-commodity-get-fraction commodity) GNC-RND-ROUND)))
(if (not pair)
(begin
;; create a new pair, using the gnc:numeric-collector
(set! pair (list commodity (gnc:make-numeric-collector)))
;; and add it to the alist
(set! commoditylist (cons pair commoditylist))))
;; add the value
(gnc:numeric-collector-add (cadr pair) value)))
(gnc:numeric-collector-add (cadr pair) rvalue)))

;; helper function to walk an association list, adding each
;; (commodity -> collector) pair to our list at the appropriate
Expand Down

0 comments on commit 52bb6b5

Please sign in to comment.