DeliveryOrder: neue Typen: supplier_delivery_order und rma_delivery_order
authorSven Schöling <s.schoeling@googlemail.com>
Mon, 20 Sep 2021 17:30:19 +0000 (19:30 +0200)
committerJan Büren <jan@kivitendo.de>
Mon, 14 Feb 2022 13:53:49 +0000 (14:53 +0100)
SL/Controller/DeliveryOrder.pm
SL/Controller/DeliveryOrder/TypeData.pm
locale/de/all

index 6a653f8..feeff1c 100644 (file)
@@ -205,7 +205,7 @@ sub action_save_as_new {
                         : $order->transdate;
 
   # Set new reqdate unless changed if it is enabled in client config
-  $new_attrs{reqdate} = $self->get_reqdate_by_type($order->reqdate, $saved_order->reqdate);
+  $new_attrs{reqdate} = $self->type_data->get_reqdate_by_type($order->reqdate, $saved_order->reqdate);
 
   # Update employee
   $new_attrs{employee}  = SL::DB::Manager::Employee->current;
@@ -1644,6 +1644,7 @@ sub setup_edit_action_bar {
         action => [
           t8('Save and Invoice'),
           call      => [ 'kivi.DeliveryOrder.save', 'save_and_invoice', $::instance_conf->get_order_warn_duplicate_parts ],
+          only_if  => $self->type_data->show_menu("save_and_invoice"),
         ],
         action => [
           t8('Save and AP Transaction'),
index d6828a1..6e49d42 100644 (file)
@@ -6,145 +6,75 @@ 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',
-  PURCHASE_DELIVERY_ORDER_TYPE => 'purchase_delivery_order',
   SALES_DELIVERY_ORDER_TYPE    => 'sales_delivery_order',
+  PURCHASE_DELIVERY_ORDER_TYPE => 'purchase_delivery_order',
+  SUPPLIER_DELIVERY_ORDER_TYPE => 'supplier_delivery_order',
+  RMA_DELIVERY_ORDER_TYPE      => 'rma_delivery_order',
 };
 
-our @EXPORT_OK = qw(SALES_ORDER_TYPE PURCHASE_ORDER_TYPE SALES_QUOTATION_TYPE REQUEST_QUOTATION_TYPE);
+our @EXPORT_OK = qw(SALES_DELIVERY_ORDER_TYPE PURCHASE_DELIVERY_ORDER_TYPE SUPPLIER_DELIVERY_ORDER_TYPE RMA_DELIVERY_ORDER_TYPE);
 
 use Rose::Object::MakeMethods::Generic scalar => [ qw(c) ];
 
 my %type_data = (
-  SALES_ORDER_TYPE() => {
-    text => {
-      delete => t8('The order has been deleted'),
-      saved  => t8('The order has been saved'),
-      add    => t8("Add Sales Order"),
-      edit   => t8("Edit Sales Order"),
-    },
-    show_menu => {
-      save_and_quotation      => 1,
-      save_and_rfq            => 0,
-      save_and_sales_order    => 0,
-      save_and_purchase_order => 1,
-      save_and_delivery_order => 1,
-      save_and_ap_transaction => 0,
-      delete                  => sub { $::instance_conf->get_sales_order_show_delete },
-    },
-    workflow => {
-      to_order_type        => "purchase_order",
-      to_quotation_type    => "sales_quotation",
-      to_order_copy_shipto => 1,
-    },
-    properties => {
-      customervendor => "customer",
-      is_quotation   => 0,
-      is_customer    => 1,
-      nr_key         => "ordnumber",
-    },
-    part_classification_query => [ "used_for_sale" => 1 ],
-    right => "sales_order_edit",
-  },
-  PURCHASE_ORDER_TYPE() => {
-    text =>{
-      delete => t8('The order has been deleted'),
-      saved  => t8('The order has been saved'),
-      add    => t8("Add Purchase Order"),
-      edit   => t8("Edit Purchase Order"),
-    },
-    show_menu => {
-      save_and_quotation      => 0,
-      save_and_rfq            => 1,
-      save_and_sales_order    => 1,
-      save_and_purchase_order => 0,
-      save_and_delivery_order => 1,
-      save_and_ap_transaction => 1,
-      delete                  => sub { $::instance_conf->get_purchase_order_show_delete },
-    },
-    workflow => {
-      to_order_type        => "sales_order",
-      to_quotation_type    => "request_quotation",
-      to_order_copy_shipto => 0,
-    },
-    properties => {
-      customervendor => "vendor",
-      is_quotation   => 0,
-      is_customer    => 0,
-      nr_key         => "ordnumber",
-    },
-    part_classification_query => [ "used_for_purchase" => 1 ],
-    right => "purchase_order_edit",
-  },
-  SALES_QUOTATION_TYPE() => {
+  SALES_DELIVERY_ORDER_TYPE() => {
     text => {
-      delete => t8('The quotation has been deleted'),
-      saved  => t8('The quotation has been saved'),
-      add    => t8("Add Quotation"),
-      edit   => t8("Edit Quotation"),
+      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    => 1,
+      save_and_sales_order    => 0,
       save_and_purchase_order => 0,
       save_and_delivery_order => 0,
       save_and_ap_transaction => 0,
-      delete                  => 1,
-    },
-    workflow => {
-      to_order_type        => "sales_order",
-      to_quotation_type    => "request_quotation",
-      to_order_copy_shipto => 0,
+      save_and_invoice        => 0,
+      delete                  => sub { $::instance_conf->get_sales_delivery_order_show_delete },
     },
     properties => {
       customervendor => "customer",
-      is_quotation   => 1,
       is_customer    => 1,
-      nr_key         => "quonumber",
+      nr_key         => "donumber",
+      transfer       => 'out',
     },
     part_classification_query => [ "used_for_sale" => 1 ],
-    right => "sales_quotation_edit",
+    right => "sales_delivery_order_edit",
   },
-  REQUEST_QUOTATION_TYPE() => {
+  PURCHASE_DELIVERY_ORDER_TYPE() => {
     text => {
-      delete => t8('The rfq has been deleted'),
-      saved  => t8('The rfq has been saved'),
-      add    => t8("Add Request for Quotation"),
-      edit   => t8("Edit Request for Quotation"),
+      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 => 1,
+      save_and_purchase_order => 0,
       save_and_delivery_order => 0,
       save_and_ap_transaction => 0,
-      delete                  => 1,
-    },
-    workflow => {
-      to_order_type        => "purchase_order",
-      to_quotation_type    => "request_quotation",
-      to_order_copy_shipto => 0,
+      save_and_invoice        => 0,
+      delete                  => sub { $::instance_conf->get_sales_delivery_order_show_delete },
     },
     properties => {
       customervendor => "vendor",
-      is_quotation   => 1,
       is_customer    => 0,
-      nr_key         => "quonumber",
+      nr_key         => "donumber",
+      transfer       => 'in',
     },
     part_classification_query => [ "used_for_purchase" => 1 ],
-    right => "request_quotation_edit",
+    right => "purchase_delivery_order_edit",
   },
-  SALES_DELIVERY_ORDER_TYPE() => {
+  SUPPLIER_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"),
+      add    => t8("Add Supplier Delivery Order"),
+      edit   => t8("Edit Supplier Delivery Order"),
     },
     show_menu => {
       save_and_quotation      => 0,
@@ -153,22 +83,24 @@ my %type_data = (
       save_and_purchase_order => 0,
       save_and_delivery_order => 0,
       save_and_ap_transaction => 0,
+      save_and_invoice        => 0,
       delete                  => sub { $::instance_conf->get_sales_delivery_order_show_delete },
     },
     properties => {
-      customervendor => "customer",
-      is_customer    => 1,
+      customervendor => "vendor",
+      is_customer    => 0,
       nr_key         => "donumber",
+      transfer       => 'out',
     },
-    part_classification_query => [ "used_for_sale" => 1 ],
-    right => "sales_delivery_order_edit",
+    part_classification_query => [ "used_for_purchase" => 1 ],
+    right => "purchase_delivery_order_edit",
   },
-  PURCHASE_DELIVERY_ORDER_TYPE() => {
+  RMA_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"),
+      add    => t8("Add RMA Delivery Order"),
+      edit   => t8("Edit RMA Delivery Order"),
     },
     show_menu => {
       save_and_quotation      => 0,
@@ -177,17 +109,18 @@ my %type_data = (
       save_and_purchase_order => 0,
       save_and_delivery_order => 0,
       save_and_ap_transaction => 0,
+      save_and_invoice        => 0,
       delete                  => sub { $::instance_conf->get_sales_delivery_order_show_delete },
     },
     properties => {
-      customervendor => "vendor",
+      customervendor => "customer",
       is_customer    => 0,
       nr_key         => "donumber",
+      transfer       => 'in',
     },
-    part_classification_query => [ "used_for_purchase" => 1 ],
-    right => "purchase_delivery_order_edit",
+    part_classification_query => [ "used_for_sale" => 1 ],
+    right => "sales_delivery_order_edit",
   },
-
 );
 
 sub new {
@@ -201,12 +134,10 @@ sub new {
 
 sub valid_types {
   [
-    SALES_ORDER_TYPE,
-    PURCHASE_ORDER_TYPE,
-    SALES_QUOTATION_TYPE,
-    REQUEST_QUOTATION_TYPE,
     SALES_DELIVERY_ORDER_TYPE,
     PURCHASE_DELIVERY_ORDER_TYPE,
+    SUPPLIER_DELIVERY_ORDER_TYPE,
+    RMA_DELIVERY_ORDER_TYPE,
   ];
 }
 
@@ -286,13 +217,8 @@ sub part_classification_query {
 sub set_reqdate_by_type {
   my ($self) = @_;
 
-  my $extra_days = $self->type eq SALES_QUOTATION_TYPE ? $::instance_conf->get_reqdate_interval       :
-                   $self->type eq SALES_ORDER_TYPE     ? $::instance_conf->get_delivery_date_interval : 1;
-
-  if (   ($self->type eq SALES_ORDER_TYPE     &&  $::instance_conf->get_deliverydate_on)
-      || ($self->type eq SALES_QUOTATION_TYPE &&  $::instance_conf->get_reqdate_on)
-      && (!$self->order->reqdate)) {
-    $self->c->order->reqdate(DateTime->today_local->next_workday(extra_days => $extra_days));
+  if (!$self->c->order->reqdate) {
+    $self->c->order->reqdate(DateTime->today_local->next_workday(extra_days => 1));
   }
 }
 
@@ -300,15 +226,7 @@ sub get_reqdate_by_type {
   my ($self, $reqdate, $saved_reqdate) = @_;
 
   if ($reqdate == $saved_reqdate) {
-    my $extra_days = $self->type eq SALES_QUOTATION_TYPE ? $::instance_conf->get_reqdate_interval       :
-                     $self->type eq SALES_ORDER_TYPE     ? $::instance_conf->get_delivery_date_interval : 1;
-
-    if (   ($self->type eq SALES_ORDER_TYPE     &&  !$::instance_conf->get_deliverydate_on)
-        || ($self->type eq SALES_QUOTATION_TYPE &&  !$::instance_conf->get_reqdate_on)) {
-      return '';
-    } else {
-      return DateTime->today_local->next_workday(extra_days => $extra_days);
-    }
+    return DateTime->today_local->next_workday(extra_days => 1);
   } else {
     return $reqdate;
   }
index 976b7d1..12dde98 100755 (executable)
@@ -190,6 +190,7 @@ $self->{texts} = {
   'Add Purchase Order'          => 'Lieferantenauftrag erfassen',
   'Add Quotation'               => 'Angebot erfassen',
   'Add RFQ'                     => 'Preisanfrage erfassen',
+  'Add RMA Delivery Order'      => 'Retouren-Lieferschein erfassen',
   'Add Request for Quotation'   => 'Anfrage erfassen',
   'Add Requirement Spec'        => 'Pflichtenheft erfassen',
   'Add Requirement Spec Template' => 'Pflichtenheftvorlage erfassen',
@@ -198,6 +199,7 @@ $self->{texts} = {
   'Add Sales Order'             => 'Auftrag erfassen',
   'Add Service'                 => 'Dienstleistung erfassen',
   'Add Storno Credit Note'      => 'Gutschrift Storno hinzufügen',
+  'Add Supplier Delivery Order' => 'Beistell-Lieferschein erfassen',
   'Add Transaction'             => 'Dialogbuchen',
   'Add User'                    => 'Neuer Benutzer',
   'Add User Group'              => 'Neue Benutzergruppe',
@@ -1263,6 +1265,7 @@ $self->{texts} = {
   'Edit Purchase Delivery Order' => 'Lieferschein (Einkauf) bearbeiten',
   'Edit Purchase Order'         => 'Lieferantenauftrag bearbeiten',
   'Edit Quotation'              => 'Angebot bearbeiten',
+  'Edit RMA Delivery Order'     => 'Retouren-Lieferschein bearbeiten',
   'Edit Request for Quotation'  => 'Anfrage bearbeiten',
   'Edit SEPA strings'           => 'Begriffe bei SEPA-Überweisungen bearbeiten',
   'Edit Sales Delivery Order'   => 'Lieferschein (Verkauf) bearbeiten',
@@ -1272,6 +1275,7 @@ $self->{texts} = {
   'Edit Storno Credit Note'     => 'Storno Gutschrift bearbeiten',
   'Edit Storno Invoice'         => 'Stornorechnung bearbeiten',
   'Edit Storno Invoice for Advance Payment' => 'Storno-Anzahlungsrechnung bearbeiten',
+  'Edit Supplier Delivery Order' => 'Beistell-Lieferschein bearbeiten',
   'Edit User'                   => 'Benutzerdaten bearbeiten',
   'Edit User Group'             => 'Benutzergruppe bearbeiten',
   'Edit Vendor'                 => 'Lieferant editieren',