From 8ebd75685952192deb585e5f5e1cb3c0d65df76e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Tue, 28 Mar 2017 13:26:16 +0200 Subject: [PATCH] =?utf8?q?CsvImport:=20Mehrdeutigkeit=20nur=20pr=C3=BCfen,?= =?utf8?q?=20wenn=20entsprechende=20Daten=20angegeben=20sind.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Fehler kam im commit "CsvImport: bei nicht eindeutigen Kunden/Lieferanten Fehler melden." rein. --- SL/Controller/CsvImport/Base.pm | 67 +++++++++++++++++++-------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/SL/Controller/CsvImport/Base.pm b/SL/Controller/CsvImport/Base.pm index 2eff5b276..1e92cb14d 100644 --- a/SL/Controller/CsvImport/Base.pm +++ b/SL/Controller/CsvImport/Base.pm @@ -221,47 +221,58 @@ sub check_vc { my $is_ambiguous; if (!$entry->{object}->$id_column) { - my $vc = $entry->{raw_data}->{customernumber} && $self->vc_by->{number}->{customers}->{ $entry->{raw_data}->{customernumber} }; - if ($vc && $self->vc_counts_by->{number}->{customers}->{ $entry->{raw_data}->{customernumber} } > 1) { - $vc = undef; - $is_ambiguous = 1; - } - $vc ||= $entry->{raw_data}->{vendornumber} && $self->vc_by->{number}->{vendors}->{ $entry->{raw_data}->{vendornumber} }; - if ($vc && $self->vc_counts_by->{number}->{vendors}->{ $entry->{raw_data}->{vendornumber} } > 1) { - $vc = undef; - $is_ambiguous = 1; + my $vc; + if ($entry->{raw_data}->{customernumber}) { + $vc = $self->vc_by->{number}->{customers}->{ $entry->{raw_data}->{customernumber} }; + if ($vc && $self->vc_counts_by->{number}->{customers}->{ $entry->{raw_data}->{customernumber} } > 1) { + $vc = undef; + $is_ambiguous = 1; + } + } elsif ($entry->{raw_data}->{vendornumber}) { + $vc = $self->vc_by->{number}->{vendors}->{ $entry->{raw_data}->{vendornumber} }; + if ($vc && $self->vc_counts_by->{number}->{vendors}->{ $entry->{raw_data}->{vendornumber} } > 1) { + $vc = undef; + $is_ambiguous = 1; + } } $entry->{object}->$id_column($vc->id) if $vc; } if (!$entry->{object}->$id_column) { - my $vc = $entry->{raw_data}->{customer} && $self->vc_by->{name}->{customers}->{ $entry->{raw_data}->{customer} }; - if ($vc && $self->vc_counts_by->{name}->{customers}->{ $entry->{raw_data}->{customer} } > 1) { - $vc = undef; - $is_ambiguous = 1; - } - $vc ||= $entry->{raw_data}->{vendor} && $self->vc_by->{name}->{vendors}->{ $entry->{raw_data}->{vendor} }; - if ($vc && $self->vc_counts_by->{name}->{vendors}->{ $entry->{raw_data}->{vendor} } > 1) { - $vc = undef; - $is_ambiguous = 1; + my $vc; + if ($entry->{raw_data}->{customer}) { + $vc = $self->vc_by->{name}->{customers}->{ $entry->{raw_data}->{customer} }; + if ($vc && $self->vc_counts_by->{name}->{customers}->{ $entry->{raw_data}->{customer} } > 1) { + $vc = undef; + $is_ambiguous = 1; + } + } elsif ($entry->{raw_data}->{vendor}) { + $vc = $self->vc_by->{name}->{vendors}->{ $entry->{raw_data}->{vendor} }; + if ($vc && $self->vc_counts_by->{name}->{vendors}->{ $entry->{raw_data}->{vendor} } > 1) { + $vc = undef; + $is_ambiguous = 1; + } } $entry->{object}->$id_column($vc->id) if $vc; } if (!$entry->{object}->$id_column) { - my $vc = $entry->{raw_data}->{customer_gln} && $self->vc_by->{gln}->{customers}->{ $entry->{raw_data}->{customer_gln} }; - if ($vc && $self->vc_counts_by->{gln}->{customers}->{ $entry->{raw_data}->{customer_gln} } > 1) { - $vc = undef; - $is_ambiguous = 1; - } - $vc ||= $entry->{raw_data}->{vendor_gln} && $self->vc_by->{gln}->{vendors}->{ $entry->{raw_data}->{vendor_gln} }; - if ($vc && $self->vc_counts_by->{gln}->{vendors}->{ $entry->{raw_data}->{vendor_gln} } > 1) { - $vc = undef; - $is_ambiguous = 1; + my $vc; + if ($entry->{raw_data}->{customer_gln}) { + $vc = $self->vc_by->{gln}->{customers}->{ $entry->{raw_data}->{customer_gln} }; + if ($vc && $self->vc_counts_by->{gln}->{customers}->{ $entry->{raw_data}->{customer_gln} } > 1) { + $vc = undef; + $is_ambiguous = 1; + } + } elsif ($entry->{raw_data}->{vendor_gln}) { + $vc = $self->vc_by->{gln}->{vendors}->{ $entry->{raw_data}->{vendor_gln} }; + if ($vc && $self->vc_counts_by->{gln}->{vendors}->{ $entry->{raw_data}->{vendor_gln} } > 1) { + $vc = undef; + $is_ambiguous = 1; + } } - $entry->{object}->$id_column($vc->id) if $vc; } -- 2.20.1