Helper::Inventory: warnings
authorSven Schöling <sven.schoeling@opendynamic.de>
Tue, 28 Jan 2020 14:23:40 +0000 (15:23 +0100)
committerSven Schöling <s.schoeling@googlemail.com>
Fri, 27 Nov 2020 15:27:45 +0000 (16:27 +0100)
SL/Helper/Inventory.pm

index 17a7d98..9d4ee96 100644 (file)
@@ -187,9 +187,9 @@ sub allocate {
   # sort results so that reserve_for is first, then chargenumbers, then wanted bins, then wanted warehouses
   my @sorted_results = sort {
        (!!$b->{reserve_for_id})    <=> (!!$a->{reserve_for_id})                   # sort by existing reserve_for_id first.
-    || $chargenumbers{$b->{chargenumber}}  <=> $chargenumbers{$a->{chargenumber}} # then prefer wanted chargenumbers
-    || $bin_whitelist{$b->{bin_id}}        <=> $bin_whitelist{$a->{bin_id}}       # then prefer wanted bins
-    || $wh_whitelist{$b->{warehouse_id}}   <=> $wh_whitelist{$a->{warehouse_id}}  # then prefer wanted bins
+    || exists $chargenumbers{$b->{chargenumber}}  <=> exists $chargenumbers{$a->{chargenumber}} # then prefer wanted chargenumbers
+    || exists $bin_whitelist{$b->{bin_id}}        <=> exists $bin_whitelist{$a->{bin_id}}       # then prefer wanted bins
+    || exists $wh_whitelist{$b->{warehouse_id}}   <=> exists $wh_whitelist{$a->{warehouse_id}}  # then prefer wanted bins
   } @filtered_results;
   my @allocations;
   my $rest_qty = $qty;