From 64077f45fc2842bc70b9d7f43b3a0f89bd3e5ad6 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Mon, 31 Jul 2023 09:48:18 +0000 Subject: [PATCH] Bug 34445: Set default budget in addorderiso2709.pl This patch allows the default budget to be used as a fallback if no budget is selected. Currently the default budget is set using lines 129-133 but then is never used. QA follow-up: - perl tidied - budget_codes changed to budget_ids for consistency Test plan: 1) Apply patch 2) restart_all 3) Follow the steps from the bug description 4) Order lines should be added properly Signed-off-by: Lucas Gass Signed-off-by: Marcel de Rooy [EDIT] Rearranged comments Signed-off-by: Tomas Cohen Arazi (cherry picked from commit b3427f71aede6cf0c8915c1b3e0ef970d2f188de) Signed-off-by: Fridolin Somers (cherry picked from commit 216542e4a6a499eb2a695a3647c4ce2f824af274) Signed-off-by: Matt Blenkinsop --- acqui/addorderiso2709.pl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl index fb31a8bcee..250d9c2bb3 100755 --- a/acqui/addorderiso2709.pl +++ b/acqui/addorderiso2709.pl @@ -224,7 +224,8 @@ if ($op eq ""){ my @notforloans = $input->multi_param('notforloan_' . $import_record->import_record_id); my @uris = $input->multi_param('uri_' . $import_record->import_record_id); my @copynos = $input->multi_param('copyno_' . $import_record->import_record_id); - my @budget_codes = $input->multi_param('budget_code_' . $import_record->import_record_id); + my @budget_ids = + $input->multi_param( 'budget_code_' . $import_record->import_record_id ); # bad field name used in template! my @itemprices = $input->multi_param('itemprice_' . $import_record->import_record_id); my @replacementprices = $input->multi_param('replacementprice_' . $import_record->import_record_id); my @itemcallnumbers = $input->multi_param('itemcallnumber_' . $import_record->import_record_id); @@ -257,11 +258,14 @@ if ($op eq ""){ # Group orderlines from MarcItemFieldsToOrder my $budget_hash; for (my $i = 0; $i < $count; $i++) { - $budget_hash->{$budget_codes[$i]}->{quantity} += 1; - $budget_hash->{$budget_codes[$i]}->{price} = $itemprices[$i]; - $budget_hash->{$budget_codes[$i]}->{replacementprice} = $replacementprices[$i]; - $budget_hash->{$budget_codes[$i]}->{itemnumbers} //= []; - push @{ $budget_hash->{$budget_codes[$i]}->{itemnumbers} }, $itemnumbers[$i]; + $budget_ids[$i] = $budget_id if !$budget_ids[$i]; # Use default budget if no budget selected in the UI + $budget_hash->{ $budget_ids[$i] }->{quantity} += 1; + $budget_hash->{ $budget_ids[$i] }->{price} = $itemprices[$i]; + $budget_hash->{ $budget_ids[$i] }->{replacementprice} = + $replacementprices[$i]; + $budget_hash->{ $budget_ids[$i] }->{itemnumbers} //= []; + push @{ $budget_hash->{ $budget_ids[$i] }->{itemnumbers} }, + $itemnumbers[$i]; } # Create orderlines from MarcItemFieldsToOrder -- 2.39.5