From e613d9417ed819d4f25430f78df7e2ec05e9667c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Sat, 2 Oct 2021 12:28:52 +0000 Subject: [PATCH] Bug 14999: Make sure order prices are not mixed-up We were shifting the price and replacement price for imported orders only after the line: > $duplinbatch = $import_batch_id and next if $duplifound; This lead to the "replacementprice" and "price" query parameters not being shifted/removed from the list if a duplicate record came across and caused the prices be applied to the next record being imported. To reproduce: 1) Download two records from koha to marcxml file, then cat those: cat bib1.marcxml bib2.marcxml > bibs.marcxml 2) Delete bib2 from koha 3) Stage bibs.marcxml for import 4) Create a new order basket, then "Add to basket" using "From a staged file" option 5) Select both bib1 and bib2 and set price & replacement price for bib1 to be 99.00 and for bib2 to be 88.00 6) Click save and notice bib2 was imported with the wrong prices, 99.00! 7) Apply patch and notice the prices are now correctly set to 88.00. Signed-off-by: Emmi Takkinen Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart Signed-off-by: Kyle M Hall (cherry picked from commit 58a69fb12944523391e5113ae6e326fd2d0887d9) Signed-off-by: Fridolin Somers (cherry picked from commit eb997ae320fba8c16902c8867f4588e4f3193a07) Signed-off-by: Victor Grousset/tuxayo --- acqui/addorderiso2709.pl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl index 4995b5a370..2809101ed0 100755 --- a/acqui/addorderiso2709.pl +++ b/acqui/addorderiso2709.pl @@ -162,6 +162,8 @@ if ($op eq ""){ $c_discount = $c_discount / 100 if $c_discount > 1; my $c_sort1 = shift( @sort1 ) || $input->param('all_sort1') || ''; my $c_sort2 = shift( @sort2 ) || $input->param('all_sort2') || ''; + my $c_replacement_price = shift( @orderreplacementprices ); + my $c_price = shift( @prices ) || GetMarcPrice($marcrecord, C4::Context->preference('marcflavour')); # Insert the biblio, or find it through matcher unless ( $biblionumber ) { @@ -322,24 +324,23 @@ if ($op eq ""){ order_internalnote => $cgiparams->{'all_order_internalnote'}, order_vendornote => $cgiparams->{'all_order_vendornote'}, currency => $cgiparams->{'all_currency'}, - replacementprice => shift( @orderreplacementprices ), + replacementprice => $c_replacement_price, ); # get the price if there is one. - my $price= shift( @prices ) || GetMarcPrice($marcrecord, C4::Context->preference('marcflavour')); - if ($price){ + if ($c_price){ # in France, the cents separator is the , but sometimes, ppl use a . # in this case, the price will be x100 when unformatted ! Replace the . by a , to get a proper price calculation - $price =~ s/\./,/ if C4::Context->preference("CurrencyFormat") eq "FR"; - $price = Koha::Number::Price->new($price)->unformat; + $c_price =~ s/\./,/ if C4::Context->preference("CurrencyFormat") eq "FR"; + $c_price = Koha::Number::Price->new($c_price)->unformat; $orderinfo{tax_rate} = $bookseller->tax_rate; my $c = $c_discount ? $c_discount : $bookseller->discount / 100; $orderinfo{discount} = $c; if ( $c_discount ) { - $orderinfo{ecost} = $price; + $orderinfo{ecost} = $c_price; $orderinfo{rrp} = $orderinfo{ecost} / ( 1 - $c ); } else { - $orderinfo{ecost} = $price * ( 1 - $c ); - $orderinfo{rrp} = $price; + $orderinfo{ecost} = $c_price * ( 1 - $c ); + $orderinfo{rrp} = $c_price; } $orderinfo{listprice} = $orderinfo{rrp} / $active_currency->rate; $orderinfo{unitprice} = $orderinfo{ecost}; -- 2.39.5