check_oe_access();
$main::auth->assert('purchase_order_edit');
+ $form->{sales_order_to_purchase_order} = 0;
if ($form->{type} eq 'sales_order') {
+ $form->{sales_order_to_purchase_order} = 1;
check_for_direct_delivery();
}
&poso;
+ delete $form->{sales_order_to_purchase_order};
+
$main::lxdebug->leave_sub();
}
$form->{old_salesman_id} = $form->{salesman_id};
# reset
- map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal delivered
- ordnumber);
+ map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal delivered ordnumber);
+
+ # if purchase_order was generated from sales_order, use lastcost_$i as sellprice_$i
+ if ( $form->{sales_order_to_purchase_order} ) {
+ for my $i (1 .. $form->{rowcount}) {
+ $form->{"sellprice_${i}"} = $form->parse_amount(\%myconfig, $form->{"lastcost_${i}"});
+ };
+ };
for my $i (1 .. $form->{rowcount}) {
map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice basefactor discount);