When closing a budget/creating new budgets at the end of the year fund codes are duplicated. When importing orders from a staged file we retrieve the budget using only the fund code, this is problematic if we have multiple budgets. When we really see the effect is a library that creates a new inactive budget for upcoming year, this budget's fund end up being implicitly selected by DB order. We instead need to explicitly select active funds.
Created attachment 65049 [details] [review] Bug 18941 - C4::Budgets GetBudgetByCode should return active budgets over inactive budgets To test: 1 - Create an active budget 2 - Create an inactive budget 3 - Ensure they each have a fund with the same code 4 - Set MarcFieldsToOrder to get the budget_code from a marc field 5 - Stage a file using the duplicated code 6 - Add to a basket from the staged file 7 - Add the items 8 - Note funds are encumbered from the inactive budget 9 - Apply patch 10 - Repeat 5-8 with a new basket 11 - Note the active budget is now used
Created attachment 65050 [details] [review] Bug 18941 - Unit tests
I have two problems. 1) this adds a lot of fields because of the JOIN. -- should change the * to aqbudget.* at least 2) if I apply the unit tests but not the fix, I expected a failure. They still passed. How do I know the condition is fixed? Marking Failed QA.
Created attachment 65125 [details] [review] Bug 18941 - Unit tests
Created attachment 65126 [details] [review] Bug 18941 - C4::Budgets GetBudgetByCode should return active budgets over inactive budgets To test: 1 - Create an active budget 2 - Create an inactive budget 3 - Ensure they each have a fund with the same code 4 - Set MarcFieldsToOrder to get the budget_code from a marc field 5 - Stage a file using the duplicated code 6 - Add to a basket from the staged file 7 - Add the items 8 - Note funds are encumbered from the inactive budget 9 - Apply patch 10 - Repeat 5-8 with a new basket 11 - Note the active budget is now used
Created attachment 65441 [details] [review] [SIGNED-OFF] Bug 18941 - Unit tests Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Created attachment 65442 [details] [review] [SIGNED-OFF] Bug 18941 - C4::Budgets GetBudgetByCode should return active budgets over inactive budgets To test: 1 - Create an active budget 2 - Create an inactive budget 3 - Ensure they each have a fund with the same code 4 - Set MarcFieldsToOrder to get the budget_code from a marc field 5 - Stage a file using the duplicated code 6 - Add to a basket from the staged file 7 - Add the items 8 - Note funds are encumbered from the inactive budget 9 - Apply patch 10 - Repeat 5-8 with a new basket 11 - Note the active budget is now used Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Created attachment 65847 [details] [review] Bug 18941 - Unit tests Signed-off-by: Mark Tompsett <mtompset@hotmail.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Created attachment 65848 [details] [review] Bug 18941 - C4::Budgets GetBudgetByCode should return active budgets over inactive budgets To test: 1 - Create an active budget 2 - Create an inactive budget 3 - Ensure they each have a fund with the same code 4 - Set MarcFieldsToOrder to get the budget_code from a marc field 5 - Stage a file using the duplicated code 6 - Add to a basket from the staged file 7 - Add the items 8 - Note funds are encumbered from the inactive budget 9 - Apply patch 10 - Repeat 5-8 with a new basket 11 - Note the active budget is now used Signed-off-by: Mark Tompsett <mtompset@hotmail.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Pushed to master for 17.11, thanks to everybody involved!
Pushed to 17.05.x, will be in 17.05.05.
These patches have been pushed to 16.11.x and will be in 16.11.13.
Pushed to 16.05.x, for 16.05.18 release