Bug 448788 - Incorrect Currency Conversion in Reports
Summary: Incorrect Currency Conversion in Reports
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: reports (show other bugs)
Version: 5.1.1
Platform: Other Linux
: NOR grave
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
: 451269 (view as bug list)
Depends on:
Blocks: 488491 382245
  Show dependency treegraph
 
Reported: 2022-01-19 19:11 UTC by JAH
Modified: 2024-10-30 14:21 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.2
Sentry Crash Report:


Attachments
test case (5.33 KB, text/xml)
2024-08-28 22:44 UTC, Ralf Habacker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description JAH 2022-01-19 19:11:36 UTC
SUMMARY
***
Incorrect Currency Conversion in Reports 
***
Transaction reports of foreign currency transactions (dividends in my case) do not work as intended. Selecting "Convert Values to base Currency" corrupts values and provides erroneous totals (which should not bethere since the reports contains mixed currencies). NOT selecting  "Convert Values to base Currency" DOES convert values into the base currency with correct values & totals (and a nuisance currency code before each value when their all in the base currency. An inability to report accurately invalidates storing the data.

STEPS TO REPRODUCE
1. Create a foreign currency dividend
2. Run the report "Transactions by Category"
3. Tick the box "Convert Values to base Currency"

OBSERVED RESULT
The report of foreign values are wrong and not converted to the base currency

EXPECTED RESULT
Foreign values should be converted to the base currency

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
kmymoney: 5.1.1-ad14462
Linux/KDE Plasma: opensuse 15.2 
(available in About System)
KDE Plasma Version: 15.8.6
KDE Frameworks Version: 5.71.0
Qt Version: 5.12.7

ADDITIONAL INFORMATION
This is a variation of bug 419519 in Vn 5.0.8
Do NOT tick the "Convert Values to base Currency" box & foreign values WILL be converted to base currency (and totalled correctly).
DO tick "Convert Values to base Currency" & random wrong values appear with erroneous totals.
Comment 1 Thomas Baumgart 2022-03-12 18:32:51 UTC
*** Bug 451269 has been marked as a duplicate of this bug. ***
Comment 2 Ralf Habacker 2024-08-28 22:44:06 UTC
Created attachment 173063 [details]
test case

I checked this with a build from the master branch with the appended test case and think that there is an issue.

In the report "Buchungen nach Kategorie (mit Umrechnung)" there is 

dividend 29.08.2024  [Leerer Zahlungsempfänger] [Kein Stichwort] checking (BTC)  0,57

while in the report "Buchungen nach Kategorie (ohne Umrechnung)" there is 

    dividend 29.08.2024 [Leerer Zahlungsempfänger] [Kein Stichwort] checking (BTC) EUR 0,57

Shouldn't “BTC 0,00001000” be displayed there ?
Comment 3 Ralf Habacker 2024-08-29 19:54:53 UTC
(In reply to Ralf Habacker from comment #2)
> while in the report "Buchungen nach Kategorie (ohne Umrechnung)" there is 
> 
>     dividend 29.08.2024 [Leerer Zahlungsempfänger] [Kein Stichwort] checking (BTC) EUR 0,57
> 
> Shouldn't “BTC 0,00001000” be displayed there ?

.. which is displayed with kmymoney version 4.8
Comment 4 Ralf Habacker 2024-08-29 21:10:47 UTC
(In reply to Ralf Habacker from comment #3)
> (In reply to Ralf Habacker from comment #2)
> > while in the report "Buchungen nach Kategorie (ohne Umrechnung)" there is 
> > 
> >     dividend 29.08.2024 [Leerer Zahlungsempfänger] [Kein Stichwort] checking (BTC) EUR 0,57
> > 
> > Shouldn't “BTC 0,00001000” be displayed there ?
> 
> .. which is displayed with kmymoney version 4.8

Also the tooltip in the checkbox for "Convert values to base currency" (https://invent.kde.org/office/kmymoney/-/blob/master/kmymoney/plugins/views/reports/reporttabgeneral.ui#L68) shows

> Select this option to convert all values in the report to your base currency.
> Leave it unchecked if you would like to see values in their original currency. 
> If currencies are not converted, then subtotals will not be shown.
Comment 5 Ralf Habacker 2024-08-29 22:25:18 UTC
Commit https://invent.kde.org/office/kmymoney/commit/467f0cc2d07104d4770868c8b8b3b6d16345700d has been added to fix the error 382245 is responsible for this problem. A revert shows the amount in the currency of the account in question.
Comment 6 Bug Janitor Service 2024-09-05 15:53:18 UTC
A possibly relevant merge request was started @ https://invent.kde.org/office/kmymoney/-/merge_requests/230
Comment 7 Bug Janitor Service 2024-09-05 16:00:21 UTC
A possibly relevant merge request was started @ https://invent.kde.org/office/kmymoney/-/merge_requests/231
Comment 8 Ralf Habacker 2024-09-15 06:48:28 UTC
Git commit b71085f8ad71eb614b69483190056b53d7264081 by Ralf Habacker.
Committed on 15/09/2024 at 06:24.
Pushed by habacker into branch 'master'.

Add test case for working reports

Currently the report with currency conversion has been added
for testing as it looks as expected.

M  +1    -0    kmymoney/plugins/views/reports/core/tests/data/CMakeLists.txt
A  +9    -0    kmymoney/plugins/views/reports/core/tests/data/test-448788-report-querytable-Buchungen-nach-Kategorie-_mit-Umrechnung_.csv
A  +200  -0    kmymoney/plugins/views/reports/core/tests/data/test-448788.xml

https://invent.kde.org/office/kmymoney/-/commit/b71085f8ad71eb614b69483190056b53d7264081
Comment 9 Ralf Habacker 2024-09-15 06:48:36 UTC
Git commit bf6ec53563beff53c52c0d0eabc82e664be0bad9 by Ralf Habacker.
Committed on 15/09/2024 at 06:24.
Pushed by habacker into branch 'master'.

Add reference file with expected behavior without currency conversion

A  +9    -0    kmymoney/plugins/views/reports/core/tests/data/test-448788-report-querytable-Buchungen-nach-Kategorie-_ohne-Umrechnung_.csv

https://invent.kde.org/office/kmymoney/-/commit/bf6ec53563beff53c52c0d0eabc82e664be0bad9
Comment 10 Ralf Habacker 2024-09-15 06:59:24 UTC
Git commit 26c6a5c827be45c2021f4d53af03c4a7f142ecb9 by Ralf Habacker.
Committed on 15/09/2024 at 06:33.
Pushed by habacker into branch 'master'.

Fix not showing correct currency in multi currency category report

The basic fix has been extracted from the 4.8 branch.
FIXED-IN:5.2

M  +15   -8    kmymoney/plugins/views/reports/core/querytable.cpp

https://invent.kde.org/office/kmymoney/-/commit/26c6a5c827be45c2021f4d53af03c4a7f142ecb9
Comment 11 Ralf Habacker 2024-10-30 14:21:44 UTC
Git commit eec2645f3a5623a32390d209169c780a8c5c653e by Ralf Habacker.
Committed on 30/10/2024 at 14:14.
Pushed by habacker into branch 'master'.

Fix conversion to base currency for reports containing categories

The previously used logic to recognize the conversion to the base
currency was not correct for the report mentioned in this error.

It was added to fix bug 448788 and worked there because the base
currency was taken from the first split, which happened to be the
same as the one from the file.

In general, when converting to the base currency, the base currency
of the file should be used and not the currency from the first split,
which has been corrected with this commit.
Related: bug 382245
FIXED-IN:5.2.0

M  +2    -2    kmymoney/plugins/views/reports/core/querytable.cpp

https://invent.kde.org/office/kmymoney/-/commit/eec2645f3a5623a32390d209169c780a8c5c653e
Comment 12 Ralf Habacker 2024-10-30 14:21:52 UTC
Git commit 95e46fc151cfdabc5493983800facb32475d41a2 by Ralf Habacker.
Committed on 30/10/2024 at 14:15.
Pushed by habacker into branch 'master'.

Correction of the expected test report values for “test-448788.xml”

After the problem reported in bug 382245 was fixed, the expected values
in the report “Bookings by category without conversion” from the
mentioned test have changed and need to be adjusted.

M  +5    -5    kmymoney/plugins/views/reports/core/tests/data/test-448788-report-querytable-Buchungen-nach-Kategorie-_ohne-Umrechnung_.csv

https://invent.kde.org/office/kmymoney/-/commit/95e46fc151cfdabc5493983800facb32475d41a2