Zeiterfassung: Konvertierung: Position aus zugehörigem Auftrag
[kivitendo-erp.git] / SL / OE.pm
index 759f962..1b640e3 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -123,6 +123,7 @@ sub transactions {
     qq|  o.marge_total, o.marge_percent, | .
     qq|  o.exchangerate, | .
     qq|  o.itime::DATE AS insertdate, | .
+    qq|  o.intnotes, | .
     qq|  department.description as department, | .
     qq|  ex.$rate AS daily_exchangerate, | .
     qq|  pt.description AS payment_terms, | .
@@ -296,6 +297,11 @@ SQL
     push @values, conv_date($form->{expected_billing_date_to});
   }
 
+  if ($form->{intnotes}) {
+    $query .= qq| AND o.intnotes ILIKE ?|;
+    push(@values, like($form->{intnotes}));
+  }
+
   if ($form->{parts_partnumber}) {
     $query .= <<SQL;
       AND EXISTS (
@@ -363,6 +369,7 @@ SQL
     "taxzone"                 => "tz.description",
     "payment_terms"           => "pt.description",
     "department"              => "department.description",
+    "intnotes"                => "o.intnotes",
   );
   if ($form->{sort} && grep($form->{sort}, keys(%allowed_sort_columns))) {
     $sortorder = $allowed_sort_columns{$form->{sort}} . " ${sortdir}"  . ", o.itime ${sortdir}";
@@ -979,7 +986,12 @@ sub _retrieve {
   if (!$form->{id}) {
     my $extra_days = $form->{type} eq 'sales_quotation' ? $::instance_conf->get_reqdate_interval       :
                      $form->{type} eq 'sales_order'     ? $::instance_conf->get_delivery_date_interval : 1;
-    $form->{reqdate}   = DateTime->today_local->next_workday(extra_days => $extra_days)->to_kivitendo;
+    if (   ($form->{type} eq 'sales_order'     &&  !$::instance_conf->get_deliverydate_on)
+        || ($form->{type} eq 'sales_quotation' &&  !$::instance_conf->get_reqdate_on)) {
+      $form->{reqdate}   = '';
+    } else {
+      $form->{reqdate}   = DateTime->today_local->next_workday(extra_days => $extra_days)->to_kivitendo;
+    }
     $form->{transdate} = DateTime->today_local->to_kivitendo;
   }