Bug 16474: Standardize spelling of EDIFACT
[koha-ffzg.git] / acqui / invoice.pl
index 59f2edc..08e3ee8 100755 (executable)
@@ -3,18 +3,18 @@
 # Copyright 2011 BibLibre SARL
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY 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.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 =head1 NAME
 
@@ -36,6 +36,8 @@ use C4::Acquisition;
 use C4::Budgets;
 
 use Koha::Acquisition::Bookseller;
+use Koha::Acquisition::Currencies;
+use Koha::DateUtils;
 use Koha::Misc::Files;
 
 my $input = new CGI;
@@ -76,14 +78,12 @@ elsif ( $op && $op eq 'reopen' ) {
     }
 }
 elsif ( $op && $op eq 'mod' ) {
-    my $shipmentdate       = $input->param('shipmentdate');
-    my $billingdate        = $input->param('billingdate');
     my $shipmentcost       = $input->param('shipmentcost');
     my $shipment_budget_id = $input->param('shipment_budget_id');
     ModInvoice(
         invoiceid             => $invoiceid,
-        shipmentdate          => C4::Dates->new($shipmentdate)->output("iso"),
-        billingdate           => C4::Dates->new($billingdate)->output("iso"),
+        shipmentdate          => output_pref( { str => scalar $input->param('shipmentdate'), dateformat => 'iso', dateonly => 1 } ),
+        billingdate           => output_pref( { str => scalar $input->param('billingdate'),  dateformat => 'iso', dateonly => 1 } ),
         shipmentcost          => $shipmentcost,
         shipmentcost_budgetid => $shipment_budget_id
     );
@@ -92,7 +92,7 @@ elsif ( $op && $op eq 'mod' ) {
     } elsif ($input->param('close')) {
         CloseInvoice($invoiceid);
     } elsif ($input->param('merge')) {
-        my @sources = $input->param('merge');
+        my @sources = $input->multi_param('merge');
         MergeInvoices($invoiceid, \@sources);
         defined($invoice_files) && $invoice_files->MergeFileRecIds(@sources);
     }
@@ -113,7 +113,6 @@ my $details = GetInvoiceDetails($invoiceid);
 my $bookseller = Koha::Acquisition::Bookseller->fetch({ id => $details->{booksellerid} });
 my @orders_loop = ();
 my $orders = $details->{'orders'};
-my $qty_total;
 my @foot_loop;
 my %foot;
 my $total_quantity = 0;
@@ -130,14 +129,14 @@ foreach my $order (@$orders) {
     );
     my $line = get_infos( $order, $bookseller);
 
-    $foot{$$line{gstgsti}}{gstrate} = $$line{gstrate};
-    $foot{$$line{gstgsti}}{gstvalue} += $$line{gstvalue};
+    $foot{$$line{gstrate}}{gstrate} = $$line{gstrate};
+    $foot{$$line{gstrate}}{gstvalue} += $$line{gstvalue};
     $total_gstvalue += $$line{gstvalue};
-    $foot{$$line{gstgsti}}{quantity}  += $$line{quantity};
+    $foot{$$line{gstrate}}{quantity}  += $$line{quantity};
     $total_quantity += $$line{quantity};
-    $foot{$$line{gstgsti}}{totalgste} += $$line{totalgste};
+    $foot{$$line{gstrate}}{totalgste} += $$line{totalgste};
     $total_gste += $$line{totalgste};
-    $foot{$$line{gstgsti}}{totalgsti} += $$line{totalgsti};
+    $foot{$$line{gstrate}}{totalgsti} += $$line{totalgsti};
     $total_gsti += $$line{totalgsti};
 
     $line->{orderline} = $line->{parent_ordernumber};
@@ -179,7 +178,7 @@ $template->param(
     total_gste_shipment => sprintf( $format, $total_gste + $details->{shipmentcost}),
     total_gsti_shipment => sprintf( $format, $total_gsti + $details->{shipmentcost}),
     invoiceincgst    => $bookseller->{invoiceincgst},
-    currency         => GetCurrency()->{currency},
+    currency         => Koha::Acquisition::Currencies->get_active,
     budgets_loop     => \@budgets_loop,
 );
 
@@ -210,8 +209,6 @@ sub get_infos {
         my $seriestitle = $order->{'seriestitle'};
         $line{'title'} .= " / $seriestitle" if $seriestitle;
         $line{'title'} .= " / $volume"      if $volume;
-    } else {
-        $line{'title'} = "Deleted bibliographic notice, can't find title.";
     }
 
     return \%line;