Bug 447025

Summary: Calculation of the balance is incorrect for future balances
Product: [Applications] kmymoney Reporter: mayerw <wolfgang>
Component: reportsAssignee: KMyMoney Devel Mailing List <kmymoney-devel>
Status: RESOLVED FIXED    
Severity: major    
Priority: NOR    
Version: 5.1.2   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 5.1.3
Sentry Crash Report:

Description mayerw 2021-12-15 13:15:09 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***


STEPS TO REPRODUCE
1. Open KMyMoney
2. Check the balance in the future payments
3. in the 5th row for some reason there is some money added although there is a negative payment expected. 

OBSERVED RESULT
balance increased

EXPECTED RESULT
balance decreased

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Ubuntu 21.10 
(available in About System)
KDE Plasma Version: 5.22.5
KDE Frameworks Version: 5.86.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
Comment 1 Thomas Baumgart 2021-12-15 16:23:45 UTC
Your description is a bit misleading. Hence the following questions to get clarity:

- do you mean the "Future payments" section on the home view?
- do you mean the 5th column (which shows a balance information) rather than the 5th row?
- which type does the account you see this happening for has?
- what do you mean by "negative payment"? A deposit?
Comment 2 mayerw 2021-12-15 16:57:37 UTC
I am not sure how it is exactly named in English.
But in the German version its is "Zukünftige Zahlungen" in the "Übersicht" (Overview) view.
And no, I really mean the 5th row.  Eg in the 4th row there is an expected credit entry ("Haben Buchung") which increases the total and this is correct. But the next day (row 5) there is an expected debit posting ("soll Buchung") which should decrease the total but it increases the total instead. The next day there is another credit entry (row 6)
I checked this again. And it now looks like KMoney adds  also the credit entry  in row 6 to row 5. So actual the posting of row 6 is added twice. 
The account type is "Girokonto" (checking account)
With "negative payment" I mean a "soll Buchung" (debit posting )
Comment 3 Thomas Baumgart 2021-12-16 07:19:23 UTC
Thanks for the explanation. The information on "row 5" only depends on your data, so it is a bit hard to figure out what's really going on. I have a few more questions but will contact you via PM since this involves private information. Once we figure out what is going on we report here.
Comment 4 Thomas Baumgart 2021-12-18 09:55:20 UTC
Git commit b247f26c33c94965e3ac836a8bcb797a35747122 by Thomas Baumgart.
Committed on 18/12/2021 at 08:45.
Pushed by tbaumgart into branch '5.1'.

Added additional testcases for scheduled transactions

M  +38   -0    kmymoney/mymoney/tests/mymoneyschedule-test.cpp
M  +3    -0    kmymoney/mymoney/tests/mymoneyschedule-test.h

https://invent.kde.org/office/kmymoney/commit/b247f26c33c94965e3ac836a8bcb797a35747122
Comment 5 Thomas Baumgart 2021-12-18 09:55:28 UTC
Git commit 2344c2ce4c69f835c5b8ef4ad270eaffd164f8ea by Thomas Baumgart.
Committed on 18/12/2021 at 09:34.
Pushed by tbaumgart into branch '5.1'.

Fix calculation of next due date

In case the option "Process this schedule always on the last day of a
month" is active, the next due date was not calculated correctly in all
cases.
FIXED-IN: 5.1.3

M  +11   -5    kmymoney/mymoney/mymoneyschedule.cpp

https://invent.kde.org/office/kmymoney/commit/2344c2ce4c69f835c5b8ef4ad270eaffd164f8ea
Comment 6 Thomas Baumgart 2021-12-18 09:55:41 UTC
Git commit 1f733662c2e46b1b909d79dd03a55bd3e0e5e5fa by Thomas Baumgart.
Committed on 18/12/2021 at 09:54.
Pushed by tbaumgart into branch 'master'.

Fix calculation of next due date

In case the option "Process this schedule always on the last day of a
month" is active, the next due date was not calculated correctly in all
cases.
FIXED-IN: 5.1.3
(cherry picked from commit 2344c2ce4c69f835c5b8ef4ad270eaffd164f8ea)

M  +11   -5    kmymoney/mymoney/mymoneyschedule.cpp

https://invent.kde.org/office/kmymoney/commit/1f733662c2e46b1b909d79dd03a55bd3e0e5e5fa