- my $vc = $self->vc_by->{name}->{customers}->{ $entry->{raw_data}->{customer} }
- || $self->vc_by->{name}->{vendors}->{ $entry->{raw_data}->{vendor} };
+ 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;
+ 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;
+ }
+ }