]> wagnertech.de Git - mfinanz.git/blobdiff - SL/Controller/CsvImport/DeliveryOrder.pm
kivitendo 3.9.2-0.2
[mfinanz.git] / SL / Controller / CsvImport / DeliveryOrder.pm
index 2e5a9e9ab05558bbc1605e6b80610b915493a267..2093249976ff466d2bb4ff87cb1b224ad561ace7 100644 (file)
@@ -16,7 +16,6 @@ use SL::DB::Part;
 use SL::DB::PaymentTerm;
 use SL::DB::Contact;
 use SL::DB::PriceFactor;
-use SL::DB::Pricegroup;
 use SL::DB::Shipto;
 use SL::DB::Unit;
 use SL::DB::Inventory;
@@ -34,7 +33,7 @@ use Rose::Object::MakeMethods::Generic
 (
  'scalar --get_set_init' => [ qw(settings languages_by all_parts parts_by part_counts_by
                                  contacts_by ct_shiptos_by
-                                 price_factors_by pricegroups_by units_by
+                                 price_factors_by units_by
                                  warehouses_by bins_by transfer_types_by) ],
 );
 
@@ -219,7 +218,7 @@ sub setup_displayable_columns {
                                  { name => 'language',                description => $::locale->text('Language (name)')                       },
                                  { name => 'language_id',             description => $::locale->text('Language (database ID)')                },
                                  { name => 'notes',                   description => $::locale->text('Notes')                                 },
-                                 { name => 'order_type',              description => $::locale->text('Delivery Order Type')                   },
+                                 { name => 'record_type',             description => $::locale->text('Delivery Order Type')                   },
                                  { name => 'ordnumber',               description => $::locale->text('Order Number')                          },
                                  { name => 'payment',                 description => $::locale->text('Payment terms (name)')                  },
                                  { name => 'payment_id',              description => $::locale->text('Payment terms (database ID)')           },
@@ -347,13 +346,6 @@ sub init_price_factors_by {
   return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_price_factors } } ) } qw(id description) };
 }
 
-sub init_pricegroups_by {
-  my ($self) = @_;
-
-  my $all_pricegroups = SL::DB::Manager::Pricegroup->get_all;
-  return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_pricegroups } } ) } qw(id pricegroup) };
-}
-
 sub init_units_by {
   my ($self) = @_;
 
@@ -672,7 +664,7 @@ sub handle_stock {
       parts_id      => $item_obj->parts_id,
       warehouse_id  => $object->warehouse_id,
       bin_id        => $object->bin_id,
-      trans_type_id => $trans_type_id,
+      PURCHASE_DELIVERY_ORDER_TYPE() => $trans_type_id,
       qty           => $qty,
       chargenumber  => $object->chargenumber,
       employee_id   => $order_obj->employee_id,
@@ -689,11 +681,11 @@ sub handle_stock {
 sub handle_type {
   my ($self, $entry) = @_;
 
-  if (!exists $entry->{raw_data}->{order_type}) {
+  if (!exists $entry->{raw_data}->{record_type}) {
     # if no type is present - set to sales delivery order or purchase delivery
     # order depending on is_sales or customer/vendor
 
-    $entry->{object}->order_type(
+    $entry->{object}->record_type(
       $entry->{object}->customer_id  ? SALES_DELIVERY_ORDER_TYPE :
       $entry->{object}->vendor_id    ? PURCHASE_DELIVERY_ORDER_TYPE :
       $entry->{raw_data}->{is_sales} ? SALES_DELIVERY_ORDER_TYPE :
@@ -1047,31 +1039,6 @@ sub check_price_factor {
   return 1;
 }
 
-sub check_pricegroup {
-  my ($self, $entry) = @_;
-
-  my $object = $entry->{object};
-
-  # Check whether or not pricegroup ID is valid.
-  if ($object->pricegroup_id && !$self->pricegroups_by->{id}->{ $object->pricegroup_id }) {
-    push @{ $entry->{errors} }, $::locale->text('Error: Invalid price group');
-    return 0;
-  }
-
-  # Map pricegroup to ID if given.
-  if (!$object->pricegroup_id && $entry->{raw_data}->{pricegroup}) {
-    my $pricegroup = $self->pricegroups_by->{pricegroup}->{ $entry->{raw_data}->{pricegroup} };
-    if (!$pricegroup) {
-      push @{ $entry->{errors} }, $::locale->text('Error: Invalid price group');
-      return 0;
-    }
-
-    $object->pricegroup_id($pricegroup->id);
-  }
-
-  return 1;
-}
-
 sub check_warehouse {
   my ($self, $entry) = @_;