Bug 337162

Summary: dividend payment in foreign currency
Product: [Applications] kmymoney Reporter: Wolfgang Rohdewald <wolfgang>
Component: generalAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: major CC: agander93, onet.cristian, ralf.habacker, robby.engelmann, wolfgang
Priority: NOR    
Version: 4.6.4   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In: 4.7.0
Sentry Crash Report:

Description Wolfgang Rohdewald 2014-07-07 06:55:37 UTC
This is a regression, it always worked since about 2 months ago.

I have an investment account in a foreign currency. The corresponding account for payments is in the base currency. Now if I get a dividend in foreign currency, kmymoney does show the exchange rate/price editor but then it ignores what I enter (I enter the exact amount in base currency), it just uses the foreign amount 1:1.

As I said, this always worked correctly since I started using kmymoney.

Since this is a regression and since it makes it impossible to continue tracking such an account with kmymoney, I am taxing this as a major bug.

Reproducible: Always
Comment 1 Cristian Oneț 2014-07-07 07:05:53 UTC
Could you specify what version were you using two months ago? I would be easier to pinpoint the commit that introduced this regression.
Comment 2 Wolfgang Rohdewald 2014-07-11 06:14:33 UTC
No, I cannot. I can not even find a trace of an update. If you cannot reproduce this, I will have to debug it but it will take some time until I find time for this.
Comment 3 Cristian Oneț 2014-07-11 09:18:06 UTC
OK, I've reproduced it, and by looking at the result I think that it's caused by this commit (lines 437 and 745)
https://projects.kde.org/projects/extragear/office/kmymoney/repository/revisions/101225c4ec65fc7eb4c94d92ee38a32666013908/diff/kmymoney/dialogs/investactivities.cpp

Allan, could you explain why was the 'assetAccountSplit.setShares(-total)' needed?
Comment 4 Cristian Oneț 2014-07-11 09:19:08 UTC
The previous link is to the diff this is the link to the commit

https://projects.kde.org/projects/extragear/office/kmymoney/repository/revisions/101225c4ec65fc7eb4c94d92ee38a32666013908
Comment 5 allan 2014-07-11 13:20:04 UTC
(In reply to comment #0)
> This is a regression, it always worked since about 2 months ago.
> 
> I have an investment account in a foreign currency. The corresponding
> account for payments is in the base currency. Now if I get a dividend in
> foreign currency, kmymoney does show the exchange rate/price editor but then
> it ignores what I enter (I enter the exact amount in base currency), it just
> uses the foreign amount 1:1.
> 
> As I said, this always worked correctly since I started using kmymoney.
> 
I just want to be absolutely clear about this.  The change that Cristian mentions in Comment 3 was committed nearly three years ago, so that doesn't appear to tie in with your experience.  I am sure you know what you're talking about, but just to be certain, you are saying that this operation has always worked correctly, until 'about 2 months ago.'?  So, this would suggest something has changed since then.  Unless I'm missing something.
Comment 6 allan 2014-07-11 13:26:37 UTC
Also, I meant to ask about what revision of KMM you are running, both now, with the problem, and prior to that - about two months ago?  And what distro, for good measure?
Comment 7 Cristian Oneț 2014-07-11 13:34:13 UTC
(In reply to comment #6)
> Also, I meant to ask about what revision of KMM you are running, both now,
> with the problem, and prior to that - about two months ago?  And what
> distro, for good measure?

Allan, the version number is available in the bug report, I also can confirm the bug, so there is no need for the reporter to give further details.

The bug is simple to reproduce following the description in the report. Just create an investment account in a foreign currency and the brokerage account in the base currency then enter a dividend transaction. Observe that the amount in the brokerage account is not what one would expect.

Since this only happens on dividend and interest income transactions I'm sure that the bug is caused by that commit since 'assetAccountSplit.setShares(-total)' was only added to those two actions. The rest work as expected.
Comment 8 Cristian Oneț 2014-07-11 13:36:39 UTC
All I would have liked to know is that if there was a reason to add those statements and which was it? I don't want to add other bugs by removing them.
Comment 9 Cristian Oneț 2014-07-11 17:42:18 UTC
Git commit 3cb1f8f3aa4851f46245003da03a01fb033a119e by Cristian Oneț.
Committed on 11/07/2014 at 17:33.
Pushed by conet into branch 'master'.

Fix dividend payments in foreign currency.

This was introduced in a previous revision when the call to
InvestTransactionEditor::setupPrice (which takes care of conversions)
was incorrectly removed for the Dividend and Interest income
investment transactions. Only these transactions were affected by
this bug.

M  +7    -2    kmymoney/dialogs/investactivities.cpp

http://commits.kde.org/kmymoney/3cb1f8f3aa4851f46245003da03a01fb033a119e
Comment 10 Cristian Oneț 2014-07-11 17:43:18 UTC
Git commit 7c85923e8936d1ff5abfc5fcf4fc18679eb91392 by Cristian Oneț.
Committed on 11/07/2014 at 17:33.
Pushed by conet into branch 'frameworks'.

Fix dividend payments in foreign currency.

This was introduced in a previous revision when the call to
InvestTransactionEditor::setupPrice (which takes care of conversions)
was incorrectly removed for the Dividend and Interest income
investment transactions. Only these transactions were affected by
this bug.
(cherry picked from commit 3cb1f8f3aa4851f46245003da03a01fb033a119e)

M  +7    -2    kmymoney/dialogs/investactivities.cpp

http://commits.kde.org/kmymoney/7c85923e8936d1ff5abfc5fcf4fc18679eb91392
Comment 11 Cristian Oneț 2014-07-29 09:53:30 UTC
*** Bug 316070 has been marked as a duplicate of this bug. ***
Comment 12 Robby Engelmann 2014-08-13 08:48:07 UTC
In which version should that be fixed? I am using 4.6.6 and the conversion does not work properly.
I can add a $ dividend payment in the investment account and see the very same number appearing in the brokerage account in €. However, in the income expense report the correct €-value is given.
Comment 13 Cristian Oneț 2014-08-13 08:56:59 UTC
This is fixed in master which was not yet released. It will be available as the next stable release.
Comment 14 allan 2014-08-13 09:38:53 UTC
(In reply to Robby Engelmann from comment #12)
> In which version should that be fixed? I am using 4.6.6 and the conversion
> does not work properly.
> I can add a $ dividend payment in the investment account and see the very
> same number appearing in the brokerage account in €. However, in the income
> expense report the correct €-value is given.

If you are able/willing to try compiling from source, it's avaiable now.
Comment 15 Robby Engelmann 2014-08-13 18:12:26 UTC
I compiled from source and indeed it is working now! thanks!