Bug 10723: Merge GetPendingOrders and SearchOrders routines
[koha.git] / acqui / orderreceive.pl
index f25b5a9..ab7b341 100755 (executable)
@@ -91,7 +91,9 @@ $datereceived = $datereceived ? C4::Dates->new($datereceived, 'iso') : C4::Dates
 
 my $bookseller = GetBookSellerFromId($booksellerid);
 my $results;
-$results = SearchOrder($ordernumber) if $ordernumber;
+$results = SearchOrders({
+    ordernumber => $ordernumber
+}) if $ordernumber;
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
@@ -198,7 +200,7 @@ $template->param(
     count                 => 1,
     biblionumber          => $order->{'biblionumber'},
     ordernumber           => $order->{'ordernumber'},
-    biblioitemnumber      => $order->{'biblioitemnumber'},
+    subscriptionid        => $order->{subscriptionid},
     booksellerid          => $order->{'booksellerid'},
     freight               => $freight,
     name                  => $bookseller->{'name'},
@@ -214,7 +216,6 @@ $template->param(
     quantityreceived      => $order->{'quantityreceived'},
     rrp                   => sprintf( "%.2f", $rrp ),
     ecost                 => sprintf( "%.2f", $ecost ),
-    unitprice             => sprintf( "%.2f", $unitprice),
     memberfirstname       => $member->{firstname} || "",
     membersurname         => $member->{surname} || "",
     invoiceid             => $invoice->{invoiceid},
@@ -227,6 +228,15 @@ $template->param(
     firstnamesuggestedby  => $suggestion->{firstnamesuggestedby},
 );
 
+# regardless of the content of $unitprice e.g 0 or '' or any string will return in these cases 0.00
+# and the 'IF' in the .tt will show 0.00 and not 'ecost' (see BZ 7129)
+# So if $unitprice == 0 we don't create unitprice
+if ( $unitprice != 0) {
+    $template->param(
+        unitprice             => sprintf( "%.2f", $unitprice),
+    );
+}
+
 my $op = $input->param('op');
 if ($op and $op eq 'edit'){
     $template->param(edit   =>   1);