From 17b4e6866fb03df7e2c2a428bcfca11f2f21ee35 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Fri, 8 Oct 2021 15:11:38 +0200 Subject: [PATCH] Lagerbewegungsimport: Testfehler wg. undef vermeiden --- SL/Controller/CsvImport/Inventory.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/SL/Controller/CsvImport/Inventory.pm b/SL/Controller/CsvImport/Inventory.pm index 7dbe364d8..456963ba5 100644 --- a/SL/Controller/CsvImport/Inventory.pm +++ b/SL/Controller/CsvImport/Inventory.pm @@ -53,7 +53,8 @@ sub init_parts_by { my ($self) = @_; my $all_parts = SL::DB::Manager::Part->get_all; - return { map { my $col = $_; ( $col => { map { ( $_->$col => $_ ) } @{ $all_parts } } ) } qw(id partnumber ean description) }; + return { map { my $col = $_; ( $col => + { map { ( $_->$col => $_ ) } grep { defined $_->$col } @{ $all_parts } } ) } qw(id partnumber ean description) }; } sub init_warehouses_by { @@ -70,7 +71,6 @@ sub init_bins_by { my $bins_by; $bins_by->{_wh_id_and_id_ident()} = { map { ( _wh_id_and_id_maker($_->warehouse_id, $_->id) => $_ ) } @{ $all_bins } }; $bins_by->{_wh_id_and_description_ident()} = { map { ( _wh_id_and_description_maker($_->warehouse_id, $_->description) => $_ ) } @{ $all_bins } }; - return $bins_by; } @@ -127,6 +127,8 @@ sub check_warehouse { my $object = $entry->{object}; + $self->settings->{apply_warehouse} ||= ''; # avoid warnings if undefined + # If warehouse from front-end is enforced for all transfers, use this, if valid. if ($self->settings->{apply_warehouse} eq 'all') { $object->warehouse_id(undef); @@ -185,6 +187,8 @@ sub check_bin { my $object = $entry->{object}; + $self->settings->{apply_bin} ||= ''; # avoid warnings if undefined + # If bin from front-end is enforced for all transfers, use this, if valid. if ($self->settings->{apply_bin} eq 'all') { $object->bin_id(undef); @@ -217,7 +221,7 @@ sub check_bin { } # Map description to ID if given. - if (!$object->bin_id && $entry->{raw_data}->{bin}) { + if (!$object->bin_id && $entry->{raw_data}->{bin} && $object->warehouse_id) { my $bin = $self->bins_by->{_wh_id_and_description_ident()}->{ _wh_id_and_description_maker($object->warehouse_id, $entry->{raw_data}->{bin}) }; if (!$bin) { push @{ $entry->{errors} }, $::locale->text('Error: Invalid bin'); -- 2.20.1