From a16a599942f621e9d27b13a2e2183b9aa44757a7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 15 Oct 2021 17:32:42 +0200 Subject: [PATCH] DeliveryOrder: Konvertierung von is_sales bugs --- SL/DB/DeliveryOrder.pm | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/SL/DB/DeliveryOrder.pm b/SL/DB/DeliveryOrder.pm index 068d6c419..5f6056dbc 100644 --- a/SL/DB/DeliveryOrder.pm +++ b/SL/DB/DeliveryOrder.pm @@ -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 { -- 2.20.1