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 361604 - Balance sheet report shows incorrect prices for commodities when using "nearest in time" option
Balance sheet report shows incorrect prices for commodities when using "neare...
Status: VERIFIED FIXED
Product: GnuCash
Classification: Other
Component: Reports
2.0.x
Other Linux
: Normal major
: ---
Assigned To: Chris Lyttle
Chris Lyttle
: 395694 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-10-12 02:28 UTC by F. Heinsen
Modified: 2018-06-29 21:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Sample gnucash file (gzip archive) (1.55 KB, application/octet-stream)
2006-10-17 17:08 UTC, F. Heinsen
  Details
Patch to fix this problem (1.19 KB, patch)
2007-07-26 03:03 UTC, Mike Alexander
committed Details | Review

Description F. Heinsen 2006-10-12 02:28:18 UTC
The "nearest time" option on the "commodities" tab of the balance sheet report does not work correctly when trying to print a *historical* balance sheet.  The balance sheet keeps using the most recent prices of all commodities (e.g., stocks, bonds, etc.) instead of the prices closest to the report date.  This is a major bug as it directly affects the creation of accurate historical balance sheets.
Comment 1 Christian Stimming 2006-10-12 09:26:33 UTC
Can you please provide a (simple) example file to demonstrate this error, and attach it here (as "attachment")? So far we haven't heard of any problems with the "nearest in time" option.
Comment 2 F. Heinsen 2006-10-17 17:08:11 UTC
Created attachment 74881 [details]
Sample gnucash file (gzip archive)
Comment 3 F. Heinsen 2006-10-17 17:10:51 UTC
The above attachment is a simple gnucash file which has a single investment with a price history.  The balance sheet is dated as of 2006.06.30 and is set to use "nearest in time" prices for commodities, but it doesn't show the right prices as of 2006.06.30.
Comment 4 F. Heinsen 2006-10-17 17:22:35 UTC
I just realized that the balance sheet report is not saved in the data file itself but in the logs, so you will have to run a balance sheet report on the above file.  Use 2006.06.30 as the date of the report, and select "nearest in time" prices for commodities, and you will see the bug.

Thanks for taking the time to read this and help out :-)

Comment 5 Carl van Denzen 2007-05-07 21:46:13 UTC
I also noticed this error.

Carl van Denzen
Comment 6 Andreas Köhler 2007-06-03 10:49:23 UTC
*** Bug 395694 has been marked as a duplicate of this bug. ***
Comment 7 Mike Alexander 2007-07-26 03:03:48 UTC
Created attachment 92428 [details] [review]
Patch to fix this problem

The change to lib/libqof/qof/gnc-date.h in revision 13747 changed the type of the tv_sec member of timespec64 (and hence Timespec) from long long to guint64.  Since Timespecs are used to hold time differences (which can be negative) as well as time values, this was a bad idea.  One observable effect of this is that the "nearest in time" price lookup always returns the later of the two prices that bracket the time in question even if the earlier one is nearer.  The test file attached to this bug has price quotes for 2006.06.30 and 2006.07.31 (both at midnight).  It also has later quotes, but they don't matter for this example.  The report date is 2006.06.30 (at noon) so it's between these two quotes, but it uses the July quote even though it's closer to the June quote.  This patch fixes this by changing tv_sec to gint64.
Comment 8 Josh Sled 2007-07-29 16:00:38 UTC
r16370, 2.2.1.  Thanks for the patch!
Comment 9 Carl van Denzen 2007-08-01 22:10:16 UTC
I tried to apply the patch (that succeeded I think). But the problem is not solved. Maybe I did something wrong (I used Fink, Apple OSX).
Is there anyone who can confirm that the problem has been resolved with this patch?

Thank you.
Comment 10 Carl van Denzen 2007-10-28 15:40:36 UTC
(In reply to comment #8)
> r16370, 2.2.1.  Thanks for the patch!
> 
Did you verify that the solution fixed the problem? I am still having the same problem.

Carl.
Comment 11 John Ralls 2018-06-29 21:13:38 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=361604. Please update any external references or bookmarks.