Bug 414932 - Incorrect "opening balance" in daily and weekly "Investment Worth Graph"
Summary: Incorrect "opening balance" in daily and weekly "Investment Worth Graph"
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: reports (show other bugs)
Version: 5.0.7
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-07 21:07 UTC by zoltan1980
Modified: 2020-01-11 09:16 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.0.8


Attachments
KMY file to reproduce error (18.31 KB, application/x-kmymoney)
2019-12-07 21:07 UTC, zoltan1980
Details
Incorrect daily report for 1 year (99.63 KB, image/png)
2019-12-07 21:09 UTC, zoltan1980
Details
Incorrect weekly report for 1 year (87.25 KB, image/png)
2019-12-07 21:10 UTC, zoltan1980
Details
Incorrect weekly report for 2 years (93.88 KB, image/png)
2019-12-07 21:10 UTC, zoltan1980
Details
Correct monthly report for 1 year (64.83 KB, image/png)
2019-12-07 21:10 UTC, zoltan1980
Details

Note You need to log in before you can comment on or make changes to this bug.
Description zoltan1980 2019-12-07 21:07:50 UTC
Created attachment 124363 [details]
KMY file to reproduce error

SUMMARY

The "opening balance" of an "Investment Worth Graph" is calculated using the latest stock price instead of the stock price in effect at the start of the report period. Only daily and weekly charts are affected, monthly charts look correctly.

STEPS TO REPRODUCE
I created a file to demonstrate the problem. It has a single stock with a starting price of $1 as of Jan 1, 2000, and increasing by $1 every month. There is a single share of this stock bought in Jan 1, 2000 and no other investment transaction. Use the attached file and open the Investment Worth Graph report. You can also switch to the report view to observe incorrect numbers in a table.

OBSERVED RESULT

When ticks are set to be daily (the default) or weekly, the "opening balance" on the left of the chart shows a value calculated using the latest price (which in this test file is much higher than expected). This happens regardless of the time range: please see the attached screenshots that use a range of 1 year (the default) and 2 years. When the ticks are set to be monthly, the values are correct.

EXPECTED RESULT

The opening balance should be calculated using the price that was in effect at the start of the period.

ADDITIONAL INFORMATION

I created the test file and the screenshots using an older version (plus some manual scripting), but the bug is present in v5.0.7 as well.
Comment 1 zoltan1980 2019-12-07 21:09:41 UTC
Created attachment 124365 [details]
Incorrect daily report for 1 year
Comment 2 zoltan1980 2019-12-07 21:10:06 UTC
Created attachment 124366 [details]
Incorrect weekly report for 1 year
Comment 3 zoltan1980 2019-12-07 21:10:20 UTC
Created attachment 124367 [details]
Incorrect weekly report for 2 years
Comment 4 zoltan1980 2019-12-07 21:10:54 UTC
Created attachment 124368 [details]
Correct monthly report for 1 year
Comment 5 Thomas Baumgart 2020-01-11 09:04:32 UTC
Git commit 286c3aecb316ab79b5e7115b26a9fdd58f147298 by Thomas Baumgart.
Committed on 11/01/2020 at 09:04.
Pushed by tbaumgart into branch '5.0'.

Fix calculation of columnDate

The returned date of columnDate was not correct in certain circumstances
so that the price information using this date was incorrect which
resulted in false opening balance values in reports.
FIXED-IN: 5.0.8

M  +9    -3    kmymoney/plugins/views/reports/core/pivottable.cpp

https://commits.kde.org/kmymoney/286c3aecb316ab79b5e7115b26a9fdd58f147298
Comment 6 Thomas Baumgart 2020-01-11 09:16:09 UTC
Git commit 38ea8dc4603f6e263d8d986e901e8870e534134a by Thomas Baumgart.
Committed on 11/01/2020 at 09:15.
Pushed by tbaumgart into branch 'master'.

Fix calculation of columnDate

The returned date of columnDate was not correct in certain circumstances
so that the price information using this date was incorrect which
resulted in false opening balance values in reports.
FIXED-IN: 5.0.8
(cherry picked from commit 286c3aecb316ab79b5e7115b26a9fdd58f147298)

M  +9    -3    kmymoney/plugins/views/reports/core/pivottable.cpp

https://commits.kde.org/kmymoney/38ea8dc4603f6e263d8d986e901e8870e534134a