S/D/Order: new_from/new_from_multi: Bearbeiter ist immer der aktuelle Benutzer
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 20 Sep 2021 09:22:25 +0000 (11:22 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 20 Sep 2021 09:39:54 +0000 (11:39 +0200)
Bei Workflows zu neuen Belegen ist der Bearbeiter des neuen Belegs immer der
aktuelle Benutzer, egal, was im vorherigen Beleg steht.

SL/DB/Order.pm

index fe0b321..f1cfba7 100644 (file)
@@ -328,7 +328,7 @@ sub new_from {
   }
 
   my %args = ( map({ ( $_ => $source->$_ ) } qw(amount cp_id currency_id cusordnumber customer_id delivery_customer_id delivery_term_id delivery_vendor_id
-                                                department_id employee_id exchangerate globalproject_id intnotes marge_percent marge_total language_id netamount notes
+                                                department_id exchangerate globalproject_id intnotes marge_percent marge_total language_id netamount notes
                                                 ordnumber payment_id quonumber reqdate salesman_id shippingpoint shipvia taxincluded tax_point taxzone_id
                                                 transaction_description vendor_id
                                              )),
@@ -336,13 +336,13 @@ sub new_from {
                closed    => 0,
                delivered => 0,
                transdate => DateTime->today_local,
+               employee  => SL::DB::Manager::Employee->current,
             );
 
   if ( $is_abbr_any->(qw(sopo poso)) ) {
     $args{ordnumber} = undef;
     $args{quonumber} = undef;
     $args{reqdate}   = DateTime->today_local->next_workday();
-    $args{employee}  = SL::DB::Manager::Employee->current;
   }
   if ( $is_abbr_any->(qw(sopo)) ) {
     $args{customer_id}      = undef;
@@ -448,7 +448,7 @@ sub new_from_multi {
                        order_probability expected_billing_date)) {
     $attributes{$attr} = undef if any { ($sources->[0]->$attr//'') ne ($_->$attr//'') } @$sources;
   }
-  foreach my $attr (qw(cp_id currency_id employee_id salesman_id department_id
+  foreach my $attr (qw(cp_id currency_id salesman_id department_id
                        delivery_customer_id delivery_vendor_id shipto_id
                        globalproject_id exchangerate)) {
     $attributes{$attr} = undef if any { ($sources->[0]->$attr||0) != ($_->$attr||0) }   @$sources;
@@ -463,6 +463,9 @@ sub new_from_multi {
   # no periodic invoice config for new order
   $attributes{periodic_invoices_config} = undef;
 
+  # set emplyee to the current one
+  $attributes{employee} = SL::DB::Manager::Employee->current;
+
   # copy global ordnumber, transdate, cusordnumber into item scope
   #   unless already present there
   foreach my $attr (qw(ordnumber transdate cusordnumber)) {