($form->{currency}) = split /:/, $form->{currencies};
+ # set reqdate if this is an invoice->order conversion. If someone knows a better check to ensure
+ # we come from invoices, feel free.
+ $form->{reqdate} = $form->{deliverydate} if ($form->{deliverydate} and $form->{callback} =~ /action=ar_transactions/);
+
if ($form->{id} or @ids) {
# retrieve order for single id
$dec = length $dec;
my $decimalplaces = ($dec > 2) ? $dec : 2;
- my $discount =
- $form->round_amount(
- $sellprice * $form->parse_amount($myconfig,
- $form->{"discount_$i"}) / 100,
- $decimalplaces);
+ my $i_discount = $form->round_amount($sellprice *
+ $form->parse_amount($myconfig, $form->{"discount_$i"}) / 100, $decimalplaces);
+
+ my $discount = $form->round_amount($form->{"qty_$i"} * $i_discount, $decimalplaces);
# keep a netprice as well, (sellprice - discount)
- $form->{"netprice_$i"} = $sellprice - $discount;
+ #$form->{"netprice_$i"} = $sellprice - $discount;
+ $form->{"netprice_$i"} = $sellprice - $i_discount;
my $linetotal =
$form->round_amount($form->{"qty_$i"} * $form->{"netprice_$i"}, 2);
$linetotal = ($linetotal != 0) ? $linetotal : " ";
push(@{ $form->{discount} }, $discount);
+ push(@{ $form->{p_discount} }, $form->{"discount_$i"});
$form->{ordtotal} += $linetotal;