DeliveryOrder: neue typen für Lieferschein
authorSven Schöling <s.schoeling@googlemail.com>
Thu, 16 Sep 2021 09:36:40 +0000 (11:36 +0200)
committerJan Büren <jan@kivitendo.de>
Mon, 14 Feb 2022 13:52:11 +0000 (14:52 +0100)
SL/Controller/DeliveryOrder.pm
SL/Controller/DeliveryOrder/TypeData.pm
locale/de/all

index 2ac03a8..6ac67da 100644 (file)
@@ -46,7 +46,7 @@ use Sort::Naturally;
 use Rose::Object::MakeMethods::Generic
 (
  scalar => [ qw(item_ids_to_delete is_custom_shipto_to_delete) ],
- 'scalar --get_set_init' => [ qw(order valid_types type cv p all_price_factors search_cvpartnumber show_update_button part_picker_classification_ids) ],
+ 'scalar --get_set_init' => [ qw(order valid_types type cv p all_price_factors search_cvpartnumber show_update_button part_picker_classification_ids type_data) ],
 );
 
 
@@ -66,7 +66,7 @@ sub action_add {
   my ($self) = @_;
 
   $self->order->transdate(DateTime->now_local());
-  $self->set_reqdate_by_type;
+  $self->type_data->set_reqdate_by_type;
 
 
   $self->pre_render();
@@ -1025,7 +1025,7 @@ sub init_type {
   my ($self) = @_;
 
   if (none { $::form->{type} eq $_ } @{$self->valid_types}) {
-    die "Not a valid type for order";
+    die "Not a valid type for delivery order";
   }
 
   $self->type($::form->{type});
@@ -1069,7 +1069,7 @@ sub init_all_price_factors {
 sub init_part_picker_classification_ids {
   my ($self)    = @_;
 
-  return [ map { $_->id } @{ SL::DB::Manager::PartClassification->get_all(where => $self->type_date->part_classification_query) } ];
+  return [ map { $_->id } @{ SL::DB::Manager::PartClassification->get_all(where => $self->type_data->part_classification_query) } ];
 }
 
 sub check_auth {
@@ -1161,9 +1161,7 @@ sub make_order {
   # order here solves this problem.
   my $order;
   $order   = SL::DB::DeliveryOrder->new(id => $::form->{id})->load(with => [ 'orderitems', 'orderitems.part' ]) if $::form->{id};
-  $order ||= SL::DB::DeliveryOrder->new(orderitems  => [],
-                                quotation   => $self->type_data->is_quotation,
-                                currency_id => $::instance_conf->get_currency_id(),);
+  $order ||= SL::DB::DeliveryOrder->new(orderitems  => [], currency_id => $::instance_conf->get_currency_id(),);
 
   my $cv_id_method = $self->cv . '_id';
   if (!$::form->{id} && $::form->{$cv_id_method}) {
@@ -1572,7 +1570,7 @@ sub pre_render {
     $item->active_discount_source($price_source->discount_from_source($item->active_discount_source));
   }
 
-  if ($self->order->number && $::instance_conf->get_webdav) {
+  if ($self->order->${\ $self->type_data->nr_key } && $::instance_conf->get_webdav) {
     my $webdav = SL::Webdav->new(
       type     => $self->type,
       number   => $self->order->number,
index 705d332..e525f57 100644 (file)
@@ -6,10 +6,12 @@ use Scalar::Util qw(weaken);
 use SL::Locale::String qw(t8);
 
 use constant {
-  SALES_ORDER_TYPE => 'sales_order',
-  PURCHASE_ORDER_TYPE => 'purchase_order',
-  SALES_QUOTATION_TYPE => 'sales_quotation',
-  REQUEST_QUOTATION_TYPE => 'request_quotation'
+  SALES_ORDER_TYPE             => 'sales_order',
+  PURCHASE_ORDER_TYPE          => 'purchase_order',
+  SALES_QUOTATION_TYPE         => 'sales_quotation',
+  REQUEST_QUOTATION_TYPE       => 'request_quotation',
+  PURCHASE_DELIVERY_ORDER_TYPE => 'purchase_delivery_order',
+  SALES_DELIVERY_ORDER_TYPE    => 'sales_delivery_order',
 };
 
 our @EXPORT_OK = qw(SALES_ORDER_TYPE PURCHASE_ORDER_TYPE SALES_QUOTATION_TYPE REQUEST_QUOTATION_TYPE);
@@ -133,6 +135,53 @@ my %type_data = (
     part_classification_query => [ "used_for_purchase" => 1 ],
     right => "request_quotation_edit",
   },
+  SALES_DELIVERY_ORDER_TYPE() => {
+    text => {
+      delete => t8('Delivery Order has been deleted'),
+      saved  => t8('Delivery Order has been saved'),
+      add    => t8("Add Sales Delivery Order"),
+      edit   => t8("Edit Sales Delivery Order"),
+    },
+    show_menu => {
+      save_and_quotation      => 0,
+      save_and_rfq            => 0,
+      save_and_sales_order    => 0,
+      save_and_purchase_order => 0,
+      save_and_delivery_order => 0,
+      save_and_ap_transaction => 0,
+      delete                  => sub { $::instance_conf->get_sales_delivery_order_show_delete },
+    },
+    properties => {
+      customervendor => "customer",
+      nr_key         => "donumber",
+    },
+    part_classification_query => [ "used_for_sale" => 1 ],
+    right => "sales_delivery_order_edit",
+  },
+  PURCHASE_DELIVERY_ORDER_TYPE() => {
+    text => {
+      delete => t8('Delivery Order has been deleted'),
+      saved  => t8('Delivery Order has been saved'),
+      add    => t8("Add Purchase Delivery Order"),
+      edit   => t8("Edit Purchase Delivery Order"),
+    },
+    show_menu => {
+      save_and_quotation      => 0,
+      save_and_rfq            => 0,
+      save_and_sales_order    => 0,
+      save_and_purchase_order => 0,
+      save_and_delivery_order => 0,
+      save_and_ap_transaction => 0,
+      delete                  => sub { $::instance_conf->get_sales_delivery_order_show_delete },
+    },
+    properties => {
+      customervendor => "vendor",
+      nr_key         => "donumber",
+    },
+    part_classification_query => [ "used_for_purchase" => 1 ],
+    right => "purchase_delivery_order_edit",
+  },
+
 );
 
 sub new {
@@ -150,6 +199,8 @@ sub valid_types {
     PURCHASE_ORDER_TYPE,
     SALES_QUOTATION_TYPE,
     REQUEST_QUOTATION_TYPE,
+    SALES_DELIVERY_ORDER_TYPE,
+    PURCHASE_DELIVERY_ORDER_TYPE,
   ];
 }
 
@@ -157,7 +208,7 @@ sub type {
   $_[0]->c->type;
 }
 
-sub get {
+sub _get {
   my ($self, $key) = @_;
 
   my $ret = $type_data{$self->type}->{$key} // die "unknown property '$key'";
@@ -206,7 +257,7 @@ sub type_data {
 }
 
 sub access {
-  $type_data{right};
+  _get($_[0], "right");
 }
 
 sub is_quotation {
index 3bd1203..976b7d1 100755 (executable)
@@ -1060,6 +1060,8 @@ $self->{texts} = {
   'Delivery Order Number'       => 'Lieferscheinnummer',
   'Delivery Order created'      => 'Lieferschein erstellt',
   'Delivery Order deleted!'     => 'Lieferschein gelöscht!',
+  'Delivery Order has been deleted' => 'Lieferschein wurde gelöscht',
+  'Delivery Order has been saved' => 'Lieferschein wurde gespeichert',
   'Delivery Order(s) for full qty created' => 'Lieferschein(e) mit kompletter Menge erstellt',
   'Delivery Orders'             => 'Lieferscheine',
   'Delivery Plan'               => 'Lieferplan',
@@ -2450,7 +2452,7 @@ $self->{texts} = {
   'Part Notes'                  => 'Bemerkungen',
   'Part Number'                 => 'Artikelnummer',
   'Part Number missing!'        => 'Artikelnummer fehlt!',
-  'Part Test'                   => '',
+  'Part Test'                   => 'Artikel-Test',
   'Part Type'                   => 'Artikel-Typ',
   'Part Unit'                   => 'Einheit',
   'Part classifications'        => 'Artikel-Klassifizierungen',