Bug 373966 - Incorrect rates used during a report
Summary: Incorrect rates used during a report
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: 4.7.2
Platform: macOS (DMG) macOS
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-20 16:10 UTC by Will Holland
Modified: 2017-07-01 11:06 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.0.0


Attachments
GBP Account and EUR Category example to reproduce bug (24.99 KB, application/xml)
2016-12-24 17:54 UTC, Mark
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Will Holland 2016-12-20 16:10:57 UTC
I'm using kmymoney for mac os x - version: 4.7.2

When I view my income/expence report, with everything converted to £ (my default currency), I see that I have some errors.

Specifically I have one category with two transactions in it.  One is a refund, and so the exchange rate was maintained for this transaction (i.e. within the transaction I have used the same value for £ and for €).

When I look at the report, this category is not zero - i.e. the exchange rate applied for that conversion appears to be different to the ones in the transactions.

So: Steps to reproduce.
1. Create account in £
2. Create Category in €
3. Create transaction on day 1, between account and category.  Set exchange rate, and verify totals.
4. Create transaction on day 2, between account and category.  Set exchange rate and verify totals.
5. Create other transactions between other accounts and other categories that may also define the exchange rates for day1 and day2.
6. look at income and expense by month, and note that although the total for the category is 0 in the leger view, it is not 0 in the transaction view.
Comment 1 Mark 2016-12-24 17:54:35 UTC
Created attachment 102979 [details]
GBP Account and EUR Category example to reproduce bug

I reproduced this on 4.8.0 (Ubuntu) so 4.7.2 (OSX) behaviour may be different. Using the attached file, it can be seen that the ledger view is correct but the "Transactions by Month" report is converting the 80 EUR transaction to 120 GBP using the incorrect exchange rate on 20/12/2016. It is using the GBP/EUR exchange rate entered for the second transaction (300GBP=200EUR) instead of the rate entered for the first transaction (100GBP=80EUR).
Comment 2 Mark 2016-12-24 19:35:23 UTC
All the reports appear to be doing a forex rate lookup based on the post date of the transaction rather than the actual rate used. From looking at the generated XML, the correct forex rate is stored in the split transaction (rate = shares / value) but any fix would be complicated by the fact that this rate may have nothing to do with the currently set base currency. One would presumably have to look at the currency of the account on other side of the split and if it is the same as the base currency then the (shares/value) can be used as the forex rate for reporting.
Comment 3 NSLW 2017-02-17 20:34:56 UTC
Git commit 622dab3f94878c501518795aa00c102d10562a1a by Łukasz Wojniłowicz.
Committed on 17/02/2017 at 20:15.
Pushed by wojnilowicz into branch 'master'.

Revise investment transaction report

Summary:
Price of transaction should be taken from transaction and not from
stored prices.
Investment accounts should report asset split as main split for correct
amount value, as it contains fees.
Related: bug 365306
Signed-off-by: Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>

Differential Revision: https://phabricator.kde.org/D4445

Signed-off-by: Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>

M  +99   -45   kmymoney/reports/querytable.cpp
M  +7    -7    kmymoney/reports/tests/querytable-test.cpp
M  +1    -1    kmymoney/reports/tests/reportstestcommon.cpp

https://commits.kde.org/kmymoney/622dab3f94878c501518795aa00c102d10562a1a