Bug 345550 - Foreign Currency Amounts inaccurate in Transaction Report
Summary: Foreign Currency Amounts inaccurate in Transaction Report
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: 4.6.6
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-26 15:18 UTC by JAH
Modified: 2015-03-29 13:16 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.7.2


Attachments
TEst1.kmy (6.01 KB, application/x-kmymoney)
2015-03-27 00:25 UTC, JAH
Details

Note You need to log in before you can comment on or make changes to this bug.
Description JAH 2015-03-26 15:18:47 UTC
When reporting the transactions for a Foreign Currency account (US$ in my case) in the Foreign Currency (i.e with the box "Convert values to base currency" UNticked, Kmymoney does not seem to report the original foreign currency transaction amount as stored in the database (and shown correctly in the account) but instead it appears recalculate the orignal foreign amount as a multiple of the base currency amount and the stored exchange rate price. This leads to significant changes in value for larger sums and completely incorrect velues when no exchange rate was stored (i.e if the amount was converted to an absolute value when posted - which seems to record a rate of 1 against he transaction.

If this analysis is correct - would it to be better for the report to reference the foreign amount as stored in the database for the report rather than tryimng to recalculate it from the base currency value and a rounded exchange rate.

Reproducible: Always

Steps to Reproduce:
1. Create a few transactions in a foreign currency account, some posted via exchange rates and some converted to absolute amounts inthe base currency
2.Run the transactions report for the account with the option "Convert values to base currency" UNticked
3.Compare the report foreign values to those stored in the account

Actual Results:  
The foreign currency amount is frequently reported inaccurately - sometimes wildly

Expected Results:  
the report of a foreign currency account transactions, in that foreign currency should be 100% accurate. The reprot should reference the foreign currency value as stored in the database and shown in the account screen
Comment 1 Cristian Oneț 2015-03-26 15:26:47 UTC
Could you create a test file or an anonymous test file that demonstrates this problem? Take a look at this description of the anonymous file:
https://docs.kde.org/stable/en/extragear-office/kmymoney/details.formats.anonymous.html

I'm asking for this because last time I've checked a report for an account using a currency other than the base currency everything looked fine. The fact that you said that you had the currency conversion checkbox unchecked makes me even more suspicious since in that case there is really no conversion of values performed so the amounts should match those in the account.
Comment 2 JAH 2015-03-27 00:25:55 UTC
Created attachment 91761 [details]
TEst1.kmy

Hi Cristian,

Thanks you for the very quick reply. I have attached a test .kmy file 
which seems to clearly demonstrate the issue.

I have posted 2 transactions to the Foreign account. The first I 
converted to an absolute GBP value and the second I used an exchange 
rate. If you run the Transactions report for the account you'll see it 
does not accurately reflect the Dollar amounts posted when the "use base 
currency" box is unchecked. I saved the report as a Transaction report too.

I trust the fault is not mine and that this helps identify the problem 
(in an otherwise great piece of software)

Regards
John


On 26/03/15 15:26, Cristian Oneț wrote:
> https://bugs.kde.org/show_bug.cgi?id=345550
>
> Cristian Oneț <onet.cristian@gmail.com> changed:
>
>             What    |Removed                     |Added
> ----------------------------------------------------------------------------
>               Status|UNCONFIRMED                 |NEEDSINFO
>                   CC|                            |onet.cristian@gmail.com
>           Resolution|---                         |WAITINGFORINFO
>
> --- Comment #1 from Cristian Oneț <onet.cristian@gmail.com> ---
> Could you create a test file or an anonymous test file that demonstrates this
> problem? Take a look at this description of the anonymous file:
> https://docs.kde.org/stable/en/extragear-office/kmymoney/details.formats.anonymous.html
>
> I'm asking for this because last time I've checked a report for an account
> using a currency other than the base currency everything looked fine. The fact
> that you said that you had the currency conversion checkbox unchecked makes me
> even more suspicious since in that case there is really no conversion of values
> performed so the amounts should match those in the account.
>
Comment 3 Thomas Baumgart 2015-03-27 12:18:55 UTC
I saw the problem. From looking at the file, things seem to be stored correctly. One other thing to be aware of: in case you check the 'convert all values to base currency' then the opening balance is not adjusted. That could be due to a missing price information. For the other transactions we do have a price: the one that is stored with the transaction. This certainly looks like a little bug. Thanks to John for reporting and providing a test file.
Comment 4 Cristian Oneț 2015-03-27 17:20:10 UTC
(In reply to Thomas Baumgart from comment #3)
> I saw the problem. From looking at the file, things seem to be stored
> correctly. One other thing to be aware of: in case you check the 'convert
> all values to base currency' then the opening balance is not adjusted. That
> could be due to a missing price information. For the other transactions we
> do have a price: the one that is stored with the transaction. This certainly
> looks like a little bug. Thanks to John for reporting and providing a test
> file.

I've identified the problem, it was introduced by this fix:

https://projects.kde.org/projects/extragear/office/kmymoney/repository/revisions/9fc583d3db4fe2c16448790d7ee17145fbe8bd2f

I've added a testcase to catch the issue and proposed a fix at:

https://git.reviewboard.kde.org/r/123154/
Comment 5 Cristian Oneț 2015-03-27 17:29:53 UTC
Git commit 31adc38e7d632fb79eb3163998c8c568ee957383 by Cristian Oneț.
Committed on 27/03/2015 at 17:08.
Pushed by conet into branch 'master'.

Fix foreign currency income/expense transactions in reports.

Since commit 9fc583d3db4fe2c16448790d7ee17145fbe8bd2f was added as a
fix for some currency conversions performed in reports income/expense
transactions which involved a currency conversion were not properly
displayed in the transactions by account report.

Extended the multi-currency report testcase to catch this error and
fixed the problem by resurrecting some conversion code which was
removed by that commit, but moved it to a place where it's applied
only to income/expense transactions.
REVIEW: 123154

M  +6    -1    kmymoney/reports/querytable.cpp
M  +7    -2    kmymoney/reports/querytabletest.cpp

http://commits.kde.org/kmymoney/31adc38e7d632fb79eb3163998c8c568ee957383
Comment 6 Cristian Oneț 2015-03-27 17:30:55 UTC
Git commit 7b10760b947432e77078ade8d6ef1557321b3a74 by Cristian Oneț.
Committed on 27/03/2015 at 17:08.
Pushed by conet into branch '4.7'.

Fix foreign currency income/expense transactions in reports.

Since commit 9fc583d3db4fe2c16448790d7ee17145fbe8bd2f was added as a
fix for some currency conversions performed in reports income/expense
transactions which involved a currency conversion were not properly
displayed in the transactions by account report.

Extended the multi-currency report testcase to catch this error and
fixed the problem by resurrecting some conversion code which was
removed by that commit, but moved it to a place where it's applied
only to income/expense transactions.
REVIEW: 123154
(cherry picked from commit 31adc38e7d632fb79eb3163998c8c568ee957383)

M  +6    -1    kmymoney/reports/querytable.cpp
M  +7    -2    kmymoney/reports/querytabletest.cpp

http://commits.kde.org/kmymoney/7b10760b947432e77078ade8d6ef1557321b3a74
Comment 7 Thomas Baumgart 2015-03-29 06:05:09 UTC
Sorry to have to reopen this: using the attaced test file still does not show correct results when the 'convert all values to base currency' option is set/removed. The values do not change, only the currency is identified in case the option is turned off (USD in our case). I thought this would be caused by the conversion rate in the test file which is set to 1, but even if you change the rate to e.g. 1.5 , the values do not change in the report if the option is turned on.
Comment 8 Cristian Oneț 2015-03-29 12:04:13 UTC
(In reply to Thomas Baumgart from comment #7)
> Sorry to have to reopen this: using the attaced test file still does not
> show correct results when the 'convert all values to base currency' option
> is set/removed. The values do not change, only the currency is identified in
> case the option is turned off (USD in our case). I thought this would be
> caused by the conversion rate in the test file which is set to 1, but even
> if you change the rate to e.g. 1.5 , the values do not change in the report
> if the option is turned on.

You are right, the code I brought back was originally on the else branch of the if 'convert all values to base currency' so I must add that check, I'll fix it in a minute.
Comment 9 Cristian Oneț 2015-03-29 13:11:24 UTC
Git commit 6780bf61922eab24542f5d02b29a17b0df12299d by Cristian Oneț.
Committed on 29/03/2015 at 12:48.
Pushed by conet into branch 'master'.

Fix foreign currency income/expense transactions in reports.

The previous commit broke the convert all values to the base currency
use case. Fixed this by properly checking that flag before converting
a split's value to the currency of the starting account.

Extended the multiple currencies report test case to check this
scenario.

M  +1    -1    kmymoney/reports/querytable.cpp
M  +32   -1    kmymoney/reports/querytabletest.cpp

http://commits.kde.org/kmymoney/6780bf61922eab24542f5d02b29a17b0df12299d
Comment 10 Cristian Oneț 2015-03-29 13:16:54 UTC
Git commit e3967e5918ba887c69e4de809605072686bc2f91 by Cristian Oneț.
Committed on 29/03/2015 at 12:48.
Pushed by conet into branch '4.7'.

Fix foreign currency income/expense transactions in reports.

The previous commit broke the convert all values to the base currency
use case. Fixed this by properly checking that flag before converting
a split's value to the currency of the starting account.

Extended the multiple currencies report test case to check this
scenario.
(cherry picked from commit 6780bf61922eab24542f5d02b29a17b0df12299d)

M  +1    -1    kmymoney/reports/querytable.cpp
M  +32   -1    kmymoney/reports/querytabletest.cpp

http://commits.kde.org/kmymoney/e3967e5918ba887c69e4de809605072686bc2f91