CsvImport Aufträge: Artikel auch nach EAN suchen
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Thu, 23 Mar 2017 15:43:03 +0000 (16:43 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Thu, 23 Mar 2017 22:17:59 +0000 (23:17 +0100)
SL/Controller/CsvImport/Order.pm

index 0d54944..4393fd4 100644 (file)
@@ -162,6 +162,7 @@ sub setup_displayable_columns {
                                  { name => 'cusordnumber',    description => $::locale->text('Customer Order Number')      },
                                  { name => 'description',     description => $::locale->text('Description')                },
                                  { name => 'discount',        description => $::locale->text('Discount')                   },
+                                 { name => 'ean',             description => $::locale->text('EAN')                        },
                                  { name => 'lastcost',        description => $::locale->text('Lastcost')                   },
                                  { name => 'longdescription', description => $::locale->text('Long Description')           },
                                  { name => 'marge_percent',   description => $::locale->text('Margepercent')               },
@@ -464,6 +465,17 @@ sub check_part {
     $object->parts_id($part->id);
   }
 
+  # Map ean to ID if given.
+  if (!$object->parts_id && $entry->{raw_data}->{ean}) {
+    my $part = $self->parts_by->{ean}->{ $entry->{raw_data}->{ean} };
+    if (!$part) {
+      push @{ $entry->{errors} }, $::locale->text('Error: Invalid part');
+      return 0;
+    }
+
+    $object->parts_id($part->id);
+  }
+
   if ($object->parts_id) {
     $entry->{info_data}->{partnumber} = $self->parts_by->{id}->{ $object->parts_id }->partnumber;
   } else {