DeliveryOrder: Konvertierung von is_sales bugs
authorSven Schöling <s.schoeling@googlemail.com>
Fri, 15 Oct 2021 15:32:42 +0000 (17:32 +0200)
committerJan Büren <jan@kivitendo.de>
Mon, 14 Feb 2022 13:58:19 +0000 (14:58 +0100)
SL/DB/DeliveryOrder.pm

index 068d6c4..5f6056d 100644 (file)
@@ -153,13 +153,13 @@ sub new_from {
   }
 
   # infer type from legacy fields if not given
-  $params{order_type} //= $source->customer_id ? 'sales_delivery_order'
-                        : $source->vendor_id   ? 'purchase_delivery_order'
-                        : $source->is_sales    ? 'sales_delivery_order'
-                        : croak "need some way to set delivery order type from source";
+  $args{order_type} //= $source->customer_id ? 'sales_delivery_order'
+                      : $source->vendor_id   ? 'purchase_delivery_order'
+                      : $source->is_sales    ? 'sales_delivery_order'
+                      : croak "need some way to set delivery order type from source";
 
   # overwrite legacy is_sales from type_data
-  $args{is_sales} = SL::Controller::DeliveryOrder::TypeData::get3($params{order_type}, "properties", "is_customer");
+  $args{is_sales} = SL::Controller::DeliveryOrder::TypeData::get3($args{order_type}, "properties", "is_customer");
 
   my $delivery_order = $class->new(%args);
   $delivery_order->assign_attributes(%{ $params{attributes} }) if $params{attributes};
@@ -321,7 +321,10 @@ sub new_from_time_recordings {
 # legacy for compatibility
 # use type_data cusomtervendor and transfer direction instead
 sub is_sales {
-  SL::Controller::DeliveryOrder::TypeData::get3($_[0]->order_type, "properties", "is_customer");
+  if ($_[0]->order_type) {
+   return SL::Controller::DeliveryOrder::TypeData::get3($_[0]->order_type, "properties", "is_customer");
+  }
+  return $_[0]{is_sales};
 }
 
 sub customervendor {