Bug 463974

Summary: Report "Investment Performance by Account" Annualized return & Return On Investment Calculation do not account for Dividend Re-investment
Product: [Applications] kmymoney Reporter: Pete <tulaff>
Component: reportsAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: REPORTED ---    
Severity: major CC: ralf.habacker
Priority: NOR    
Version: 5.1.3   
Target Milestone: 5.2   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Bug Depends on: 452692    
Bug Blocks:    
Attachments: Fund with initial purchase and dividend re-investment. Total investment $25.53

Description Pete 2023-01-07 17:43:32 UTC
Created attachment 155088 [details]
Fund with initial purchase and dividend re-investment. Total investment $25.53

SUMMARY
 REPORT: "Investment Performance by Account" does not appear to be taking dividend re-investment into consideration when calculating "Annualized return" and "Return On Investment".  The re-invested dividends appear not to be used in determining the cost as a result the return is higher than the real return.


STEPS TO REPRODUCE
1. Create an investment account for a mutual fund
2. Buy units $25
3. Post dividend re-investments $.22 & $.32
4. Run report "Investment Performance by Account" 

OBSERVED RESULT
Present value is $25.08 report shows annualized return of .17% and ROI of .32%

EXPECTED RESULT
A negative result.  $25.53 invested and present value is $25.36 representing a loss of $.17

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: PCLinuxOS 2022 6.1.3-pclos1 (64 bit)
(available in About System)
KDE Plasma Version: 5.26.5
KDE Frameworks Version: 5.101.0
Qt Version:  5.15.6

ADDITIONAL INFORMATION
Comment 1 Ralf Habacker 2024-12-31 10:39:32 UTC
When fixing bug 452692, it became apparent that kmymoney was calculating the “Annualized return” value incorrectly. In reality, XIRR was calculated there and the column was renamed accordingly. The output of “Annualized return” should be added.
Comment 2 Bug Janitor Service 2024-12-31 10:41:48 UTC
A possibly relevant merge request was started @ https://invent.kde.org/office/kmymoney/-/merge_requests/251
Comment 3 Ralf Habacker 2025-01-04 06:41:59 UTC
Git commit a0d0566c668fa2a4569477a5e43b7feef5ee6bc9 by Ralf Habacker.
Committed on 04/01/2025 at 06:40.
Pushed by habacker into branch 'master'.

Add column "Annualized return" to investment performance reports

M  +3    -0    kmymoney/plugins/views/reports/core/listtable.cpp
M  +1    -0    kmymoney/plugins/views/reports/core/listtable.h
M  +81   -15   kmymoney/plugins/views/reports/core/querytable.cpp
M  +15   -0    kmymoney/plugins/views/reports/core/querytable.h
M  +4    -4    kmymoney/plugins/views/reports/core/tests/data/test-investment-report-querytable-Investment-Performance-by-Account-_Customized---from-period---one-year--start-later_.csv
M  +4    -4    kmymoney/plugins/views/reports/core/tests/data/test-investment-report-querytable-Investment-Performance-by-Account-_Customized---from-period---one-year_.csv
M  +4    -4    kmymoney/plugins/views/reports/core/tests/data/test-investment-report-querytable-Investment-Performance-by-Account-_Customized---from-period---three-year_.csv
C  +4    -4    kmymoney/plugins/views/reports/core/tests/data/test-investment-report-querytable-Investment-Performance-by-Account-_Customized---from-period---two-years_.csv [from: kmymoney/plugins/views/reports/core/tests/data/test-investment-report-querytable-Investment-Performance-by-Account-_Customized---from-period---one-year_.csv - 063% similarity]
M  +6    -3    kmymoney/plugins/views/reports/core/tests/data/test-investment.xml
M  +44   -0    kmymoney/plugins/views/reports/core/tests/querytable-test.cpp
M  +1    -0    kmymoney/plugins/views/reports/core/tests/querytable-test.h

https://invent.kde.org/office/kmymoney/-/commit/a0d0566c668fa2a4569477a5e43b7feef5ee6bc9
Comment 4 Ralf Habacker 2025-01-08 23:48:56 UTC
Git commit 18d78eaf58bde890b666a2352836f5984c20e4c8 by Ralf Habacker.
Committed on 08/01/2025 at 23:48.
Pushed by habacker into branch 'master'.

Fix rounding issue in report column "Annualized return"

The return value of QueryTable::helperRAOI() was previously
rounded to two digits, which is too small and led to directly
visible differences between the ROI and an AROI over one year.

Fixup of commit a0d0566c.

M  +1    -1    kmymoney/plugins/views/reports/core/querytable.cpp
M  +3    -3    kmymoney/plugins/views/reports/core/tests/data/test-investment-report-querytable-Investment-Performance-by-Account-_Customized---from-period---one-year--start-later_.csv
M  +3    -3    kmymoney/plugins/views/reports/core/tests/data/test-investment-report-querytable-Investment-Performance-by-Account-_Customized---from-period---one-year_.csv
M  +3    -3    kmymoney/plugins/views/reports/core/tests/data/test-investment-report-querytable-Investment-Performance-by-Account-_Customized---from-period---three-year_.csv
M  +3    -3    kmymoney/plugins/views/reports/core/tests/data/test-investment-report-querytable-Investment-Performance-by-Account-_Customized---from-period---two-years_.csv
M  +1    -1    kmymoney/plugins/views/reports/core/tests/querytable-test.cpp

https://invent.kde.org/office/kmymoney/-/commit/18d78eaf58bde890b666a2352836f5984c20e4c8