|
Lines 166-204
my @loop_received = ();
Link Here
|
| 166 |
for (my $i = 0 ; $i < $countlines ; $i++) { |
166 |
for (my $i = 0 ; $i < $countlines ; $i++) { |
| 167 |
|
167 |
|
| 168 |
#$total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'}; #weird, are the freight fees counted by book? (pierre) |
168 |
#$total=($parcelitems[$i]->{'unitprice'} + $parcelitems[$i]->{'freight'}) * $parcelitems[$i]->{'quantityreceived'}; #weird, are the freight fees counted by book? (pierre) |
| 169 |
$total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'}; #weird, are the freight fees counted by book? (pierre) |
169 |
$total = ($parcelitems[$i]->{'unitprice'}) * $parcelitems[$i]->{'quantityreceived'} + $parcelitems[$i]->{'freight'}; |
| 170 |
$parcelitems[$i]->{'unitprice'} += 0; |
170 |
$parcelitems[$i]->{'unitprice'} += 0; |
| 171 |
my %line; |
171 |
my %line; |
| 172 |
%line = %{ $parcelitems[$i] }; |
172 |
%line = %{ $parcelitems[$i] }; |
| 173 |
$line{invoice} = $invoice; |
173 |
$line{invoice} = $invoice; |
| 174 |
$line{gst} = $gst; |
174 |
$line{gst} = $gst; |
|
|
175 |
$line{freight} = sprintf($cfstr, $line{freight}); |
| 175 |
$line{total} = sprintf($cfstr, $total); |
176 |
$line{total} = sprintf($cfstr, $total); |
| 176 |
$line{supplierid} = $supplierid; |
177 |
$line{supplierid} = $supplierid; |
| 177 |
push @loop_received, \%line; |
178 |
push @loop_received, \%line; |
| 178 |
$totalprice += $parcelitems[$i]->{'unitprice'}; |
179 |
$totalprice += $parcelitems[$i]->{'unitprice'}; |
| 179 |
$line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'}); |
180 |
$line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'}); |
| 180 |
|
181 |
|
| 181 |
#double FIXME - totalfreight is redefined later. |
182 |
$totalfreight += $parcelitems[$i]->{'freight'}; |
| 182 |
|
|
|
| 183 |
# FIXME - each order in a parcel holds the freight for the whole parcel. This means if you receive a parcel with items from multiple budgets, you'll see the freight charge in each budget.. |
| 184 |
if ($i > 0 && $totalfreight != $parcelitems[$i]->{'freight'}) { |
| 185 |
warn "FREIGHT CHARGE MISMATCH!!"; |
| 186 |
} |
| 187 |
$totalfreight = $parcelitems[$i]->{'freight'}; |
| 188 |
$totalquantity += $parcelitems[$i]->{'quantityreceived'}; |
183 |
$totalquantity += $parcelitems[$i]->{'quantityreceived'}; |
| 189 |
$tototal += $total; |
184 |
$tototal += $total; |
| 190 |
} |
185 |
} |
| 191 |
|
186 |
|
| 192 |
my $pendingorders = GetPendingOrders($supplierid); |
187 |
my $pendingorders = GetPendingOrders($supplierid); |
| 193 |
my $countpendings = scalar @$pendingorders; |
188 |
my $countpendingitems = 0; |
|
|
189 |
if ($pendingorders) { |
| 190 |
$countpendingitems += $_->{quantity} || 1 foreach @$pendingorders; |
| 191 |
} |
| 192 |
my $freight_per_item = $freight && $countpendingitems ? $freight/$countpendingitems : 0; |
| 194 |
|
193 |
|
| 195 |
# pending orders totals |
194 |
# pending orders totals |
| 196 |
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd); |
195 |
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd); |
| 197 |
my $ordergrandtotal; |
196 |
my $ordergrandtotal; |
| 198 |
my @loop_orders = (); |
197 |
my @loop_orders = (); |
| 199 |
for (my $i = 0 ; $i < $countpendings ; $i++) { |
198 |
for (my $i = $startfrom; $i < $startfrom + $resultsperpage; $i++) { |
| 200 |
my %line; |
199 |
last unless $pendingorders->[$i]; |
| 201 |
%line = %{$pendingorders->[$i]}; |
200 |
my %line = %{$pendingorders->[$i]}; |
| 202 |
|
201 |
|
| 203 |
$line{quantity}+=0; |
202 |
$line{quantity}+=0; |
| 204 |
$line{quantityreceived}+=0; |
203 |
$line{quantityreceived}+=0; |
|
Lines 210-220
for (my $i = 0 ; $i < $countpendings ; $i++) {
Link Here
|
| 210 |
$line{ecost} = sprintf("%.2f",$line{ecost}); |
209 |
$line{ecost} = sprintf("%.2f",$line{ecost}); |
| 211 |
$line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity}); |
210 |
$line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity}); |
| 212 |
$line{unitprice} = sprintf("%.2f",$line{unitprice}); |
211 |
$line{unitprice} = sprintf("%.2f",$line{unitprice}); |
|
|
212 |
$line{freight} = sprintf("%.2f",$freight_per_item * $line{quantity}); |
| 213 |
$line{invoice} = $invoice; |
213 |
$line{invoice} = $invoice; |
| 214 |
$line{gst} = $gst; |
214 |
$line{gst} = $gst; |
| 215 |
$line{total} = $total; |
215 |
$line{total} = $total; |
| 216 |
$line{supplierid} = $supplierid; |
216 |
$line{supplierid} = $supplierid; |
| 217 |
$ordergrandtotal += $line{ecost} * $line{quantity}; |
217 |
$ordergrandtotal += $line{ecost} * $line{quantity} + $line{freight} || 0; |
| 218 |
|
218 |
|
| 219 |
my $biblionumber = $line{'biblionumber'}; |
219 |
my $biblionumber = $line{'biblionumber'}; |
| 220 |
my $countbiblio = CountBiblioInOrders($biblionumber); |
220 |
my $countbiblio = CountBiblioInOrders($biblionumber); |
|
Lines 244-265
for (my $i = 0 ; $i < $countpendings ; $i++) {
Link Here
|
| 244 |
$line{holds} = $holds; |
244 |
$line{holds} = $holds; |
| 245 |
$line{holds_on_order} = $itemholds?$itemholds:$holds if $line{left_holds_on_order}; |
245 |
$line{holds_on_order} = $itemholds?$itemholds:$holds if $line{left_holds_on_order}; |
| 246 |
|
246 |
|
| 247 |
|
247 |
push @loop_orders, \%line; |
| 248 |
push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage); |
|
|
| 249 |
} |
248 |
} |
| 250 |
$freight = $totalfreight unless $freight; |
|
|
| 251 |
|
249 |
|
| 252 |
my $count = $countpendings; |
250 |
my $countpendings = $pendingorders ? scalar (@$pendingorders) : 0; |
| 253 |
|
251 |
|
| 254 |
if ($count>$resultsperpage){ |
252 |
if ($countpendings>$resultsperpage){ |
| 255 |
my $displaynext=0; |
253 |
my $displaynext=0; |
| 256 |
my $displayprev=$startfrom; |
254 |
my $displayprev=$startfrom; |
| 257 |
if(($count - ($startfrom+$resultsperpage)) > 0 ) { |
255 |
if(($countpendings - ($startfrom+$resultsperpage)) > 0 ) { |
| 258 |
$displaynext = 1; |
256 |
$displaynext = 1; |
| 259 |
} |
257 |
} |
| 260 |
|
258 |
|
| 261 |
my @numbers = (); |
259 |
my @numbers = (); |
| 262 |
for (my $i=1; $i<$count/$resultsperpage+1; $i++) { |
260 |
for (my $i=1; $i<$countpendings/$resultsperpage+1; $i++) { |
| 263 |
my $highlight=0; |
261 |
my $highlight=0; |
| 264 |
($startfrom/$resultsperpage==($i-1)) && ($highlight=1); |
262 |
($startfrom/$resultsperpage==($i-1)) && ($highlight=1); |
| 265 |
push @numbers, { number => $i, |
263 |
push @numbers, { number => $i, |
|
Lines 269-290
if ($count>$resultsperpage){
Link Here
|
| 269 |
|
267 |
|
| 270 |
my $from = $startfrom*$resultsperpage+1; |
268 |
my $from = $startfrom*$resultsperpage+1; |
| 271 |
my $to; |
269 |
my $to; |
| 272 |
if($count < (($startfrom+1)*$resultsperpage)){ |
270 |
if($countpendings < (($startfrom+1)*$resultsperpage)){ |
| 273 |
$to = $count; |
271 |
$to = $countpendings; |
| 274 |
} else { |
272 |
} else { |
| 275 |
$to = (($startfrom+1)*$resultsperpage); |
273 |
$to = (($startfrom+1)*$resultsperpage); |
| 276 |
} |
274 |
} |
| 277 |
$template->param(numbers=>\@numbers, |
275 |
$template->param(numbers=>\@numbers, |
| 278 |
displaynext=>$displaynext, |
276 |
displaynext=>$displaynext, |
| 279 |
displayprev=>$displayprev, |
277 |
displayprev=>$displayprev, |
| 280 |
nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count), |
278 |
nextstartfrom=>(($startfrom+$resultsperpage<$countpendings)?$startfrom+$resultsperpage:$countpendings), |
| 281 |
prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0) |
279 |
prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0) |
| 282 |
); |
280 |
); |
| 283 |
} |
281 |
} |
| 284 |
|
282 |
|
| 285 |
#$totalfreight=$freight; |
|
|
| 286 |
$tototal = $tototal + $freight; |
| 287 |
|
| 288 |
$template->param( |
283 |
$template->param( |
| 289 |
invoice => $invoice, |
284 |
invoice => $invoice, |
| 290 |
datereceived => $datereceived->output('iso'), |
285 |
datereceived => $datereceived->output('iso'), |
|
Lines 300-306
$template->param(
Link Here
|
| 300 |
countpending => $countpendings, |
295 |
countpending => $countpendings, |
| 301 |
loop_orders => \@loop_orders, |
296 |
loop_orders => \@loop_orders, |
| 302 |
totalprice => sprintf($cfstr, $totalprice), |
297 |
totalprice => sprintf($cfstr, $totalprice), |
| 303 |
totalfreight => $totalfreight, |
298 |
totalfreight => sprintf($cfstr, $totalfreight), |
| 304 |
totalquantity => $totalquantity, |
299 |
totalquantity => $totalquantity, |
| 305 |
tototal => sprintf($cfstr, $tototal), |
300 |
tototal => sprintf($cfstr, $tototal), |
| 306 |
ordergrandtotal => sprintf($cfstr, $ordergrandtotal), |
301 |
ordergrandtotal => sprintf($cfstr, $ordergrandtotal), |