Bug 513916 - Rounding errors in investment purchases
Summary: Rounding errors in investment purchases
Status: NEEDSINFO WAITINGFORINFO
Alias: None
Product: kmymoney
Classification: Applications
Component: general (other bugs)
Version First Reported In: 5.1.3
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-12-28 16:03 UTC by mark.smolarz
Modified: 2026-01-03 17:15 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments
Screenshot – correctly rounded total, incorrect entry (24.18 KB, image/png)
2025-12-28 16:03 UTC, mark.smolarz
Details
Screenshot - Incorrect rounding x.885 (19.07 KB, image/png)
2025-12-28 16:06 UTC, mark.smolarz
Details
Screenshot - Correct rounding x.775 (18.83 KB, image/png)
2025-12-28 16:06 UTC, mark.smolarz
Details
Incorrect Rounding on Appimage (5.2.1-c9efa7a) (20.02 KB, image/png)
2025-12-30 17:56 UTC, mark.smolarz
Details
Rounding of x.8855 on Appimage (5.2.1-c9efa7a) (19.97 KB, image/png)
2025-12-30 18:00 UTC, mark.smolarz
Details
Setting the rounding option on the investment (19.01 KB, image/png)
2025-12-31 12:30 UTC, Thomas Baumgart
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mark.smolarz 2025-12-28 16:03:42 UTC
Created attachment 188039 [details]
Screenshot – correctly rounded total, incorrect entry

SUMMARY
I noticed a rounding or input error when entering investment transactions. I enter the total price of all shares instead of the price per share. As can be seen in the screenshot at the beginning. The total amount is rounded correctly in the input window, but then entered incorrectly.
A similar bug was reported as bug 439861 and should have been fixed in version 5.1.3, but it is still present in this version.

STEPS TO REPRODUCE
1. Create a transaction for the purchase of an investment share.
2. Create a total amount of xx.225; xx.445; xx.665 or xx.885 €.

OBSERVED RESULT
In one case, the correctly rounded total is displayed, but entered incorrectly in the book. In further tests, the total was also rounded incorrectly.
xx.225 --> xx.22
xx.445 --> xx.44
xx.665 --> xx.66
xx.885 --> xx.88
The error does not occur with other entries such as xx.115; xx.335, etc.

EXPECTED RESULT
Correct rounding of all amounts

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: openSUSE Leap 15.6
KDE Plasma Version: 5.27.11
KDE Frameworks Version: 5.115.0
Qt Version: 5.15.12

ADDITIONAL INFORMATION
In the securities settings, the ‘Round’ option is selected for the remainder.
Comment 1 mark.smolarz 2025-12-28 16:06:07 UTC
Created attachment 188040 [details]
Screenshot - Incorrect rounding x.885
Comment 2 mark.smolarz 2025-12-28 16:06:36 UTC
Created attachment 188041 [details]
Screenshot - Correct rounding x.775
Comment 3 Thomas Baumgart 2025-12-30 13:33:24 UTC
Does the problem still exist on a newer version? You can simply try by using an AppImage from https://kmymoney.org/appimage.html
Comment 4 mark.smolarz 2025-12-30 17:56:13 UTC
Created attachment 188078 [details]
Incorrect Rounding on Appimage (5.2.1-c9efa7a)
Comment 5 mark.smolarz 2025-12-30 17:59:31 UTC
The same problem exists here too. The numbers are rounded incorrectly and even my input is overwritten. Previously, entries with 3 or 4 decimal places were still saved and displayed again when edited. The correct value was still saved, but here only the rounded value seems to be saved.
Comment 6 mark.smolarz 2025-12-30 18:00:04 UTC
Created attachment 188079 [details]
Rounding of x.8855 on Appimage (5.2.1-c9efa7a)
Comment 7 Thomas Baumgart 2025-12-31 12:30:39 UTC
Created attachment 188111 [details]
Setting the rounding option on the investment

It looks like your rounding option is set to RoundRound which causes the behavior you encounter (see attached screenshot). I have not found a respective section on rounding in the KMyMoney documentation, but the different settings are very well explained in the comment of the source code at https://invent.kde.org/office/alkimia/-/blob/master/src/alkvalue.h.in?ref_type=heads#L30-L78.
Comment 8 Thomas Baumgart 2025-12-31 12:30:48 UTC
Regarding the modification of the value entry in 5.2.1+ it has to be noted, that keeping the original value caused other (rounding) problems down the line. There are (closed) bug entries about it, which I did not find on first glance. If you want to keep the original detail, you may want to switch to the price per share entry method. That allows to control the number of digits using the price precision of the investment.
Comment 9 mark.smolarz 2026-01-03 17:15:55 UTC
It seems that some rounding options were not yet available in this version. Only Round, Ceil, Floor and Truncate are offered. From the wording, “Round” was the option I was looking for, because the other two options rounded up or down completely.
However, “RoundHalfUp” would probably be the best option here.
I'll probably have to wait until the new version is available for me.