Bug 13321: use the populate_with_prices where needed
authorJonathan Druart <jonathan.druart@biblibre.com>
Fri, 14 Nov 2014 15:44:27 +0000 (16:44 +0100)
committerKyle M Hall <kyle@bywatersolutions.com>
Fri, 28 Oct 2016 13:46:06 +0000 (13:46 +0000)
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 <laurence.rault@biblibre.com>
Signed-off-by: Francois Charbonnier <francois.charbonnier@inlibro.com>
Signed-off-by: Sonia Bouis <sonia.bouis@univ-lyon3.fr>
Signed-off-by: Sonia Bouis <koha@univ-lyon3.fr>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
acqui/addorder.pl
acqui/addorderiso2709.pl
acqui/finishreceive.pl

index c35b851..81064ff 100755 (executable)
@@ -268,6 +268,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} ) {
index e425051..9a7739c 100755 (executable)
@@ -233,6 +233,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
index 0a62887..53a7412 100755 (executable)
@@ -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(