}
my $project_id;
- my $reqdate;
+ my $items_reqdate;
$form->get_lists('price_factors' => 'ALL_PRICE_FACTORS');
my %price_factors = map { $_->{id} => $_->{factor} } @{ $form->{ALL_PRICE_FACTORS} };
$price_factor = $price_factors{ $form->{"price_factor_id_$i"} } || 1;
my $linetotal = $form->round_amount($form->{"sellprice_$i"} * $form->{"qty_$i"} / $price_factor, 2);
- $reqdate = ($form->{"reqdate_$i"}) ? $form->{"reqdate_$i"} : undef;
+ $items_reqdate = ($form->{"reqdate_$i"}) ? $form->{"reqdate_$i"} : undef;
do_statement($form, $h_item_id, $q_item_id);
my ($item_id) = $h_item_id->fetchrow_array();
$form->{"description_$i"}, $form->{"longdescription_$i"},
$form->{"qty_$i"}, $baseqty,
$form->{"sellprice_$i"}, $form->{"discount_$i"} / 100,
- $form->{"unit_$i"}, conv_date($reqdate), conv_i($form->{"project_id_$i"}),
+ $form->{"unit_$i"}, conv_date($items_reqdate), conv_i($form->{"project_id_$i"}),
$form->{"serialnumber_$i"},
$form->{"ordnumber_$i"}, conv_date($form->{"transdate_$i"}),
$form->{"cusordnumber_$i"},
$h_item_stock->finish();
+ # reqdate is last items reqdate (?: old behaviour) if not already set
+ $form->{reqdate} ||= $items_reqdate;
# save DO record
$query =
qq|UPDATE delivery_orders SET
@values = ($form->{donumber}, $form->{ordnumber},
$form->{cusordnumber}, conv_date($form->{transdate}),
conv_i($form->{vendor_id}), conv_i($form->{customer_id}),
- conv_date($reqdate), $form->{shippingpoint}, $form->{shipvia},
+ conv_date($form->{reqdate}), $form->{shippingpoint}, $form->{shipvia},
$form->{notes}, $form->{intnotes},
$form->{closed} ? 't' : 'f', $form->{delivered} ? "t" : "f",
conv_i($form->{department_id}), conv_i($form->{language_id}), conv_i($form->{shipto_id}),
my $mode = !$params{ids} ? 'default' : ref $params{ids} eq 'ARRAY' ? 'multi' : 'single';
if ($mode eq 'default') {
- $ref = selectfirst_hashref_query($form, $dbh, qq|SELECT current_date AS transdate, current_date AS reqdate|);
+ $ref = selectfirst_hashref_query($form, $dbh, qq|SELECT current_date AS transdate|);
map { $form->{$_} = $ref->{$_} } keys %$ref;
+ # if reqdate is not set from oe-workflow, set it to transdate (which is current date)
+ $form->{reqdate} ||= $form->{transdate};
+
# get last name used
$form->lastname_used($dbh, $myconfig, $vc) unless $form->{"${vc}_id"};