From 8556621a3e5bdbe1fb49a4fc7e30ca184cc5703a Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 25 Jan 2024 19:03:00 +0000 Subject: [PATCH] Bug 35892: Populate order price using GetMarcPrice if no price specified Previously this happened after the fact, automagically, if no price was included in the order record. We should rather load the Marc price into the order form if we don't have a price form the '...ToOrder' system preferences To test: Setup -- Set systempreferences below MarcFieldsToOrder: price: 949$g quantity: 949$k budget_code: 949$l discount: 949$m sort1: 949$n sort2: 949$q MarcItemFieldsToOrder: homebranch: 949$a holdingbranch: 949$b itype: 949$y nonpublic_note: 949$x public_note: 949$z loc: 949$c ccode: 949$8 notforloan: 949$7 uri: 949$u copyno: 949$t replacementprice: 949$v itemcallnumber: 949$o quantity: 949$k budget_code: 949$l Stage the attached bib-303.marcxml file Add to basket from the staged file Note that item prices are populated as '6.50' from 949$g Cancel Update MarcFieldsToOrder and map price to "020$c" Add to basket from the staged file Note the price is not populated, because 020$c contains a dollar sign Cancel Apply patch, restart all Add to basket from the staged file Note the price is now correctly populated from fallback to GetMarcPrice Note: GetMarcPrice does some automatic munging, that's why 020$c on it's own doesn't work - this could be done to fields in MarcFieldsToOrder/MarcItemFieldsToOrder but this would be an enhancement. This bug simply restores the previous behavious, but does it on the front end and is more obvious to the user Signed-off-by: Andrew Fuerste-Henry Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer (cherry picked from commit c3035f7e1b469acaebfc6e388d60a9684f744ba5) Signed-off-by: Fridolin Somers (cherry picked from commit 781f34e504eb5d5cd84e7e9840e06006fd703977) Signed-off-by: Lucas Gass --- acqui/addorderiso2709.pl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl index 365e0621de..ceede5de7f 100755 --- a/acqui/addorderiso2709.pl +++ b/acqui/addorderiso2709.pl @@ -26,6 +26,7 @@ use CGI qw ( -utf8 ); use YAML::XS; use List::MoreUtils; use Encode; +use Scalar::Util qw( looks_like_number ); use C4::Context; use C4::Auth qw( get_template_and_user ); @@ -168,9 +169,7 @@ if ($op eq ""){ my $c_sort1 = $input->param( 'sort1_' . $import_record->import_record_id ) || $input->param('all_sort1') || ''; my $c_sort2 = $input->param( 'sort2_' . $import_record->import_record_id ) || $input->param('all_sort2') || ''; my $c_replacement_price = $input->param( 'replacementprice_' . $import_record->import_record_id ); - my $c_price = $input->param( 'price_' . $import_record->import_record_id ) - || GetMarcPrice( $marcrecord, C4::Context->preference('marcflavour') ); - + my $c_price = $input->param( 'price_' . $import_record->import_record_id ); # Insert the biblio, or find it through matcher if ( $biblionumber ) { # If matched during staging we can continue $import_record->status('imported')->store; @@ -501,7 +500,7 @@ sub import_biblios_list { my $marcrecord = $import_record->get_marc_record || die "couldn't translate marc information"; my $infos = get_infos_syspref('MarcFieldsToOrder', $marcrecord, ['price', 'quantity', 'budget_code', 'discount', 'sort1', 'sort2','replacementprice']); - my $price = $infos->{price}; + my $price = looks_like_number($infos->{price}) ? $infos->{price} : GetMarcPrice( $marcrecord, C4::Context->preference('marcflavour') ); my $replacementprice = $infos->{replacementprice}; my $quantity = $infos->{quantity}; my $budget_code = $infos->{budget_code}; -- 2.39.5