}
# 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};
# 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 {