From edc4dedddb674a13a745e83b2a66575d482710ed 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 --- acqui/addorderiso2709.pl | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl index fb31a8bcee..983cddf0c6 100755 --- a/acqui/addorderiso2709.pl +++ b/acqui/addorderiso2709.pl @@ -224,7 +224,7 @@ 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); 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 +257,15 @@ 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]; + # Use default budget if no budget selected in the UI + $budget_ids[$i] = $budget_id if !$budget_ids[$i]; + $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.37.1 (Apple Git-137.1)