From f87214b22e4bf7a54f314d8248468529ad7019e0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Thu, 23 Mar 2017 16:43:03 +0100 Subject: [PATCH] =?utf8?q?CsvImport=20Auftr=C3=A4ge:=20Artikel=20auch=20na?= =?utf8?q?ch=20EAN=20suchen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/CsvImport/Order.pm | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/SL/Controller/CsvImport/Order.pm b/SL/Controller/CsvImport/Order.pm index 0d5494413..4393fd424 100644 --- a/SL/Controller/CsvImport/Order.pm +++ b/SL/Controller/CsvImport/Order.pm @@ -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 { -- 2.20.1