X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/0af0977dd85c7d47942f7d3aee7e18fd86f09e7a..f4051b8f98064513e21ea95b881f4aa092a99098:/SL/Controller/CsvImport/Inventory.pm diff --git a/SL/Controller/CsvImport/Inventory.pm b/SL/Controller/CsvImport/Inventory.pm index 16debc093..c0dcfb519 100644 --- a/SL/Controller/CsvImport/Inventory.pm +++ b/SL/Controller/CsvImport/Inventory.pm @@ -208,7 +208,7 @@ sub check_bin { push @{ $entry->{errors} }, $::locale->text('Error: Invalid bin'); return 0; } - + # Map description to ID if given. if (!$object->bin_id && $entry->{raw_data}->{bin}) { my $bin = $self->bins_by->{_wh_id_and_description_ident()}->{ _wh_id_and_description_maker($object->warehouse_id, $entry->{raw_data}->{bin}) }; @@ -286,15 +286,17 @@ sub check_qty{ } # Actual quantity is read from stock or is the result of transfers for the - # same part, warehouse and bin done before. - my $key = join '+', $object->parts_id, $object->warehouse_id, $object->bin_id; + # same part, warehouse, bin and chargenumber done before. + my $key = join '+', $object->parts_id, $object->warehouse_id, $object->bin_id, $object->chargenumber; if (!exists $self->{resulting_quantities}->{$key}) { - my $stock = $object->part->get_simple_stock; - my @stocked = grep { $_->{warehouse_id} == $object->warehouse_id && $_->{bin_id} == $object->bin_id } @$stock; - my $stocked_qty = 0; - foreach (@stocked) { - $stocked_qty += $stocked[0]->{sum} * 1; - } + my $query = <get_standard_dbh, $query, + $object->parts_id, $object->warehouse_id, $object->bin_id, $object->chargenumber); $self->{resulting_quantities}->{$key} = $stocked_qty; } my $actual_qty = $self->{resulting_quantities}->{$key};