GnuCash
Contact   Instructions
Bug 797861 - Yearly / Monthly average reporting displays zeros
Summary: Yearly / Monthly average reporting displays zeros
Status: RESOLVED FIXED
Alias: None
Product: GnuCash
Classification: Unclassified
Component: Reports (show other bugs)
Version: 4.0
Hardware: PC Mac OS
: Normal normal
Target Milestone: ---
Assignee: reports
QA Contact: reports
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-18 11:47 EDT by Greg Hamerly
Modified: 2020-07-19 10:11 EDT (History)
3 users (show)

See Also:


Attachments
Expense Chart Pie Chart with yearly averaging, showing $0.00 amounts (1.51 MB, image/png)
2020-07-18 11:47 EDT, Greg Hamerly
no flags Details

Description Greg Hamerly 2020-07-18 11:47:51 EDT
Created attachment 373791 [details]
Expense Chart Pie Chart with yearly averaging, showing $0.00 amounts

When creating an expense report, using "Yearly" or "Monthly" averaging gives (seemingly) correct percentages, but all monetary (dollar) values are $0.00.

See attached screenshot.

Method to reproduce:

1. Reports > Income & Expense > Expense Pie Chart
2. Open "Options" window
3. Change "Show Average" from current setting ("No Averaging") to "Yearly" or "Monthly", then click "Apply".

Result: all displayed dollar amounts are $0.00. However, if I mouse-over a pie slice, I see something like "Taxes - $0.00 (27.5%) <newline> Accounts: $xxx", where "$xxx" is a real-looking dollar amount.

Expected result: to see real dollar amounts in the display.

Note: the averaging *does* seem to work with "Weekly" averaging, but the amounts displayed contain fractions (e.g. ($123 + 26399/30000").

Version information:

Version: 4.0
Build ID: 4.0+(2020-06-27)
Finance::Quote: 1.47
MacOS
Comment 1 Christopher Lam 2020-07-19 05:46:00 EDT
try the following couple fixes in the Gnucash.app package:

1. date-utilities.scm

modified   libgnucash/app-utils/date-utilities.scm
@@ -110,8 +110,8 @@
 (define (gnc:date-to-year-fraction caltime)
   (let ((lt (gnc-localtime caltime)))
     (+ (- (gnc:date-get-year lt) 1970)
-       (/ (- (gnc:date-get-year-day lt) 1.0)
-	  (* 1.0 (gnc:days-in-year (gnc:date-get-year lt)))))))
+       (/ (- (gnc:date-get-year-day lt) 1)
+          (gnc:days-in-year (gnc:date-get-year lt))))))
 
 ;; return the number of years (in floating point format) between two dates.
 (define (gnc:date-year-delta caltime1 caltime2)
@@ -146,9 +146,9 @@
 ;; convert a date in seconds since 1970 into # of months since 1970
 (define (gnc:date-to-month-fraction caltime)
   (let ((lt (gnc-localtime caltime)))
-    (+ (* 12 (- (gnc:date-get-year lt) 1970.0))
+    (+ (* 12 (- (gnc:date-get-year lt) 1970))
        (gnc:date-get-month lt) -1
-       (/ (- (gnc:date-get-month-day lt) 1.0)
+       (/ (- (gnc:date-get-month-day lt) 1)
           (gnc:days-in-month
 	   (gnc:date-get-month lt)
 	   (gnc:date-get-year lt))))))


2. account-piecharts.scm

modified   gnucash/report/reports/standard/account-piecharts.scm
@@ -431,12 +431,9 @@ balance at a given time"))
         ;; everything foreign gets converted
         ;; (gnc:sum-collector-commodity) based on the average
         ;; cost of all holdings.
-        (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))
+        (* (gnc:gnc-monetary-amount
+            (gnc:sum-collector-commodity c report-currency exchange-fn))
+           averaging-multiplier))
 
       ;; Get balance of an account as an inexact number converted to,
       ;; and using precision of the report's currency.
Comment 2 Greg Hamerly 2020-07-19 09:28:30 EDT
Thanks.

I tried your suggestions (just editing the app directly), and it seems to fix the main issue (seeing zeros). I now see monetary (dollar) amounts in both the legend and the pie chart, for both monthly and yearly averaging.

One remaining issue (which might be intentional, but feels strange to me) is that the fractional amounts are still shown as fractions (e.g. "$123 + 51539/146450"). (I understand that's how things are done in many places in Gnucash, especially when dealing with stocks, but I don't believe I've seen it before in this type of report.)
Comment 3 Greg Hamerly 2020-07-19 09:32:58 EDT
One additional strangeness: when hovering over a pie slice, I see something like:

"CategoryName - $123 + 83/146 (20.5%)
[] Accounts: $123.56849315068493150"

Note the long decimal expansion in the last string.
Comment 4 Christopher Lam 2020-07-19 10:11:24 EDT
The zeros are now fixed for 4.1. I cannot reproduce the exact-fraction issue. It may have been fixed already. Please wait for 4.1 to be released, and file another bug if still present.

Note You need to log in before you can comment on or make changes to this bug.