Reference dates for net worth barchart

John Ralls jralls at ceridwen.us
Sat Nov 7 11:22:50 EST 2015


> On Nov 5, 2015, at 9:26 AM, Geert Janssens <geert.gnucash at kobaltwit.be> wrote:
> 
> The part of the patch I'm interested in here now is the part where you changed code to 
> unconditionally use the start-day-time for the from-date, where it was using either start-day-
> time or end-day-time depending on whether the report is for income/expense or not. Your patch 
> may be correct, but I don't know because I have no idea why this distinction was there in the 
> first place. I would like to hear if other users/devs know this before I apply your patch.
> 

Wm’s response indicates that others need a little more background to understand the question here: The file being patched, net-barchart.scm, generates several different reports depending upon the arguments with which it’s called. One of those arguments is inc-exp?, which if true indicates that the report being run is either the Income, Expense, or Net Profit Barchart, if false either the Assets, Liabilities, or Net Worth Barchart.

The current code uses the start-time-of-day for the from-date (beginning of the period) if inc-exp? is true and end-time-of-day if it’s not. It always uses end-time-of-day for the to-date (end of the period). JD’s patch makes it always start-time-of-day. These values are passed to gnc:make-date-interval-list if inc-exp? is true and gnc:make-date-list if it isn’t. 

Commenters also need to know that GnuCash actually uses a unix time value (the number of seconds since 1 January 1970, expressed as a 64-bit signed integer — technically two 64-bit ints, the second for nanoseconds, but in practice we never fill  in the second one so it doesn’t matter). Entry dates are stored as the start-of-day time value for the day in question (I think that’s a change since the reporting code was written).

What this boils down to is that when constructing an interval-list, the current code includes transactions from the start-of the first day to the end-of the last day of the interval, while when constructing a date-list it uses the end-of each date.

For my part, if I run an asset report for a certain day I expect that that day’s transactions would be included. I would not want JD’s patch applied.

The other part of the bug, about the intervals being wrong, is correct.

As for the claim that the report uses a fixed interval, that’s false. The report uses calendar functions (only the Gregorian calendar is supported, but pretty much everyone in the world uses that for accounting so I wouldn’t consider that to be a problem) to determine the correct number of days for each month. This is clear from examining the dates in the x-axis labels.

Regards,
John Ralls




More information about the gnucash-devel mailing list