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.
Created attachment 124365 [details] Incorrect daily report for 1 year
Created attachment 124366 [details] Incorrect weekly report for 1 year
Created attachment 124367 [details] Incorrect weekly report for 2 years
Created attachment 124368 [details] Correct monthly report for 1 year
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
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