5 #script to recieve orders
6 #written by chris@katipo.co.nz 24/2/2000
9 # Copyright 2000-2002 Katipo Communications
11 # This file is part of Koha.
13 # Koha is free software; you can redistribute it and/or modify it under the
14 # terms of the GNU General Public License as published by the Free Software
15 # Foundation; either version 2 of the License, or (at your option) any later
18 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
20 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License along with
23 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
24 # Suite 330, Boston, MA 02111-1307 USA
32 This script shows all orders receipt or pending for a given supplier.
33 It allows to write an order as 'received' when he arrives.
40 To know the supplier this script has to show orders.
43 is the bookseller invoice number.
52 To filter the results list on this given date.
64 use C4::Interface::CGI::Output;
70 my $supplierid=$input->param('supplierid');
71 my $basketno=$input->param('basketno');
72 my @booksellers=GetBookSeller($supplierid);
73 my $count = scalar @booksellers;
75 my @datetoday = localtime();
76 my $date = (1900+$datetoday[5])."-".($datetoday[4]+1)."-". $datetoday[3];
77 my ($template, $loggedinuser, $cookie)
78 = get_template_and_user({template_name => "acqui/parcel.tmpl",
82 flagsrequired => {acquisition => 1},
86 my @booksellers=GetBookSeller($supplierid);
88 my $gstreg=$booksellers[0]->{gstreg};
89 my $incgst=$booksellers[0]->{'invoiceincgst'};
90 my $invcurrency=$booksellers[0]->{'invoiceprice'};
91 my $discount=$booksellers[0]->{'discount'};
93 # get currencies (for exchange rates calcs if needed)
94 my @rates = GetCurrencies();
95 my $count = scalar @rates;
97 for ( my $i = 0 ; $i < $count ; $i++ ) {
98 if ($rates[$i]->{'currency'} eq $invcurrency){
99 $currencyrate = $rates[$i]->{'rate'};
102 my $me=C4::Context->userenv;
103 my $user=$me->{'cardnumber'};
119 ##Receiving a single basket or all baskets of a supplier
121 my $pendingorders = GetPendingOrders($supplierid);
122 $countpendings = scalar @$pendingorders;
123 foreach my $pendingorder (@$pendingorders){
124 my @orders=GetOrders($pendingorder->{basketno});
125 foreach my $order(@orders){
126 $order->{toreceive}=$order->{quantity} - $order->{quantityreceived};
127 $totalquantity+=$order->{quantity};
128 $totaltoreceive+=$order->{toreceive};
129 $totalprice+=$order->{rrp}*$order->{quantity};
130 $totaltoprice+=$order->{rrp}*$order->{toreceive};
131 $totalgst+=(($order->{rrp}*$order->{quantity}) -($order->{rrp}*$order->{quantity}*$order->{discount}/100))* $order->{gst}/100;
132 $totaltogst+=(($order->{rrp}*$order->{toreceive}) -($order->{rrp}*$order->{toreceive}*$order->{discount}/100))* $order->{gst}/100;
133 $totaldiscount +=$order->{rrp}*$order->{quantity}*$order->{discount}/100;
134 $totaltodiscount +=$order->{rrp}*$order->{toreceive}*$order->{discount}/100;
135 $order->{actualrrp}=sprintf( "%.2f",$order->{rrp}/$currencyrate);
136 push @loop_orders, $order;
144 my @orders=GetOrders($basketno);
145 foreach my $order(@orders){
146 $invoice=$order->{booksellerinvoicenumber} unless $invoice;
147 $order->{toreceive}=$order->{quantity} - $order->{quantityreceived};
148 $totalquantity+=$order->{quantity};
149 $totaltoreceive+=$order->{toreceive};
150 $totalprice+=$order->{rrp}*$order->{quantity};
151 $totaltoprice+=$order->{rrp}*$order->{toreceive};
152 $totalgst+=(($order->{rrp}*$order->{quantity}) -($order->{rrp}*$order->{quantity}*$order->{discount}/100))* $order->{gst}/100;
153 $totaltogst+=(($order->{rrp}*$order->{toreceive}) -($order->{rrp}*$order->{toreceive}*$order->{discount}/100))* $order->{gst}/100;
154 $totaldiscount +=$order->{rrp}*$order->{quantity}*$order->{discount}/100;
155 $totaltodiscount +=$order->{rrp}*$order->{toreceive}*$order->{discount}/100;
156 $order->{actualrrp}=sprintf( "%.2f",$order->{rrp}/$currencyrate);
157 push @loop_orders, $order;
160 undef $invcurrency if ($currencyrate ==1);
162 $template->param( invoice=>$invoice,
163 date => format_date($date),
164 name => $booksellers[0]->{'name'},
165 supplierid => $supplierid,
166 countpending => $countpendings,
167 loop_orders => \@loop_orders,
169 totalquantity=>$totalquantity,
170 totaltoreceive=>$totaltoreceive,
171 totalprice=>sprintf( "%.2f",$totalprice),
172 totalactual =>sprintf( "%.2f",$totaltoprice/$currencyrate),
173 totalgst=>sprintf( "%.2f",$totalgst),
174 actualgst=>sprintf( "%.2f",$totaltogst/$currencyrate),
175 totaldiscount=>sprintf( "%.2f",$totaldiscount),
176 actualdiscount=>sprintf( "%.2f",$totaltodiscount/$currencyrate),
177 total=>sprintf( "%.2f",$totalprice+$totalgst-$totaldiscount),
179 gstrate=>C4::Context->preference('gist')*100,
180 currencyrate=>$currencyrate,
182 invcurrency=>$invcurrency ,
183 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
184 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
185 IntranetNav => C4::Context->preference("IntranetNav"),
187 output_html_with_http_headers $input, $cookie, $template->output;