[eguile-utilities.scm] fmtnumeric: use xaccPrintAmount

fmtnumeric is used to render Quantity, Discount percent. Previously it
would render 1/3 as 0.333333333. Use xaccPrintAmount to show exact
fractions for Qty and Discount, where appropriate.
This commit is contained in:
Christopher Lam 2023-02-18 13:00:27 +08:00
parent 2acba0ea18
commit 5acf686c76

View File

@ -34,12 +34,13 @@
(use-modules (gnucash report))
(define-public (fmtnumber n)
(issue-deprecation-warning "fmtnumber is deprecated")
;; Format a number (integer or real) into something printable
(number->string (if (integer? n) (inexact->exact n) n)))
;; Format gnc-numeric n with as many decimal places as required
;; Format gnc-numeric n with decimal places, or exact fraction
(define-public fmtnumeric
(compose fmtnumber exact->inexact))
(lambda (n) (xaccPrintAmount n (gnc-default-print-info #f))))
(define-public (gnc-monetary-neg? monetary)
;; return true if the monetary value is negative