After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 541970 - Balance Sheet: "Nearest in time" exchange rate not correct
Balance Sheet: "Nearest in time" exchange rate not correct
Status: VERIFIED FIXED
Product: GnuCash
Classification: Other
Component: Reports
2.2.x
Other All
: Normal minor
: ---
Assigned To: Charles Day
Andreas Köhler
Depends on:
Blocks: backport
 
 
Reported: 2008-07-07 23:51 UTC by Jannick
Modified: 2018-06-29 22:06 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Nearest-in-time bug in balance sheet report (12.57 KB, application/octet-stream)
2008-07-07 23:52 UTC, Jannick
Details
Sample file reproducing the bug (4.14 KB, application/octet-stream)
2008-07-08 03:45 UTC, Charles Day
Details

Description Jannick 2008-07-07 23:51:29 UTC
Please describe the problem:
The nearest in time exchange rate (of a stock) is not correctly chosen in the balance sheet report - provided that "nearest in time" means that the value in database with minimum time distance to balance sheet date is allowed for..

Steps to reproduce:
Enter fair values of stock into price database:

July 1: 100
July 4:  90
July 5:  90

Run balance sheet report at July 2 with price source "nearest in time".

Actual results:
Fair value of stock: 90

Expected results:
Should be 100.

Does this happen every time?
Yes.

Other information:
Example file provided.
Comment 1 Jannick 2008-07-07 23:52:45 UTC
Created attachment 114157 [details]
Nearest-in-time bug in balance sheet report
Comment 2 Charles Day 2008-07-08 03:45:07 UTC
Created attachment 114160 [details]
Sample file reproducing the bug

Confirmed. I can reproduce this problem with the sample attached.
Comment 3 Charles Day 2008-07-08 21:16:59 UTC
I've dug through the code and here's what's actually happening:

Report time: July 2, 12PM (noon)
Time of July 1 price: July 1, 12AM (midnight)
Time of July 4 price: July 4, 12AM (midnight)

So the difference between the report time and the price time is exactly 36 hours in both cases. So it is a tie, and the newer price (July 4) is chosen arbitrarily.

So that explains what happens... now what to do about it?
Comment 4 Jannick 2008-07-08 22:22:00 UTC
In both samples attached to this bug report the time stamp of the July 1 price is 
- 2008-07-01 00:00:00 +0200 (Charles' sample)
- 2008-07-01 09:00:00 +0200 (my sample)

I am wondering if the time of the prices is ignored in the calculations in the reports. If so I am just asking which rate is taken when multiple entries are in the price-db with the same date.

This case happens after a multiple update during a day. I would expect the latest entry to be taken. Only if the latest entry is not used there is an issue here I think.
Comment 5 Charles Day 2008-07-09 03:44:23 UTC
I don't think the time is ignored. If it was judging by date alone then it would pick the July 1 price. I'll bet your report time was 2008-07-02 21:00:00 +0200, making your July 1 and July 4 prices both 36 hours from report time, just like mine. (The nine hour difference in our samples is probably our time zone difference.)

Anyway, if GnuCash has fake times of day on Price Editor entries and report run dates, then the "Nearest in time" routine could ignore time of day and only compare dates.

But maybe the "Nearest in time" routine should be left alone, and the real bug to fix is the fake time of day. So I'm not sure what the right approach is here. We might need to ask for advice on the mailing list.
Comment 6 Frank H. Ellenberger 2008-07-10 03:55:33 UTC
You should watch, not to run in Bug 137017 - date of transaction change with time zone change, which possible also relates to Bug 506251 – src/engine/test/test-date fails on systems with a timezone east of UTC.

May be, gnucash files need an option to remember, in which time zone they were created?


Comment 7 Jannick 2008-07-10 07:23:56 UTC
(In reply to comment #6)
> You should watch, not to run in Bug 137017 - date of transaction change with
> time zone change, ...

Even the winter/summer time switch counts as time zone change, but it should not result in significant distortions of report results, I assume.

> May be, gnucash files need an option to remember, in which time zone they were
> created?

This is ok if transactions relate to one time zone regardless in which time zone they are produced. But what happens if stock or currency exchange data are retrieved online in a different time zone than assigned to the gnucash file? This sounds like a complication, e.g., with respect to use closing data only.
Comment 8 Charles Day 2008-08-04 16:53:08 UTC
Fix committed as r17454. Requesting backport for 2.2.

This fix works by preferring the older price in the event of a tie. Even without this bug, I think it makes more sense anyway. A price that actually existed at the given time will be preferred to one that didn't.

Another way of saying this: If the "nearest in time" method results in a tie, then the result will be equal to the "latest before" method.
Comment 9 Andreas Köhler 2008-09-16 13:42:21 UTC
Applied to branches/2.2 as r17520 for inclusion in GnuCash 2.2.7.
Thanks a lot!
Comment 10 John Ralls 2018-06-29 22:06:50 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=541970. Please update any external references or bookmarks.