gnucash maint: Use gnc_numeric_multiply instead of Guile's * form for computing prices.

John Ralls jralls at code.gnucash.org
Sat Feb 4 12:44:09 EST 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/1c09adec (commit)
	from  https://github.com/Gnucash/gnucash/commit/ce3447e6 (commit)



commit 1c09adec87314f643ad7c3f7fc92a694a028ab7e
Author: John Ralls <jralls at ceridwen.us>
Date:   Sat Feb 4 09:36:46 2023 -0800

    Use gnc_numeric_multiply instead of Guile's * form for computing prices.
    
    Partly fixes bug 798550 (https://bugs.gnucash.org/show_bug.cgi?id=798550)
    
    Guile's * form when applied to rationals doesn't reduce and since
    guile uses gmp for unlimited precision arithmetic produces numbers
    that can't be passed back to C functions because they're too big for
    any normal C integer types.

diff --git a/gnucash/report/commodity-utilities.scm b/gnucash/report/commodity-utilities.scm
index 2ca72f09c..9eb6f6028 100644
--- a/gnucash/report/commodity-utilities.scm
+++ b/gnucash/report/commodity-utilities.scm
@@ -700,7 +700,8 @@
                (gnc:make-gnc-monetary
                 domestic
                 (if pair
-                    (* (gnc:gnc-monetary-amount foreign) (cadr pair))
+                    (gnc-numeric-mul (gnc:gnc-monetary-amount foreign) (cadr pair)
+                                     GNC-DENOM-AUTO GNC-RND-ROUND)
                     0)))))))
 
 ;; This is another ready-to-use function for calculation of exchange
@@ -780,7 +781,9 @@
                   (plist (assoc-ref pricealist foreign-comm))
                   (price (and plist
                               (gnc:pricelist-price-find-nearest plist date))))
-             (gnc:make-gnc-monetary domestic (* foreign-amt (or price 0)))))))
+             (gnc-numeric_mul (gnc:make-gnc-monetary domestic)
+                              (gnc:make-gnc-monetary foreign-amt (or price 0))
+                              GNC-DENOM-AUTO GNC-RND-ROUND)))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



Summary of changes:
 gnucash/report/commodity-utilities.scm | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)



More information about the gnucash-changes mailing list