commit 8eaf5ab5ad644497b36c231cceeda97049a0693c
Author: Tamino Steinert <tamino.steinert@tamino.st>
Date:   Wed Feb 15 17:48:49 2023 +0100

    Model::Record: update_after_new implementiert

diff --git a/SL/Controller/DeliveryOrder.pm b/SL/Controller/DeliveryOrder.pm
index e0bb89919..1b533bf3f 100644
--- a/SL/Controller/DeliveryOrder.pm
+++ b/SL/Controller/DeliveryOrder.pm
@@ -78,9 +78,7 @@ __PACKAGE__->run_before('get_unalterable_data',
 sub action_add {
   my ($self) = @_;
 
-  $self->order->transdate(DateTime->now_local());
-  $self->type_data->set_reqdate_by_type;
-
+  $self->order(SL::Model::Record->update_after_new($self->order, $self->type));
 
   $self->pre_render();
 
diff --git a/SL/Controller/Order.pm b/SL/Controller/Order.pm
index 0706ef778..42b7bde38 100644
--- a/SL/Controller/Order.pm
+++ b/SL/Controller/Order.pm
@@ -77,16 +77,7 @@ __PACKAGE__->run_before('check_auth_for_edit',
 sub action_add {
   my ($self) = @_;
 
-  $self->order->transdate(DateTime->now_local());
-  my $extra_days = $self->type eq sales_quotation_type() ? $::instance_conf->get_reqdate_interval       :
-                   $self->type eq sales_order_type()     ? $::instance_conf->get_delivery_date_interval : 1;
-
-  if (   ($self->type eq sales_order_type()     &&  $::instance_conf->get_deliverydate_on)
-      || ($self->type eq sales_quotation_type() &&  $::instance_conf->get_reqdate_on)
-      && (!$self->order->reqdate)) {
-    $self->order->reqdate(DateTime->today_local->next_workday(extra_days => $extra_days));
-  }
-
+  $self->order(SL::Model::Record->update_after_new($self->order, $self->type));
 
   $self->pre_render();
 
diff --git a/SL/Controller/Reclamation.pm b/SL/Controller/Reclamation.pm
index 713fe3fa5..394d4f3e3 100644
--- a/SL/Controller/Reclamation.pm
+++ b/SL/Controller/Reclamation.pm
@@ -98,7 +98,7 @@ __PACKAGE__->run_before('get_record_links_data_from_form',
 sub action_add {
   my ($self) = @_;
 
-  $self->reclamation->transdate(DateTime->now_local());
+  $self->reclamation(SL::Model::Record->update_after_new($self->reclamation, $self->type));
 
   $self->pre_render();
 
diff --git a/SL/Model/Record.pm b/SL/Model/Record.pm
index c6eacfed9..c32be7f74 100644
--- a/SL/Model/Record.pm
+++ b/SL/Model/Record.pm
@@ -17,16 +17,70 @@ use SL::DB::ValidityToken;
 use SL::Util qw(trim);
 use SL::Locale::String qw(t8);
 
-sub new {
-  my ($class, $target_type, %flags) = @_;
+sub update_after_new {
+  my ($class, $new_record, $subtype, %flags) = @_;
 
-  # target_type: der angeforderte typ
+  my $type_info = {
+    # order
+    sales_quotation => {
+      get_new_reqdate => sub {
+        if ($::instance_conf->get_reqdate_on) {
+          return DateTime->today_local->next_workday(
+            extra_days => $::instance_conf->get_reqdate_interval());
+        } else {
+          return '';
+        }
+      },
+    },
+    sales_order => {
+      get_new_reqdate => sub {
+        if ($::instance_conf->get_deliverydate_on) {
+          return DateTime->today_local->next_workday(
+            extra_days => $::instance_conf->get_delivery_date_interval());
+        } else {
+          return '';
+        }
+      },
+    },
+    request_quotation => {
+      get_new_reqdate => sub { DateTime->today_local->next_workday(extra_days => 1); },
+    },
+    purchase_order => {
+      get_new_reqdate => sub { DateTime->today_local->next_workday(extra_days => 1); },
+    },
+    # delivery_order
+    rma_delivery_order => {
+      get_new_reqdate => sub { DateTime->today_local->next_workday(extra_days => 1); },
+    },
+    sales_delivery_order => {
+      get_new_reqdate => sub { DateTime->today_local->next_workday(extra_days => 1); },
+    },
+    supplier_delivery_order => {
+      get_new_reqdate => sub { DateTime->today_local->next_workday(extra_days => 1); },
+    },
+    purchase_delivery_order => {
+      get_new_reqdate => sub { DateTime->today_local->next_workday(extra_days => 1); },
+    },
+    # reclamation
+    sales_reclamation => {
+      get_new_reqdate => sub { return; },
+    },
+    purchase_reclamation => {
+      get_new_reqdate => sub { return; },
+    },
+  };
+
+  $new_record->transdate(DateTime->now_local());
+  $new_record->reqdate($type_info->{$subtype}->{get_new_reqdate}->());
+
+  # new_record: der neuerstellte objekt
   # flags: zusätzliche informationen zu der behanldung (soll    )
 
   # (aus add) neues record mit vorbereitenden sachen wie transdate/reqdate
   #
   # rückgabe: neues objekt
   # fehlerfall: exception
+  return $new_record;
 }
 
 sub new_from_workflow {
