Bug 489451 - When buying stocks with precision>2, the rounding rule used in the ledger is wrong
Summary: When buying stocks with precision>2, the rounding rule used in the ledger is ...
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: 5.1.2
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-29 17:43 UTC by matt
Modified: 2024-07-06 19:05 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.2
Sentry Crash Report:


Attachments
screenshot showing the bug (40.20 KB, image/png)
2024-06-29 17:43 UTC, matt
Details
Rounding in current master version (34.20 KB, image/png)
2024-07-06 19:04 UTC, Thomas Baumgart
Details

Note You need to log in before you can comment on or make changes to this bug.
Description matt 2024-06-29 17:43:33 UTC
Created attachment 171186 [details]
screenshot showing the bug

***
If you're not sure this is actually a bug, instead post about it at https://discuss.kde.org

If you're reporting a crash, attach a backtrace with debug symbols; see https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

SUMMARY
When you buy stocks that have a precision > 2 and the rounding option is set to closest ("arrondi" in my french interface) the value is right in the edit window but the value that is written in the ledger seems to use the truncate rule instead. I have attached a screenshot that shows the discrepancy.

STEPS TO REPRODUCE
1. 
2. 
3. 

OBSERVED RESULT


EXPECTED RESULT
The value written in the ledger should use the right rounding rule when buying stocks

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: ubuntu 22.04
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Thomas Baumgart 2024-06-30 13:37:36 UTC
5.1.2 is a bit out-dated. Can you check if the problem persists in the current development version? You can get it as an AppImage. See https://kmymoney.org/appimage.html for details. In case the problem persists, please provide details about the settings in the investment and the transaction so that we are able to duplicate the problem. Merci d'avence.
Comment 2 matt 2024-06-30 15:18:14 UTC
I downloaded and tested the AppImage named kmymoney-5.1-3218-linux-gcc-x86_64.AppImage (version 5.1.3-eef04f1 in the UI).

This version is much better. 

Only small detail left, 1.0051 is rounded up which is correct but the value 1.0050 is rounded down when using the round option, I think it should be rounded up.

It seems there is no international standard but the EU provided one for the euro : 
https://eur-lex.europa.eu/legal-content/EN/TXT/HTML/?uri=LEGISSUM:l25025&from=FR

 Rounding rules

    Monetary amounts in euros must, when a rounding takes place, be rounded up or down to the nearest cent.
    Monetary amounts converted into a national currency unit must be rounded up or down to the nearest sub-unit or in the absence of a sub-unit to the nearest unit.
    National law or practice is to be respected such that, in some countries, rounding may be to a multiple or fraction of the sub-unit or unit of the national currency.
    **If the application of the conversion rate gives a result which is exactly half-way, the sum is rounded up.**
Comment 3 matt 2024-06-30 15:20:21 UTC
Too bad Ubuntu is so late in updating the packages. The version I reported for is the latest in Ubuntu with apt.
Time to switch to flatpak or snap for kmymoney?!
Comment 4 Thomas Baumgart 2024-07-06 19:04:39 UTC
Created attachment 171438 [details]
Rounding in current master version

This has been corrected and is working properly in the master version. See attached screenshot showing the edit widgets on top and the ledger entry at the bottom.
Comment 5 Thomas Baumgart 2024-07-06 19:05:18 UTC
Resolved as per previous comment