From 15176cbb3b162a07a055dbe6cfc0f98f9d65d0df Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Wed, 20 Nov 2019 15:48:06 +0100 Subject: [PATCH] =?utf8?q?Inventory:=20allocate=20bevorzugt=20jetzt=20fr?= =?utf8?q?=C3=BCherere=20Lagerbewegung?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Helper/Inventory.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SL/Helper/Inventory.pm b/SL/Helper/Inventory.pm index 9a5910d70..a1a142803 100644 --- a/SL/Helper/Inventory.pm +++ b/SL/Helper/Inventory.pm @@ -24,7 +24,10 @@ sub _get_stock_onhand { my $onhand_mode = !!$params{onhand}; - my @selects = ('SUM(qty) as qty'); + my @selects = ( + 'SUM(qty) AS qty', + 'MIN(EXTRACT(epoch FROM inventory.itime)) AS itime', + ); my @values; my @where; my @groups; @@ -192,6 +195,7 @@ sub allocate { || 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 + || $a->{itime} <=> $b->{itime} # and finally prefer earlier charges } @filtered_results; my @allocations; my $rest_qty = $qty; -- 2.20.1