Bug 382162

Summary: Wrong budget in root categories if subcategories also include subcategories
Product: [Applications] skrooge Reporter: Bernhard Scheirle <bernhard+kde>
Component: generalAssignee: Stephane MANKOWSKI <stephane>
Status: RESOLVED FIXED    
Severity: normal CC: stephane
Priority: NOR    
Version: unspecified   
Target Milestone: 25.1.0   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Skrooge file that contains this bug.

Description Bernhard Scheirle 2017-07-09 15:46:26 UTC
Created attachment 106519 [details]
Skrooge file that contains this bug.

Skrooge Version: 2.8.1

Lets say we have following setup:
* 6 Categories:
  * Root
  * Root > Sub
  * Root > Sub > Sub
  * Root2
  * Root2 > Sub2
  * Root2 > Sub2 > Sub2
* 4 Operations:
  * 10€ in "Root > Sub"
  *  5€ in "Root > Sub > Sub"
  * 10€ in "Root2 > Sub2"
  *  5€ in "Root2 > Sub2 > Sub2"
* 4 Budget entries:
  * "Root"         [including subcategories]
  * "Root > Sub"   [including subcategories]
  * "Root2"        [including subcategories]
  * "Root2 > Sub2" [NOT including subcategories]

Skrooge now shows following values for these budgets:

Budget         | Skrooge Value | Expected Value
---------------|---------------|---------------
"Root"         |           5 € |     0 €
"Root > Sub"   |          15 € |    15 €
"Root2"        |           5 € |     5 €
"Root2 > Sub2" |          10 € |    10 €
---------------|---------------|---------------
Total:         |          35 € |    30 €


As you can see skooge counts the 5€ in "Root > Sub > Sub" twice,
once in "Root" and once in "Root > Sub".
This leads to wrong budget values.

If multiple budgets in the same hierarchy have the "include subcategories" flag set only the closest parent should include operation of its subcategories.
E.g. The 5€ in "Root > Sub > Sub" should only be included in "Root > Sub".

The attached skrooge file contains this scenario.
Comment 1 Stephane MANKOWSKI 2017-07-13 16:49:10 UTC
Git commit 92039757fc60c6719c69caa133fd69d82a2d90e5 by Stephane Mankowski.
Committed on 13/07/2017 at 16:47.
Pushed by smankowski into branch 'master'.

Wrong budget in root categories if subcategories also include subcategories

M  +1    -0    CHANGELOG
M  +9    -8    skgbankmodeler/skgdocumentbank.cpp

https://commits.kde.org/skrooge/92039757fc60c6719c69caa133fd69d82a2d90e5