Lines 178-204
for (my $i = 0 ; $i < $countlines ; $i++) {
Link Here
|
178 |
$totalprice += $parcelitems[$i]->{'unitprice'}; |
178 |
$totalprice += $parcelitems[$i]->{'unitprice'}; |
179 |
$line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'}); |
179 |
$line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'}); |
180 |
|
180 |
|
181 |
#double FIXME - totalfreight is redefined later. |
181 |
$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'}; |
182 |
$totalquantity += $parcelitems[$i]->{'quantityreceived'}; |
189 |
$tototal += $total; |
183 |
$tototal += $total; |
190 |
} |
184 |
} |
191 |
|
185 |
|
192 |
my $pendingorders = GetPendingOrders($supplierid); |
186 |
my $pendingorders = GetPendingOrders($supplierid); |
193 |
my $countpendings = scalar @$pendingorders; |
187 |
my $countpendingitems = 0; |
|
|
188 |
if ($pendingorders) { |
189 |
$countpendingitems += $_->{items} || 1 foreach @$pendingorders; |
190 |
} |
191 |
my $freight_per_item = $freight && $countpendingitems ? $freight/$countpendingitems : 0; |
194 |
|
192 |
|
195 |
# pending orders totals |
193 |
# pending orders totals |
196 |
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd); |
194 |
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd); |
197 |
my $ordergrandtotal; |
195 |
my $ordergrandtotal; |
198 |
my @loop_orders = (); |
196 |
my @loop_orders = (); |
199 |
for (my $i = 0 ; $i < $countpendings ; $i++) { |
197 |
for (my $i = $startfrom; $i < $startfrom + $resultsperpage; $i++) { |
200 |
my %line; |
198 |
last unless $pendingorders->[$i]; |
201 |
%line = %{$pendingorders->[$i]}; |
199 |
my %line = %{$pendingorders->[$i]}; |
202 |
|
200 |
|
203 |
$line{quantity}+=0; |
201 |
$line{quantity}+=0; |
204 |
$line{quantityreceived}+=0; |
202 |
$line{quantityreceived}+=0; |
Lines 210-215
for (my $i = 0 ; $i < $countpendings ; $i++) {
Link Here
|
210 |
$line{ecost} = sprintf("%.2f",$line{ecost}); |
208 |
$line{ecost} = sprintf("%.2f",$line{ecost}); |
211 |
$line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity}); |
209 |
$line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity}); |
212 |
$line{unitprice} = sprintf("%.2f",$line{unitprice}); |
210 |
$line{unitprice} = sprintf("%.2f",$line{unitprice}); |
|
|
211 |
$line{freight} = sprintf("%.2f",$freight_per_item * ($line{items} || 1)); |
213 |
$line{invoice} = $invoice; |
212 |
$line{invoice} = $invoice; |
214 |
$line{gst} = $gst; |
213 |
$line{gst} = $gst; |
215 |
$line{total} = $total; |
214 |
$line{total} = $total; |
Lines 244-265
for (my $i = 0 ; $i < $countpendings ; $i++) {
Link Here
|
244 |
$line{holds} = $holds; |
243 |
$line{holds} = $holds; |
245 |
$line{holds_on_order} = $itemholds?$itemholds:$holds if $line{left_holds_on_order}; |
244 |
$line{holds_on_order} = $itemholds?$itemholds:$holds if $line{left_holds_on_order}; |
246 |
|
245 |
|
247 |
|
246 |
push @loop_orders, \%line; |
248 |
push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage); |
|
|
249 |
} |
247 |
} |
250 |
$freight = $totalfreight unless $freight; |
|
|
251 |
|
248 |
|
252 |
my $count = $countpendings; |
249 |
my $countpendings = $pendingorders ? scalar (@$pendingorders) : 0; |
253 |
|
250 |
|
254 |
if ($count>$resultsperpage){ |
251 |
if ($countpendings>$resultsperpage){ |
255 |
my $displaynext=0; |
252 |
my $displaynext=0; |
256 |
my $displayprev=$startfrom; |
253 |
my $displayprev=$startfrom; |
257 |
if(($count - ($startfrom+$resultsperpage)) > 0 ) { |
254 |
if(($countpendings - ($startfrom+$resultsperpage)) > 0 ) { |
258 |
$displaynext = 1; |
255 |
$displaynext = 1; |
259 |
} |
256 |
} |
260 |
|
257 |
|
261 |
my @numbers = (); |
258 |
my @numbers = (); |
262 |
for (my $i=1; $i<$count/$resultsperpage+1; $i++) { |
259 |
for (my $i=1; $i<$countpendings/$resultsperpage+1; $i++) { |
263 |
my $highlight=0; |
260 |
my $highlight=0; |
264 |
($startfrom/$resultsperpage==($i-1)) && ($highlight=1); |
261 |
($startfrom/$resultsperpage==($i-1)) && ($highlight=1); |
265 |
push @numbers, { number => $i, |
262 |
push @numbers, { number => $i, |
Lines 269-289
if ($count>$resultsperpage){
Link Here
|
269 |
|
266 |
|
270 |
my $from = $startfrom*$resultsperpage+1; |
267 |
my $from = $startfrom*$resultsperpage+1; |
271 |
my $to; |
268 |
my $to; |
272 |
if($count < (($startfrom+1)*$resultsperpage)){ |
269 |
if($countpendings < (($startfrom+1)*$resultsperpage)){ |
273 |
$to = $count; |
270 |
$to = $countpendings; |
274 |
} else { |
271 |
} else { |
275 |
$to = (($startfrom+1)*$resultsperpage); |
272 |
$to = (($startfrom+1)*$resultsperpage); |
276 |
} |
273 |
} |
277 |
$template->param(numbers=>\@numbers, |
274 |
$template->param(numbers=>\@numbers, |
278 |
displaynext=>$displaynext, |
275 |
displaynext=>$displaynext, |
279 |
displayprev=>$displayprev, |
276 |
displayprev=>$displayprev, |
280 |
nextstartfrom=>(($startfrom+$resultsperpage<$count)?$startfrom+$resultsperpage:$count), |
277 |
nextstartfrom=>(($startfrom+$resultsperpage<$countpendings)?$startfrom+$resultsperpage:$countpendings), |
281 |
prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0) |
278 |
prevstartfrom=>(($startfrom-$resultsperpage>0)?$startfrom-$resultsperpage:0) |
282 |
); |
279 |
); |
283 |
} |
280 |
} |
284 |
|
281 |
|
285 |
#$totalfreight=$freight; |
282 |
$tototal = $tototal + $totalfreight; |
286 |
$tototal = $tototal + $freight; |
|
|
287 |
|
283 |
|
288 |
$template->param( |
284 |
$template->param( |
289 |
invoice => $invoice, |
285 |
invoice => $invoice, |
Lines 300-306
$template->param(
Link Here
|
300 |
countpending => $countpendings, |
296 |
countpending => $countpendings, |
301 |
loop_orders => \@loop_orders, |
297 |
loop_orders => \@loop_orders, |
302 |
totalprice => sprintf($cfstr, $totalprice), |
298 |
totalprice => sprintf($cfstr, $totalprice), |
303 |
totalfreight => $totalfreight, |
299 |
totalfreight => sprintf($cfstr, $totalfreight), |
304 |
totalquantity => $totalquantity, |
300 |
totalquantity => $totalquantity, |
305 |
tototal => sprintf($cfstr, $tototal), |
301 |
tototal => sprintf($cfstr, $tototal), |
306 |
ordergrandtotal => sprintf($cfstr, $ordergrandtotal), |
302 |
ordergrandtotal => sprintf($cfstr, $ordergrandtotal), |