Bug 12168 - Spent and ordered budget values are wrong if deep > 2
Summary: Spent and ordered budget values are wrong if deep > 2
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Acquisitions (show other bugs)
Version: Main
Hardware: All All
: P5 - low major (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 12164
  Show dependency treegraph
 
Reported: 2014-05-01 12:07 UTC by Jonathan Druart
Modified: 2015-06-04 23:33 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 12168: Spent and ordered budget values are wrong if deep > 2 (5.66 KB, patch)
2014-05-01 12:31 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12168: Add unit tests for GetBudgetHierarchySpent GetBudgetHierarchyOrdered (7.18 KB, patch)
2014-05-01 12:31 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12168: Add unit tests for GetBudgetHierarchySpent GetBudgetHierarchyOrdered (7.11 KB, patch)
2014-05-01 14:12 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12168: Spent and ordered budget values are wrong if deep > 2 (5.66 KB, patch)
2014-05-08 15:10 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 12168: Add unit tests for GetBudgetHierarchySpent GetBudgetHierarchyOrdered (7.18 KB, patch)
2014-05-08 15:10 UTC, Jonathan Druart
Details | Diff | Splinter Review
[PASSED QA] Bug 12168: Spent and ordered budget values are wrong if deep > 2 (5.73 KB, patch)
2014-05-16 10:52 UTC, Kyle M Hall
Details | Diff | Splinter Review
[PASSED QA] Bug 12168: Add unit tests for GetBudgetHierarchySpent GetBudgetHierarchyOrdered (7.25 KB, patch)
2014-05-16 10:53 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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. ***