Bug 297437

Summary: Reports show currency-converted values even when asked not to
Product: [Applications] kmymoney Reporter: Brendon Higgins <brendon>
Component: generalAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: git (master)   
Target Milestone: ---   
Platform: Debian testing   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Anonymized budget exhibiting the problem

Description Brendon Higgins 2012-04-04 00:03:40 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64) KHTML/4.7.4 (like Gecko) Konqueror/4.7
Build Identifier: 

I've noticed that in reports there are unmarked conversions of currencies, even when I uncheck the convert to base currency option. I know they are being converted to another currency because the numbers do not match those in the ledger. Some accounts do this, but it seems cash accounts do not.

Furthermore, the conversions are *away* from the base currency into another currency. What's worse is that the conversion is silent. (Fortunately I caught this *before* finishing my tax return. Not pleased about it.)

Worthy of note: I used to have this budget in a different base currency (the one which these values seem to get converted to), but changed it when I moved. Maybe that has something to do with it. I noticed that when I enabled the convert to base currency option, it seemed to convert it all to my previous base currency and not the current one.

Reproducible: Always
Comment 1 Cristian OneČ› 2012-04-04 06:27:09 UTC
Could you please attach an anonymous file to reproduce this?
Comment 2 Brendon Higgins 2012-04-08 19:20:28 UTC
Created attachment 70240 [details]
Anonymized budget exhibiting the problem

Anonymized budget attached. After opening, look at the Transactions by Category report. The first entry (306.38) to account A000054, is actually (304.47) in the ledger of that account. This account is in CAD, and the report is supposed to be converting everything to CAD, so there should be no discrepancy. If you customize the report to not convert values to base currency, this erroneous conversion is still applied. Conversion seems to be okay for entries in AUD. I used to use AUD as the base currency, but now it is CAD.
Comment 3 Alvaro Soliverez 2012-04-27 23:46:29 UTC
Ok, I think I found the problem. It's using a conversion rate from 5 days before, instead of using the reverse for the same day. (If only Thomas were around to point me to the correct area of the code to fix that.)

Now, it shouldn't use any conversion at all when not converting to base currency. I'll keep looking into this.
Comment 4 Alvaro Soliverez 2012-04-28 19:22:42 UTC
Quick explanation, which may help in the future.
First, the transaction are a beast. Now, more to the point. When running a non-base currency report, the individual splits of a transaction were still being converted to the currency of the main split (that gets selected on-the-fly by several criteria). In this case, the main split was the CAD account, over the AUD category, therefore it got converted to CAD. The wrong value is due to what I mentioned before, an old value is being used instead of the same-day reverse one.

I've posted a patch that removes that conversion, and adds the display of currency for individual splits. It will have to be reviewed by others before pushing this to master branch. The complexity of those reports has the potential to make it very disruptive, so it will take a while to push it.

I want to thank the thorough description of the bug and the attached test file which made it easy to pinpoint the problem and verify the fixes.
Comment 5 Alvaro Soliverez 2012-05-06 01:15:59 UTC
Git commit 9fc583d3db4fe2c16448790d7ee17145fbe8bd2f by Alvaro Soliverez.
Committed on 01/05/2012 at 00:33.
Pushed by asoliverez into branch 'master'.

Multi-currency transaction reports: each individual should be shown in
its own currency, not the one of the main split.
Fixed the display of currency for those cases when the currency is
different from the base currency.
Added test for Transaction by Account report with multiple currencies,
contributed by Cristian Onet.

There might be some more fixing to do, as it's one of the most complex
reports.
Related: bug 295533
REVIEW:104774

M  +18   -10   kmymoney/reports/querytable.cpp
M  +79   -0    kmymoney/reports/querytabletest.cpp
M  +1    -0    kmymoney/reports/querytabletest.h

http://commits.kde.org/kmymoney/9fc583d3db4fe2c16448790d7ee17145fbe8bd2f
Comment 6 Alvaro Soliverez 2012-11-30 19:43:21 UTC
Git commit 2c2d932439ac6eac8adbdfabe8598a4887582512 by Alvaro Soliverez.
Committed on 01/05/2012 at 01:10.
Pushed by asoliverez into branch 'master'.

Price: When a price is not found for the exact date, verify
if the reciprocal exists for that date before searching
previous dates prices
REVIEW:104786

M  +28   -4    kmymoney/mymoney/mymoneyfile.cpp

http://commits.kde.org/kmymoney/2c2d932439ac6eac8adbdfabe8598a4887582512