Bug 382245

Summary: Reports not showing correct totals for split transactions
Product: [Applications] kmymoney Reporter: Christopher Tanner <christann404>
Component: reportsAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: major CC: koalinux, ralf.habacker
Priority: NOR Keywords: regression
Version: git (master)   
Target Milestone: ---   
Platform: OpenMandriva   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=395327
Latest Commit: Version Fixed In: 5.2.0
Sentry Crash Report:
Bug Depends on: 448788    
Bug Blocks: 488491    
Attachments: Demo file to duplicate the problem on master
Report screenshot from recent 4.8
Screenshot of the associated report with currency conversion and the initial problem
Screenshot of the associated report without currency conversion and the initial problem
Updated demo file including the associated reports
Updated demo file including multi currency account and the associated reports
Screenshot of the associated report with currency conversion and incorrect patch applied
Screenshot of the associated report without currency conversion and incorrect patch applied
Screenshot of the associated report with currency conversion and the initial problem
Screenshot of the associated report without currency conversion and the initial problem
Screenshot of the associated report without currency conversion (Version 4)
Screenshot of the associated report with currency conversion (Version 4)

Description Christopher Tanner 2017-07-11 15:51:36 UTC
Running kmymoney vs 4.100.3474270. 

When I create a transaction report by category, entries which are splits show the amount from the master transaction, not the actual split amount.
Comment 1 Thomas Baumgart 2017-07-13 14:38:41 UTC
Created attachment 106591 [details]
Demo file to duplicate the problem on master

Using this demo file run a Transaction-Report by Category. It shows 1000 in both income categories but not amounts of the splits (which sum up to 1000). This used to work in the 4.8 branch (and still might - I have not tested it). Maybe someone can check this on a recent 4.8 version.
Comment 2 wojnilowicz 2017-07-13 17:44:18 UTC
Git commit 467f0cc2d07104d4770868c8b8b3b6d16345700d by Łukasz Wojniłowicz.
Committed on 13/07/2017 at 17:43.
Pushed by wojnilowicz into branch 'master'.

Show correct totals for Transactions by Category
FIXED-IN:5.0
Signed-off-by: Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>

M  +9    -1    kmymoney/reports/querytable.cpp

https://commits.kde.org/kmymoney/467f0cc2d07104d4770868c8b8b3b6d16345700d
Comment 3 Christopher Tanner 2017-07-13 18:35:16 UTC
That fixed the problem. Thanks

Chris
Comment 4 wojnilowicz 2017-07-13 19:12:36 UTC
(In reply to Christopher Tanner from comment #3)
> That fixed the problem. Thanks
> 
> Chris

No problem. Please report if something is not working as before. It's very needed. The best way is just like Thomas did it i.e. with .kmy test file attached.

Łukasz
Comment 5 Ralf Habacker 2017-07-14 06:24:13 UTC
Created attachment 106608 [details]
Report screenshot from recent 4.8

(In reply to Thomas Baumgart from comment #1)
> This used to work in the 4.8 branch (and still might - I have not tested
> it). Maybe someone can check this on a recent 4.8 version.

Screenshot from 4.8 has been appended
Comment 6 Thomas Baumgart 2017-07-30 11:52:34 UTC
*** Bug 380194 has been marked as a duplicate of this bug. ***
Comment 7 Ralf Habacker 2024-09-03 01:26:26 UTC
(In reply to NSLW from comment #2)
...
> Show correct totals for Transactions by Category
> FIXED-IN:5.0
> Signed-off-by: Łukasz Wojniłowicz <lukasz.wojnilowicz@gmail.com>
> 
> M  +9    -1    kmymoney/reports/querytable.cpp
> 
> https://commits.kde.org/kmymoney/467f0cc2d07104d4770868c8b8b3b6d16345700d

This commit breaks the display with multiple currencies, as reported with bug 448788.
Comment 8 Ralf Habacker 2024-09-03 01:29:23 UTC
Created attachment 173254 [details]
Screenshot of the associated report with currency conversion and the initial problem
Comment 9 Ralf Habacker 2024-09-03 01:30:20 UTC
Created attachment 173255 [details]
Screenshot of the associated report without currency conversion and the initial problem
Comment 10 Ralf Habacker 2024-09-03 01:31:25 UTC
Created attachment 173256 [details]
Updated demo file including the associated reports
Comment 11 Ralf Habacker 2024-09-03 02:07:28 UTC
Created attachment 173257 [details]
Updated demo file including multi currency account and the associated reports
Comment 12 Ralf Habacker 2024-09-03 02:08:38 UTC
Created attachment 173258 [details]
Screenshot of the associated report with currency conversion and incorrect patch applied
Comment 13 Ralf Habacker 2024-09-03 02:09:40 UTC
Created attachment 173259 [details]
Screenshot of the associated report without currency conversion and incorrect patch applied
Comment 14 Ralf Habacker 2024-09-03 02:14:41 UTC
Created attachment 173260 [details]
Screenshot of the associated report with currency conversion and the initial problem
Comment 15 Ralf Habacker 2024-09-03 02:15:55 UTC
Created attachment 173261 [details]
Screenshot of the associated report without currency conversion and the initial problem
Comment 16 Ralf Habacker 2024-09-03 02:29:39 UTC
Created attachment 173262 [details]
Screenshot of the associated report without currency conversion (Version 4)
Comment 17 Ralf Habacker 2024-09-03 02:30:10 UTC
Created attachment 173263 [details]
Screenshot of the associated report with currency conversion (Version 4)
Comment 18 Ralf Habacker 2024-09-05 05:38:53 UTC
(In reply to Ralf Habacker from comment #13)
> Created attachment 173259 [details]
> Screenshot of the associated report without currency conversion and  incorrect patch applied
https://bugs.kde.org/attachment.cgi?id=173259

Apart from the fact that using the same VAT account (EUR) for the transaction in FRF might be wrong, this report seems correct to me.
Comment 19 Ralf Habacker 2024-09-05 20:54:57 UTC
(In reply to Ralf Habacker from comment #12)
> Created attachment 173258 [details]
> Screenshot of the associated report with currency conversion and incorrect patch applied

This reports looks incorrect to me. It should be like this.

(In reply to Ralf Habacker from comment #17)
> Created attachment 173263 [details]
> Screenshot of the associated report with currency conversion (Version 4)
Comment 20 Bug Janitor Service 2024-09-08 06:08:52 UTC
A possibly relevant merge request was started @ https://invent.kde.org/office/kmymoney/-/merge_requests/232
Comment 21 Ralf Habacker 2024-09-26 19:01:54 UTC
Git commit fd13f447e138b4f3fee690edf36e7566173e4c36 by Ralf Habacker.
Committed on 26/09/2024 at 19:01.
Pushed by habacker into branch 'master'.

Add note that report results may be incorrect

This note can be removed once the cause of the discrepancies has been
resolved or limited to specific reports once the causes have been
narrowed down.

M  +4    -0    kmymoney/plugins/views/reports/core/pivottable.cpp
M  +5    -0    kmymoney/plugins/views/reports/core/querytable.cpp
M  +10   -0    kmymoney/plugins/views/reports/core/reporttable.cpp
M  +5    -0    kmymoney/plugins/views/reports/core/reporttable.h

https://invent.kde.org/office/kmymoney/-/commit/fd13f447e138b4f3fee690edf36e7566173e4c36
Comment 22 Ralf Habacker 2024-10-24 04:26:26 UTC
The issue is also present in the actual git master branch.
Comment 23 Ralf Habacker 2024-10-30 14:21:34 UTC
Git commit b4f6901f8b685e88d9f6423e7043ede26c9ea382 by Ralf Habacker.
Committed on 30/10/2024 at 13:36.
Pushed by habacker into branch 'master'.

Add test case for bug 382245

M  +1    -0    kmymoney/plugins/views/reports/core/tests/data/CMakeLists.txt
A  +20   -0    kmymoney/plugins/views/reports/core/tests/data/test-382245-report-querytable-Buchungen-nach-Kategorie-_mit-Umrechnung_.csv
A  +22   -0    kmymoney/plugins/views/reports/core/tests/data/test-382245-report-querytable-Buchungen-nach-Kategorie-_ohne-Umrechnung_.csv
A  +209  -0    kmymoney/plugins/views/reports/core/tests/data/test-382245.xml

https://invent.kde.org/office/kmymoney/-/commit/b4f6901f8b685e88d9f6423e7043ede26c9ea382
Comment 24 Ralf Habacker 2024-10-30 14:21:36 UTC
Git commit a346d765a181c6a080102d4c2308dad36f93daa0 by Ralf Habacker.
Committed on 30/10/2024 at 14:14.
Pushed by habacker into branch 'master'.

Revert "Add note that report results may be incorrect"

As the related issue has been fixed, this message is
now obsolate and can be removed.

This reverts commit fd13f447e138b4f3fee690edf36e7566173e4c36.

M  +0    -4    kmymoney/plugins/views/reports/core/pivottable.cpp
M  +0    -5    kmymoney/plugins/views/reports/core/querytable.cpp
M  +0    -10   kmymoney/plugins/views/reports/core/reporttable.cpp
M  +0    -5    kmymoney/plugins/views/reports/core/reporttable.h

https://invent.kde.org/office/kmymoney/-/commit/a346d765a181c6a080102d4c2308dad36f93daa0
Comment 25 Ralf Habacker 2024-10-30 14:21:42 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 448788
FIXED-IN:5.2.0

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

https://invent.kde.org/office/kmymoney/-/commit/eec2645f3a5623a32390d209169c780a8c5c653e