From cfe5a1b29d24e050357ccb8998d5dd16fd5c4568 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 10 Jan 2017 10:03:36 +0100 Subject: [PATCH] Bug 17872: Fix small error in GetBudgetHierarchy and one of its calls MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit In aqbudgetperiods.pl a commented line is removed that contains a wrong userenv hash key. Should be branch instead of branchcode. In aqbudgets GetBudgetHierarchy is called with the same wrong userenv hash key. Should be userenv->{branch}. This made another bug visible: if you call GetBudgetHierarchy with a branch and without owner, the where clause should take into account that the branchcode can be empty (not null). Test plan: [1] Run Budgets.t [2] Run aqbudgets.pl from Administration [3] Add the show_mine=1 parameter in the URL [4] Change owner of one of the funds and repeat step 2 and 3. t/Budgets.t returns green. Followed test plan, works as expected. Signed-off-by: Marc Véron Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit 476179a12311b32643087cc8ec10c31409bb1b99) Signed-off-by: Katrin Fischer (cherry picked from commit 3079f7a72515a22062bd9a65ec546cfcd6d9bb66) Signed-off-by: Julian Maurice --- C4/Budgets.pm | 2 +- admin/aqbudgetperiods.pl | 2 -- admin/aqbudgets.pl | 3 +-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/C4/Budgets.pm b/C4/Budgets.pm index cd7198a8c5..6a10ad0443 100644 --- a/C4/Budgets.pm +++ b/C4/Budgets.pm @@ -514,7 +514,7 @@ sub GetBudgetHierarchy { } } else { if ($branchcode) { - push @where_strings," (budget_branchcode =? or budget_branchcode is NULL)"; + push @where_strings," (budget_branchcode =? or budget_branchcode is NULL OR budget_branchcode='')"; push @bind_params, $branchcode; } } diff --git a/admin/aqbudgetperiods.pl b/admin/aqbudgetperiods.pl index 405c8862e9..d7fb0898e8 100755 --- a/admin/aqbudgetperiods.pl +++ b/admin/aqbudgetperiods.pl @@ -195,8 +195,6 @@ elsif ( $op eq 'close_form' ) { my $budgets_to_move = GetBudgetHierarchy($budget_period_id); - # C4::Context->userenv->{branchcode}, $show_mine ? $borrower_id : '') - my $number_of_unreceived_orders = 0; for my $budget (@$budgets_to_move) { diff --git a/admin/aqbudgets.pl b/admin/aqbudgets.pl index 5cc0ea16b4..1efdf673e3 100755 --- a/admin/aqbudgets.pl +++ b/admin/aqbudgets.pl @@ -265,8 +265,7 @@ if ( $op eq 'list' ) { ); my @budgets = @{ - GetBudgetHierarchy($$period{budget_period_id}, - C4::Context->userenv->{branchcode}, $show_mine ? $borrower_id : '') + GetBudgetHierarchy( $$period{budget_period_id}, C4::Context->userenv->{branch}, ( $show_mine ? $borrower_id : 0 )) }; my $period_total = 0; -- 2.39.5