Bug 12168

Summary: Spent and ordered budget values are wrong if deep > 2
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: AcquisitionsAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: major    
Priority: P5 - low CC: fridolin.somers, gmcharlt, nengard, paola.rossi
Version: Main   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11714
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on:    
Bug Blocks: 12164    
Attachments: Bug 12168: Spent and ordered budget values are wrong if deep > 2
Bug 12168: Add unit tests for GetBudgetHierarchySpent GetBudgetHierarchyOrdered
Bug 12168: Add unit tests for GetBudgetHierarchySpent GetBudgetHierarchyOrdered
Bug 12168: Spent and ordered budget values are wrong if deep > 2
Bug 12168: Add unit tests for GetBudgetHierarchySpent GetBudgetHierarchyOrdered
[PASSED QA] Bug 12168: Spent and ordered budget values are wrong if deep > 2
[PASSED QA] Bug 12168: Add unit tests for GetBudgetHierarchySpent GetBudgetHierarchyOrdered

Description Jonathan Druart 2014-05-01 12:07:38 UTC
A really weird (and old) code process the calculation for the spent and ordered sublevel funds.
It only takes into account the direct children.

So if you have:
fund1 (spent=100) parent of fund11 (spent=10) parent of fund111 (spent=1), you get:
fund     | base-level | total spent
fund1    | 100        | 110
fund11   | 10         | 11
fund111  | 1          | 1

which is wrong, it should be
fund     | base-level | total spent
fund1    | 100        | 111
fund11   | 10         | 11
fund111  | 1          | 1
Comment 1 Jonathan Druart 2014-05-01 12:31:00 UTC Comment hidden (obsolete)
Comment 2 Jonathan Druart 2014-05-01 12:31:06 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2014-05-01 14:12:09 UTC Comment hidden (obsolete)
Comment 4 Paola Rossi 2014-05-08 14:27:23 UTC
I test against master 3.15.00.051.

Applying: Bug 12168: Spent and ordered budget values are wrong if deep > 2
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging C4/Budgets.pm
CONFLICT (content): Merge conflict in C4/Budgets.pm
Failed to merge in the changes.
Patch failed at 0001 Bug 12168: Spent and ordered budget values are wrong if deep > 2

So I pass the patch to "Patch doesn't apply" status.
Comment 5 Jonathan Druart 2014-05-08 15:10:18 UTC Comment hidden (obsolete)
Comment 6 Jonathan Druart 2014-05-08 15:10:32 UTC Comment hidden (obsolete)
Comment 7 Paola Rossi 2014-05-09 10:30:18 UTC
I test the patch against master 3.15.00.051.

The values are correct as required.

So I pass the patch to "Signed Off" status.
Comment 8 Kyle M Hall 2014-05-16 10:52:58 UTC
Created attachment 28289 [details] [review]
[PASSED QA] Bug 12168: Spent and ordered budget values are wrong if deep > 2

A really weird (and old) code process the calculation for the spent and
ordered sublevel funds.
It only takes into account the direct children.

So if you have:
fund1 (spent=100) parent of fund11 (spent=10) parent of fund111 (spent=1), you get:
fund     | base-level | total spent
fund1    | 100        | 110
fund11   | 10         | 11
fund111  | 1          | 1

which is wrong, it should be
fund     | base-level | total spent
fund1    | 100        | 111
fund11   | 10         | 11
fund111  | 1          | 1

Test plan:
- Create 1 budget and 3 funds with the same structure as above.
- Create some orders and receive them (not all).
- Go on the fund list view and verify the values are correct.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 9 Kyle M Hall 2014-05-16 10:53:36 UTC
Created attachment 28290 [details] [review]
[PASSED QA] Bug 12168: Add unit tests for GetBudgetHierarchySpent GetBudgetHierarchyOrdered

Test plan:
prove t/db_dependent/Budgets.t

Note: This addition may sound overkill but I found this bug developping
bug 12164 and I will reuse all of that.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 10 Galen Charlton 2014-05-19 22:05:50 UTC
Pushed to master.  Thanks, Jonathan!
Comment 11 Jonathan Druart 2014-07-11 11:00:07 UTC
*** Bug 11714 has been marked as a duplicate of this bug. ***