Bug 5864: link biblio => serials subscription is wrong
[koha_gimpoz] / acqui / parcel.pl
index 7b93a15..ad95944 100755 (executable)
 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA  02111-1307 USA
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 =head1 NAME
 
 parcel.pl
 
 =head1 DESCRIPTION
+
 This script shows all orders receipt or pending for a given supplier.
 It allows to write an order as 'received' when he arrives.
 
@@ -34,9 +35,11 @@ It allows to write an order as 'received' when he arrives.
 =over 4
 
 =item supplierid
+
 To know the supplier this script has to show orders.
 
 =item code
+
 is the bookseller invoice number.
 
 =item freight
@@ -46,16 +49,19 @@ is the bookseller invoice number.
 
 
 =item datereceived
+
 To filter the results list on this given date.
 
 =back
 
 =cut
 
+use strict;
+#use warnings; FIXME - Bug 2505
 use C4::Auth;
 use C4::Acquisition;
 use C4::Budgets;
-use C4::Bookseller;
+use C4::Bookseller qw/ GetBookSellerFromId /;
 use C4::Biblio;
 use C4::Items;
 use CGI;
@@ -63,15 +69,14 @@ use C4::Output;
 use C4::Dates qw/format_date format_date_in_iso/;
 use JSON;
 
-use strict;
-
 my $input=new CGI;
 my $supplierid=$input->param('supplierid');
 my $bookseller=GetBookSellerFromId($supplierid);
 
 my $invoice=$input->param('invoice') || '';
 my $freight=$input->param('freight');
-my $gst= $input->param('gst') || $bookseller->{gstrate} || C4::Context->preference("gist") || 0;
+my $input_gst = ($input->param('gst') eq '' ? undef : $input->param('gst'));
+my $gst= $input_gst // $bookseller->{gstrate} // C4::Context->preference("gist") // 0;
 my $datereceived =  ($input->param('op') eq 'new') ? C4::Dates->new($input->param('datereceived')) 
                                        :  C4::Dates->new($input->param('datereceived'), 'iso')   ;
 $datereceived = C4::Dates->new() unless $datereceived;
@@ -109,9 +114,10 @@ if($input->param('format') eq "json"){
             $data->{ordernumber} = $order->{ordernumber};
             $data->{title} = $order->{title};
             $data->{author} = $order->{author};
+            $data->{isbn} = $order->{isbn};
+            $data->{booksellerid} = $order->{booksellerid};
             $data->{biblionumber} = $order->{biblionumber};
             $data->{freight} = $order->{freight};
-            $data->{quantrem} = $order->{quantity} - $order->{quantityreceived};
             $data->{quantity} = $order->{quantity};
             $data->{ecost} = $order->{ecost};
             $data->{ordertotal} = sprintf("%.2f",$order->{ecost}*$order->{quantity});
@@ -165,8 +171,6 @@ if ($action eq "cancelorder") {
     }
 
     if ($error_delitem || $error_delbiblio) {
-       warn $error_delitem;
-       warn $error_delbiblio;
        if ($error_delitem)   { $template->param(error_delitem => 1); }
        if ($error_delbiblio) { $template->param(error_delbiblio => 1); }
     } else {
@@ -234,7 +238,6 @@ for (my $i = 0 ; $i < $countpendings ; $i++) {
     my %line;
     %line = %{$pendingorders->[$i]};
     $line{quantity}+=0;
-    $line{quantrem} = $line{quantity} - $line{quantityreceived};
     $line{quantityreceived}+=0;
     $line{unitprice}+=0;
     $totalPunitprice += $line{unitprice};