|
Lines 216-234
for (my $i = 0 ; $i < $countlines ; $i++) {
Link Here
|
| 216 |
$totalprice += $parcelitems[$i]->{'unitprice'}; |
216 |
$totalprice += $parcelitems[$i]->{'unitprice'}; |
| 217 |
$line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'}); |
217 |
$line{unitprice} = sprintf($cfstr, $parcelitems[$i]->{'unitprice'}); |
| 218 |
|
218 |
|
| 219 |
#double FIXME - totalfreight is redefined later. |
219 |
$totalfreight += $parcelitems[$i]->{'freight'}; |
| 220 |
|
|
|
| 221 |
# 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.. |
| 222 |
if ($i > 0 && $totalfreight != $parcelitems[$i]->{'freight'}) { |
| 223 |
warn "FREIGHT CHARGE MISMATCH!!"; |
| 224 |
} |
| 225 |
$totalfreight = $parcelitems[$i]->{'freight'}; |
| 226 |
$totalquantity += $parcelitems[$i]->{'quantityreceived'}; |
220 |
$totalquantity += $parcelitems[$i]->{'quantityreceived'}; |
| 227 |
$tototal += $total; |
221 |
$tototal += $total; |
| 228 |
} |
222 |
} |
| 229 |
|
223 |
|
| 230 |
my $pendingorders = GetPendingOrders($supplierid); |
224 |
my $pendingorders = GetPendingOrders($supplierid); |
| 231 |
my $countpendings = scalar @$pendingorders; |
225 |
my $countpendings = scalar @$pendingorders; |
|
|
226 |
my $freight_per_order = $freight && $countpendings ? $freight/$countpendings : 0; |
| 232 |
|
227 |
|
| 233 |
# pending orders totals |
228 |
# pending orders totals |
| 234 |
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd); |
229 |
my ($totalPunitprice, $totalPquantity, $totalPecost, $totalPqtyrcvd); |
|
Lines 247-252
for (my $i = 0 ; $i < $countpendings ; $i++) {
Link Here
|
| 247 |
$line{ecost} = sprintf("%.2f",$line{ecost}); |
242 |
$line{ecost} = sprintf("%.2f",$line{ecost}); |
| 248 |
$line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity}); |
243 |
$line{ordertotal} = sprintf("%.2f",$line{ecost}*$line{quantity}); |
| 249 |
$line{unitprice} = sprintf("%.2f",$line{unitprice}); |
244 |
$line{unitprice} = sprintf("%.2f",$line{unitprice}); |
|
|
245 |
$line{freight} = sprintf("%.2f",$freight_per_order); |
| 250 |
$line{invoice} = $invoice; |
246 |
$line{invoice} = $invoice; |
| 251 |
$line{gst} = $gst; |
247 |
$line{gst} = $gst; |
| 252 |
$line{total} = $total; |
248 |
$line{total} = $total; |
|
Lines 254-260
for (my $i = 0 ; $i < $countpendings ; $i++) {
Link Here
|
| 254 |
$ordergrandtotal += $line{ecost} * $line{quantity}; |
250 |
$ordergrandtotal += $line{ecost} * $line{quantity}; |
| 255 |
push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage); |
251 |
push @loop_orders, \%line if ($i >= $startfrom and $i < $startfrom + $resultsperpage); |
| 256 |
} |
252 |
} |
| 257 |
$freight = $totalfreight unless $freight; |
|
|
| 258 |
|
253 |
|
| 259 |
my $count = $countpendings; |
254 |
my $count = $countpendings; |
| 260 |
|
255 |
|
|
Lines 289-296
if ($count>$resultsperpage){
Link Here
|
| 289 |
); |
284 |
); |
| 290 |
} |
285 |
} |
| 291 |
|
286 |
|
| 292 |
#$totalfreight=$freight; |
287 |
$tototal = $tototal + $totalfreight; |
| 293 |
$tototal = $tototal + $freight; |
|
|
| 294 |
|
288 |
|
| 295 |
$template->param( |
289 |
$template->param( |
| 296 |
invoice => $invoice, |
290 |
invoice => $invoice, |
|
Lines 307-313
$template->param(
Link Here
|
| 307 |
countpending => $countpendings, |
301 |
countpending => $countpendings, |
| 308 |
loop_orders => \@loop_orders, |
302 |
loop_orders => \@loop_orders, |
| 309 |
totalprice => sprintf($cfstr, $totalprice), |
303 |
totalprice => sprintf($cfstr, $totalprice), |
| 310 |
totalfreight => $totalfreight, |
304 |
totalfreight => sprintf($cfstr, $totalfreight), |
| 311 |
totalquantity => $totalquantity, |
305 |
totalquantity => $totalquantity, |
| 312 |
tototal => sprintf($cfstr, $tototal), |
306 |
tototal => sprintf($cfstr, $tototal), |
| 313 |
ordergrandtotal => sprintf($cfstr, $ordergrandtotal), |
307 |
ordergrandtotal => sprintf($cfstr, $ordergrandtotal), |