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>
Signed-off-by: Mason James <mtj@kohaaloha.com>
This commit is contained in:
Nick Clemens 2017-07-14 11:25:42 +00:00 committed by Mason James
parent cb555851c6
commit b2b1ee07cf
1 changed files with 3 additions and 2 deletions

View File

@ -773,10 +773,11 @@ sub GetBudgetByCode {
my $dbh = C4::Context->dbh;
my $query = qq{
SELECT *
SELECT aqbudgets.*
FROM aqbudgets
JOIN aqbudgetperiods USING (budget_period_id)
WHERE budget_code = ?
ORDER BY budget_id DESC
ORDER BY budget_period_active DESC, budget_id DESC
LIMIT 1
};
my $sth = $dbh->prepare( $query );