From 9fc8fbd1d1507937c71ea37eedfbedb32698309f 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 --- 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 f58e58d..a1ff9b5 100755 --- a/acqui/addorder.pl +++ b/acqui/addorder.pl @@ -263,6 +263,14 @@ if ( $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 187c771..3c1e97c 100755 --- a/acqui/addorderiso2709.pl +++ b/acqui/addorderiso2709.pl @@ -261,6 +261,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 b35212c..5baf7db 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( -- 1.9.1