Bug 410544

Summary: Investment in foreign currency
Product: [Applications] kmymoney Reporter: stephanesp <stephane_1802>
Component: generalAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version: 5.0.8   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.0.8
Sentry Crash Report:
Attachments: Foreign currency investment
Investment currency

Description stephanesp 2019-08-03 17:07:52 UTC
SUMMARY
I have an investment account in currency A, for which fees are also in currency A. If I buy shares in another currency (B), I can no longer add the fees for the transaction in currency A (they are automatically in currency B)

STEPS TO REPRODUCE
1. Have an investment account in currency A
2. Create share in currency B
3. Buy some of those shares
4. Add fees

OBSERVED RESULT
Fees are automatically entered in currency B, whereas the investment account is in currency A

EXPECTED RESULT
Fees should be in currency A and the currency conversion should only apply to the amount corresponding to the shares

SOFTWARE/OS VERSIONS
Linux Ubuntu 19.04

ADDITIONAL INFORMATION
Comment 1 stephanesp 2019-11-01 13:04:17 UTC
As I was told that the issue might have been fixed in later version, I upgraded to version 5.0.6. The issue is still present.

Kmymoney 5.0.6

SOFTWARE/OS VERSIONS
Linux Ubuntu 19.10
Comment 2 Thomas Baumgart 2019-11-02 08:43:24 UTC
Git commit 962c9bcb3e16660e1c7ba0768b96f7be561b9b6f by Thomas Baumgart.
Committed on 02/11/2019 at 08:42.
Pushed by tbaumgart into branch '5.0'.

Correctly handle splits with differing currency

When entering investments the foreign currency detection did not compare
a split's currencyId against the transaction commodity. This is now
fixed.
FIXED-IN: 5.0.8

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

https://commits.kde.org/kmymoney/962c9bcb3e16660e1c7ba0768b96f7be561b9b6f
Comment 3 Thomas Baumgart 2019-11-02 08:48:23 UTC
Git commit cf8d796bd5fe26d4e5bd0707caa35f58f0f0b1c8 by Thomas Baumgart.
Committed on 02/11/2019 at 08:45.
Pushed by tbaumgart into branch 'master'.

Correctly handle splits with differing currency

When entering investments the foreign currency detection did not compare
a split's currencyId against the transaction commodity. This is now
fixed.
FIXED-IN: 5.0.8
(cherry picked from commit 962c9bcb3e16660e1c7ba0768b96f7be561b9b6f)

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

https://commits.kde.org/kmymoney/cf8d796bd5fe26d4e5bd0707caa35f58f0f0b1c8
Comment 4 stephanesp 2020-01-05 16:29:29 UTC
I have tried with the AppImage 5.0.80-35379fe and seem to still have the problem with the following example:

File base currency: A
Investment account in currency B
Purchase share in currency C

OBSERVED RESULT
Fees forced in currency C

EXPECTED RESULT
Fees in same currency as investment account, i.e. B
Comment 5 Thomas Baumgart 2020-01-05 16:46:58 UTC
You know that the currency used depends on the currency of the category. Could it be that the category for the fees is denominated in currency C?
Comment 6 stephanesp 2020-01-05 17:13:24 UTC
Thanks for the quick response. Here are a few points to clarify.

Category for the fee is tax and is in currency A
I assume this is why the fee is then rightly converted in currency A
However, when entered, it is assumed to be in currency C (and is therefore converted from C to A) whereas I would expect it to be assumed as being in currency B (and therefore converted from B to A), given that the investment account is in currency B
This is not an issue when the share is in currency B: both the share and fee are entered in currency B (and then converted from currency B to A)
Comment 7 Thomas Baumgart 2020-01-05 19:36:55 UTC
Would you mind to setup a small test file which shows the situation (just the accounts involved and the one transaction) and attach it to this bug report? I want to avoid to setup something that does not reflect your real scenario. Once I have that file at hand it will be a lot easier to workout a fix. Many thanks in advance.
Comment 8 stephanesp 2020-01-06 20:28:50 UTC
Created attachment 124940 [details]
Foreign currency investment

Thank you very much for looking into this so promptly. Here is a small copy of a file that should illustrate the issue I have.
I have set up the following:

Base account is in euro (base currency)
Trading account is in £
Two shares: one in £ and one in $

When shares bought/sold are in £, everything is shown in £ in account "Trade", where details of the operation are shown
However, when shares bought/sold are in $, share price is rightly shown in $ in account "Trade" but so are the fees (in my example, 5$). Given that the trading account is in £, would it not be expected that the fees are also in £ (in my example £5) ?

In both cases, everything is then converted to the base currency.
Comment 9 stephanesp 2020-01-19 12:34:07 UTC
When adding my last comment and example file, I forgot to change the status back to REPORTED, my apologies
Comment 10 stephanesp 2020-03-07 10:48:52 UTC
I have seen that, in the commit with over 80 changes for appimage 5.0.80 (made a week ago), there is one change regarding investment currency.
What has this changed? Because I have tried with the file in attachment 124940 [details] and still getting the same issue of the fee being shown in the same currency as the share rather than that of the trading account. So, am I setting up this wrongly ?
Comment 11 Thomas Baumgart 2020-04-04 07:37:00 UTC
Sorry for the delay in working on this issue. Regarding the file attached: how did you create it? It contains data that is not created by KMyMoney which causes the application to crash here (master branch plus many local changes). E.g.:

  <ACCOUNT currency="EUR" id="102-category" lastmodified="" number="" description="" parentaccount="AStd::Income" lastreconciled="" opened="1900-01-01" type="12" institution="" name="Investment Income">

A value like "102-category" as id is never produced by KMyMoney. How can that happen?
Comment 12 stephanesp 2020-04-04 13:56:14 UTC
Created attachment 127268 [details]
Investment currency

Hello,

Thank you very much for looking into this. I am not sure about the issue on the original file. I might have used an old template that with remnants of an imported file. I have created this new file from scratch. Does it still cause issues?
Comment 13 Bug Janitor Service 2020-04-19 04:33:11 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 14 Jack 2020-04-19 16:50:51 UTC
Changing status back to REPORTED, as it looks to be still in progress.
Comment 15 stephanesp 2020-07-13 12:25:13 UTC
Just to stay informed about this topic. Has this been implemented in the nightly Appimage for testing ?