gnucash master: [account-piecharts] round account->balance to report-currency SCU

Christopher Lam clam at code.gnucash.org
Sat Jul 4 09:31:52 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/1acd2bea (commit)
	from  https://github.com/Gnucash/gnucash/commit/207616ab (commit)



commit 1acd2beacb6a6f12c4b77460cfae185ea706f8ad
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Jul 4 15:07:37 2020 +0800

    [account-piecharts] round account->balance to report-currency SCU

diff --git a/gnucash/report/reports/standard/account-piecharts.scm b/gnucash/report/reports/standard/account-piecharts.scm
index c65fac183..c8dc53b96 100644
--- a/gnucash/report/reports/standard/account-piecharts.scm
+++ b/gnucash/report/reports/standard/account-piecharts.scm
@@ -418,30 +418,30 @@ balance at a given time"))
            (other-anchor "")
            (print-info (gnc-commodity-print-info report-currency #t)))
 
-      ;; Converts a commodity-collector into one single double
+      ;; Converts a commodity-collector into one single inexact
       ;; number, depending on the report's currency and the
       ;; exchange-fn calculated above. Returns the absolute value
-      ;; as double, multiplied by the averaging-multiplies (smaller
-      ;; than one; multiplication instead of division to avoid
-      ;; division-by-zero issues) in case the user wants to see the
-      ;; amounts averaged over some value.
-      (define (collector->double c)
+      ;; multiplied by the averaging-multiplier (smaller than one;
+      ;; multiplication instead of division to avoid division-by-zero
+      ;; issues) in case the user wants to see the amounts averaged
+      ;; over some value.
+      (define (collector->amount c)
         ;; Future improvement: Let the user choose which kind of
         ;; currency combining she want to be done. Right now
         ;; everything foreign gets converted
         ;; (gnc:sum-collector-commodity) based on the average
         ;; cost of all holdings.
-        (*
-         (gnc:gnc-monetary-amount
-          (gnc:sum-collector-commodity
-           c report-currency
-           exchange-fn))
-         averaging-multiplier))
-
-      ;; Get balance of an account as double number, already converted
-      ;; to the report's currency.
+        (gnc-numeric-convert
+         (* (gnc:gnc-monetary-amount
+             (gnc:sum-collector-commodity c report-currency exchange-fn))
+            averaging-multiplier)
+         (gnc-commodity-get-fraction report-currency)
+         GNC-RND-ROUND))
+
+      ;; Get balance of an account as an inexact number converted to,
+      ;; and using precision of the report's currency.
       (define (account-balance a subaccts?)
-        (collector->double (profit-fn a subaccts?)))
+        (collector->amount (profit-fn a subaccts?)))
 
       (define (count-accounts current-depth accts)
 	(if (< current-depth tree-depth)



Summary of changes:
 .../report/reports/standard/account-piecharts.scm  | 32 +++++++++++-----------
 1 file changed, 16 insertions(+), 16 deletions(-)



More information about the gnucash-changes mailing list