Bug 403885 - Buying / selling investments interest / fees round to 2 decimal places even when currency is to 6 decimal places
Summary: Buying / selling investments interest / fees round to 2 decimal places even w...
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: git (master)
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-03 09:59 UTC by Ian Neal
Modified: 2019-03-02 09:27 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.0.4


Attachments
Test kmy file (1.11 KB, application/x-kmymoney)
2019-02-03 15:44 UTC, Ian Neal
Details
Patched test file (1.12 KB, application/x-kmymoney)
2019-02-03 18:01 UTC, Thomas Baumgart
Details
Test kmy created using git master (1.12 KB, application/x-kmymoney)
2019-02-03 18:39 UTC, Ian Neal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ian Neal 2019-02-03 09:59:27 UTC
SUMMARY
When buying or selling investments the interest and/or fees round to 2 decimal places even when the currency is set to calculate to 6 decimal places (e.g. palladium)

STEPS TO REPRODUCE
1. Create an investment account with currency of palladium
2. Create a category for the investment interest with currency of palladium
3. Create and buy some investments in palladium
4. Sell some investments in palladium with interest added using the category created.

OBSERVED RESULT
Interest is rounded to 2 decimal places.

EXPECTED RESULT
Interest is rounded to 6 decimal places.

SOFTWARE/OS VERSIONS
Windows: 
MacOS: 
Linux/KDE Plasma: Fedora 29 (xcb windowing system)
(available in About System)
KDE Plasma Version: 5.13.5-1
KDE Frameworks Version: 5.54.0
Qt Version: 5.11.3

ADDITIONAL INFORMATION
Workaround is to go into the brokerage account and edit the interest amount there.
Comment 1 Thomas Baumgart 2019-02-03 15:22:26 UTC
Can you attach a testfile here, please?
Comment 2 Ian Neal 2019-02-03 15:44:42 UTC
Created attachment 117808 [details]
Test kmy file

Test file with investment and brokerage accounts in Palladium currency.
Investment Bond 01 created in palladium with a buy and a sell transaction.
Comment 3 Ian Neal 2019-02-03 15:45:18 UTC
Testfile added
Comment 4 Thomas Baumgart 2019-02-03 18:01:04 UTC
Created attachment 117811 [details]
Patched test file

Looks like you did not create the test file with today's git master and that is (still) causing the problem.

I added a fix provided on Jan 19 to the source repo in this commit:

   https://cgit.kde.org/kmymoney.git/commit/?id=e38492cbc059796addb5a62861e75b851b2428e0

Unfortunately, your test file is older:

  <CREATION_DATE date="2019-01-13"/>

The fix creates the XPD currency with the necessary SAF setting. The first line below comes from your test file. The second one is from the file I patched (just added that bunch of zeroes as per the instructions in the commit message).

69c69
<   <CURRENCY pp="4" symbol="XPD" type="3" saf="100" rounding-method="7" id="XPD" scf="1000000" name="Palladium"/>
---
>   <CURRENCY pp="4" symbol="XPD" type="3" saf="1000000" rounding-method="7" id="XPD" scf="1000000" name="Palladium"/>

I attach the modified file here as well. Opening this, you should instantaneously see correct results. Let me check if I can come up with a more automated solution.
Comment 5 Ian Neal 2019-02-03 18:39:51 UTC
Created attachment 117812 [details]
Test kmy created using git master

Test file created using latest git master
Comment 6 Ian Neal 2019-02-03 18:40:48 UTC
Tried to create sale with interest payment of 0.015 and it was rounded to 0.02
Comment 7 Thomas Baumgart 2019-02-03 18:46:45 UTC
Git commit 2fe372e97b012442f6f5be462ee23ebfcd19a5ab by Thomas Baumgart.
Committed on 03/02/2019 at 18:46.
Pushed by tbaumgart into branch '5.0'.

Added automatic fix to adjust settings of precious metals

Files created before Jan 19th 2019 will most certainly have a false
setting for the smallest account fraction of the precious metals gold,
platinum, palladium and silver.

This change fixes the problem in the file when the file is opened.

At the same time it initializes an investment transaction with the
commodity of the account and not the base currency.
FIXED-IN: 5.0.4

M  +27   -0    kmymoney/kmymoney.cpp
M  +1    -1    kmymoney/mymoney/storage/mymoneystoragemgr_p.h
M  +3    -1    kmymoney/views/kgloballedgerview_p.h

https://commits.kde.org/kmymoney/2fe372e97b012442f6f5be462ee23ebfcd19a5ab
Comment 8 Ian Neal 2019-02-03 23:34:55 UTC
(In reply to Thomas Baumgart from comment #7)
> Git commit 2fe372e97b012442f6f5be462ee23ebfcd19a5ab by Thomas Baumgart.
> Committed on 03/02/2019 at 18:46.
> Pushed by tbaumgart into branch '5.0'.
> 
> Added automatic fix to adjust settings of precious metals
> 
> Files created before Jan 19th 2019 will most certainly have a false
> setting for the smallest account fraction of the precious metals gold,
> platinum, palladium and silver.
> 
> This change fixes the problem in the file when the file is opened.
> 
> At the same time it initializes an investment transaction with the
> commodity of the account and not the base currency.
> FIXED-IN: 5.0.4
> 
> M  +27   -0    kmymoney/kmymoney.cpp
> M  +1    -1    kmymoney/mymoney/storage/mymoneystoragemgr_p.h
> M  +3    -1    kmymoney/views/kgloballedgerview_p.h
> 
> https://commits.kde.org/kmymoney/2fe372e97b012442f6f5be462ee23ebfcd19a5ab

Will this be going on master as well as 5.0?
Comment 9 Thomas Baumgart 2019-02-04 07:05:10 UTC
Once I merge the latest changes back onto master they will automatically be there.
Comment 10 Ian Neal 2019-02-09 11:49:29 UTC
Just tested with latest git master with fix in and it is still rounding. When you first try and create a new sell transaction, it wouldn't know what currency the interest is in until you select the category, is that why it is still failing?
Comment 11 Thomas Baumgart 2019-02-09 17:10:07 UTC
Fixed with https://commits.kde.org/kmymoney/d292de0b7f976d38d7c4e966aff573d7bb88fdd6 (I dropped the wrong bug number into the commit message hence a bit of manual cleanup here)
Comment 12 Ian Neal 2019-02-28 16:32:11 UTC
(In reply to Thomas Baumgart from comment #11)
> Fixed with
> https://commits.kde.org/kmymoney/d292de0b7f976d38d7c4e966aff573d7bb88fdd6 (I
> dropped the wrong bug number into the commit message hence a bit of manual
> cleanup here)

When's this going to get merged into git master as it been a few weeks now?
Comment 13 Thomas Baumgart 2019-03-01 09:35:25 UTC
Done. Sorry for the delay and thanks for the reminder.
Comment 14 Ian Neal 2019-03-02 00:21:22 UTC
It's not quiet fixed, it's working fine if you create one but as soon as you click edit on a previously created one, the interest / fees are immediately rounded to 2 decimal places.
Comment 15 Thomas Baumgart 2019-03-02 09:27:25 UTC
Git commit d03dd8e1b5303a8292401047c2a725fb9c4ca024 by Thomas Baumgart.
Committed on 02/03/2019 at 09:27.
Pushed by tbaumgart into branch '5.0'.

Set precision of edit widget before loading value

If used the other way around, the value loaded will be rounded to the
standard precision of 2 digits.

M  +2    -2    kmymoney/dialogs/investtransactioneditor.cpp

https://commits.kde.org/kmymoney/d03dd8e1b5303a8292401047c2a725fb9c4ca024