Guard against divide-by-zero errors.

This commit is contained in:
John Ralls 2018-08-27 18:00:55 -07:00
parent 4e88b8cb6c
commit fe73f52bdb
2 changed files with 14 additions and 11 deletions

View File

@ -193,11 +193,12 @@
(second foreignlist)
GNC-DENOM-AUTO
GNC-DENOM-LCD))
(gnc-numeric-div
total-domestic
total-foreign
GNC-DENOM-AUTO
(logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND)))))))
(if (not (zero? total-foreign))
(gnc-numeric-div
total-domestic
total-foreign
GNC-DENOM-AUTO
(logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND)) 0))))))
;; Get all the interesting splits, and sort them according to the
;; date.
(gnc:get-match-commodity-splits-sorted
@ -295,11 +296,12 @@
(gnc-commodity-numeric->string
report-currency (gnc-numeric-zero)))
(gnc-numeric-zero))
(gnc-numeric-div
(second foreignlist)
(third foreignlist)
GNC-DENOM-AUTO
(logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND))))))
(if (not (zero? (third foreignlist)))
(gnc-numeric-div
(second foreignlist)
(third foreignlist)
GNC-DENOM-AUTO
(logior (GNC-DENOM-SIGFIGS 8) GNC-RND-ROUND)) 0)))))
;; Get all the interesting splits, sorted by date.
(gnc:get-match-commodity-splits-sorted
currency-accounts

View File

@ -203,10 +203,11 @@
(begin
(xaccSplitSetMemo split-1 memo)
(xaccSplitSetMemo split-2 memo)))
(if (> amount2 0)
(gnc-pricedb-create (xaccAccountGetCommodity debit)
(xaccAccountGetCommodity credit)
(gnc-dmy2time64 DD MM YY)
(/ amount1 amount2))
(/ amount1 amount2)))
(xaccTransCommitEdit txn)
txn))