From 0f0d136ec2d16ac7ebb43959efdedcb5f29e0be5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 14 Nov 2014 16:44:27 +0100 Subject: [PATCH] Bug 13321: use the populate_with_prices where needed Now we need to calculate the prices (ecost, rrp, unitprice) and tax (tax_rate, tax_value) when the price is set for an order. This only appends in the 3 files impacted by this patch. addorder*.pl on ordering finishreceive.pl on receiving Signed-off-by: Laurence Rault Signed-off-by: Francois Charbonnier Signed-off-by: Sonia Bouis --- acqui/addorder.pl | 8 ++++++++ acqui/addorderiso2709.pl | 12 ++++++++++++ acqui/finishreceive.pl | 8 ++++++++ 3 files changed, 28 insertions(+) diff --git a/acqui/addorder.pl b/acqui/addorder.pl index 70cb36c..4cc97fd 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -267,6 +267,14 @@ if ( $basket->{is_standing} || $orderinfo->{quantity} ne '0' ) { $orderinfo->{unitprice} = $orderinfo->{ecost} if not defined $orderinfo->{unitprice} or $orderinfo->{unitprice} eq ''; + $orderinfo = C4::Acquisition::populate_order_with_prices( + { + order => $orderinfo, + booksellerid => $orderinfo->{booksellerid}, + ordering => 1, + } + ); + # if we already have $ordernumber, then it's an ordermodif my $order = Koha::Acquisition::Order->new($orderinfo); if ( $orderinfo->{ordernumber} ) { diff --git a/acqui/addorderiso2709.pl b/acqui/addorderiso2709.pl index 9a97758..19c4d19 100755 --- a/acqui/addorderiso2709.pl +++ b/acqui/addorderiso2709.pl @@ -234,6 +234,18 @@ if ($op eq ""){ # remove uncertainprice flag if we have found a price in the MARC record $orderinfo{uncertainprice} = 0 if $orderinfo{listprice}; + + %orderinfo = %{ + C4::Acquisition::populate_order_with_prices( + { + order => \%orderinfo, + booksellerid => $booksellerid, + ordering => 1, + receiving => 1, + } + ) + }; + my $order = Koha::Acquisition::Order->new( \%orderinfo )->insert; # 4th, add items if applicable diff --git a/acqui/finishreceive.pl b/acqui/finishreceive.pl index 0a62887..53a7412 100755 --- a/acqui/finishreceive.pl +++ b/acqui/finishreceive.pl @@ -103,6 +103,14 @@ if ($quantityrec > $origquantityrec ) { } } + $order = C4::Acquisition::populate_order_with_prices( + { + order => $order, + booksellerid => $booksellerid, + receiving => 1 + } + ); + # save the quantity received. if ( $quantityrec > 0 ) { ( $datereceived, $new_ordernumber ) = ModReceiveOrder( -- 2.7.0