Bug 457832 - Net worth report displays incorrect account balance
Summary: Net worth report displays incorrect account balance
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: reports (show other bugs)
Version: 5.1.2
Platform: Appimage Linux
: NOR major
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks: 488491
  Show dependency treegraph
 
Reported: 2022-08-13 10:15 UTC by Ceaus
Modified: 2024-11-18 19:49 UTC (History)
2 users (show)

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


Attachments
KMyMoney data file (8.91 KB, text/xml)
2022-08-13 10:15 UTC, Ceaus
Details
Screenshot of the incorrect balance values (32.54 KB, image/png)
2022-08-13 10:16 UTC, Ceaus
Details
Extended test case to reproduce the reported behavior (9.45 KB, text/xml)
2024-10-10 14:37 UTC, Ralf Habacker
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ceaus 2022-08-13 10:15:35 UTC
Created attachment 151299 [details]
KMyMoney data file

SUMMARY
A Net-Worth report displays incorrect asset values.
I have an account with outstanding balances set to zero in 2014. Depending on how the date range of the report is set, the report still displays a positive balance for dates > 2014.  This gravely compromises the reporting value. 

STEPS TO REPRODUCE
1. Open the attached data file bug_report_v5.xml.
2. Open the ledger for account A2 and observe the balance is zero on 2014-09-03.
3. Open the ledger for account A3 and observe the balance is zero on 2014-09-03.
4. Open the favorite report R1. 
5. Observe how the balance for A2 is €500 from 2014 onwards (while the balance is in fact zero).
6. Observe how the balance for A3 is €12625.26 from 2014 onwards (while the balance is in fact zero).
7. Configure report R1. Any date change, even if using the same dates, will produce a correct report.

Please be aware that if A2 and A3 are closed (and thus invisible) it is extremely difficult to understand why your current asset values are incorrect.

SOFTWARE/OS VERSIONS
KMyMoney: AppImage 5.1.2-cb0b492
Linux version: openSUSE Leap 15.3
KDE Plasma Version: 5.76.0-bp153.5.2.1
KDE Frameworks Version: 5.51.0
Qt Version: 5.11.3


ADDITIONAL INFORMATION
I've tried to export the data file as an anonymous file, but that created a big mess, so I trimmed down the data file manually to minimum size, and anonymized it manually.
Comment 1 Ceaus 2022-08-13 10:16:29 UTC
Created attachment 151300 [details]
Screenshot of the incorrect balance values
Comment 2 Thomas Baumgart 2022-08-13 13:21:09 UTC
I don't know how you end up with this report configuration. In your description I simply replaced step 7 with

7. Configure report R1. Press Apply w/o any changes

and the report is shown correct. If I save the file and then try to reproduce the problem it is gone. Looking at the raw configuration of the report it has an active filter for category (C1). That is the reason why all your transfer transactions are not taken into account. For a net worth report it does not make sense to filter on categories.

Do you have a category filter setup on your original report? What happens, if you remove it?
Comment 3 Ceaus 2022-08-13 13:59:07 UTC
(In reply to Thomas Baumgart from comment #2)
> I don't know how you end up with this report configuration. 

As simple as point-click-point-click-ENTER

> In your description I simply replaced step 7 with
> 7. Configure report R1. Press Apply w/o any changes and the report is shown correct.

Same here.

> If I save the file and then try to reproduce the problem it is gone.

Same here.

> Looking at the raw configuration of the
> report it has an active filter for category (C1). That is the reason why all
> your transfer transactions are not taken into account. For a net worth
> report it does not make sense to filter on categories.
> Do you have a category filter setup on your original report?

This is for fiscal reasons. I have a (very) small company, and when submitting the balance sheet, I have to exclude taxes from the balance sheet (that's a side effect of Dutch tax laws). So category C1 is in fact the "Paid taxes this year"  category.
I was hoping to be able to run the balance sheet without having to worry about paid taxes during the year. It seems I need to make it a double run: first run the balance sheet (no categories selected) and then manually process the paid taxes.

Would you agree the initial finding (as per the screenshot) is a bug?

> What happens, if you remove it?

Than I get the correct balances. Somehow I've missed the warning for missing the transfer transactions. Which is stupid as I've been using KMM for more than a decade, and I've seen all screens hundreds and hundreds of time. I feel stupid.
Comment 4 Ceaus 2022-08-13 14:08:50 UTC
(In reply to Ceaus from comment #3)
> (In reply to Thomas Baumgart from comment #2)
> > In your description I simply replaced step 7 with
> > 7. Configure report R1. Press Apply w/o any changes and the report is shown correct.
> 
> Same here.

Just to be aware: this is for this debug data file. In my original financial file this doesn't work. If tried changing the reporting start/end dates, change the storage type (kmy/xml/sql), but that trick doesn't work. Still a lagging account balance, while the balance should already be zero. 

> > If I save the file and then try to reproduce the problem it is gone.
> 
> Same here.

See above.

Just to remove all doubt: I'm now trying the  AppImage version kmymoney-5.1-179-linux-64-gcc.AppImage (that's the latest Jenkins successful build from https://binary-factory.kde.org/view/AppImage/job/KMyMoney_Release_appimage-centos7/.
The results and behavior are the same.
Comment 5 lp.allard.1 2022-08-13 20:54:55 UTC
@Ceaus,

please look at bug ticket https://bugs.kde.org/show_bug.cgi?id=450653 and see if its the same issue or not.  I already reported something similar a while ago regarding balances in reports.
Comment 6 Ceaus 2022-08-14 05:11:28 UTC
(In reply to lp.allard.1 from comment #5)
> @Ceaus,
> 
> please look at bug ticket https://bugs.kde.org/show_bug.cgi?id=450653 and
> see if its the same issue or not. 

450653 certainly has similarities. But it's out of my reach to conclude they are the same bug.
Comment 7 Bug Janitor Service 2024-10-10 10:57:11 UTC
A possibly relevant merge request was started @ https://invent.kde.org/office/kmymoney/-/merge_requests/233
Comment 8 Ralf Habacker 2024-10-10 12:46:03 UTC
Git commit 1b910da0972834625681d8b34bb464024da9697b by Ralf Habacker.
Committed on 10/10/2024 at 10:54.
Pushed by habacker into branch 'master'.

Unify writing tables in pivottable and querytable tests

The name of the output file for writing tables to files is now taken from
the report name and the test results are now saved in csv and html format.

M  +23   -23   kmymoney/plugins/views/reports/core/tests/pivottable-test.cpp
M  +26   -38   kmymoney/plugins/views/reports/core/tests/querytable-test.cpp

https://invent.kde.org/office/kmymoney/-/commit/1b910da0972834625681d8b34bb464024da9697b
Comment 9 Ralf Habacker 2024-10-10 14:37:31 UTC
Created attachment 174632 [details]
Extended test case to reproduce the reported behavior

This test case can be used to reproduce the reported behavior, regardless of whether the report has been saved or not.
Comment 10 Ralf Habacker 2024-10-10 14:43:31 UTC
It could help in this and other cases if corresponding warnings are issued not only when configuring the dialog, but also directly in the report.
Comment 11 Bug Janitor Service 2024-11-17 12:08:04 UTC
A possibly relevant merge request was started @ https://invent.kde.org/office/kmymoney/-/merge_requests/241
Comment 12 Thomas Baumgart 2024-11-18 19:49:58 UTC
Git commit d35ba243ec14a42a4bc62b3ceab7cb0ac48dc3ea by Thomas Baumgart, on behalf of Thomas Baumgart.
Committed on 18/11/2024 at 19:30.
Pushed by tbaumgart into branch 'master'.

Prevent to filter on categories in net worth reports

Applying category filters on a networth report yields in false results.
Therefore, all categories are selected by default for this report type
and a modification is prevented.
FIXED-IN: 5.2

M  +6    -0    kmymoney/mymoney/mymoneyreport.cpp
M  +6    -0    kmymoney/mymoney/mymoneyreport.h
M  +8    -1    kmymoney/mymoney/mymoneytransactionfilter.cpp
M  +5    -0    kmymoney/mymoney/mymoneytransactionfilter.h
M  +5    -0    kmymoney/plugins/views/reports/core/pivottable.cpp
M  +9    -0    kmymoney/widgets/ktransactionfilter.cpp
M  +23   -8    kmymoney/widgets/ktransactionfilter.ui

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