From: Sven Schöling Date: Wed, 20 Nov 2019 14:48:06 +0000 (+0100) Subject: Inventory: allocate bevorzugt jetzt früherere Lagerbewegung X-Git-Tag: kivitendo-mebil_0.1-0~9^2~604 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=15176cbb3b162a07a055dbe6cfc0f98f9d65d0df;p=kivitendo-erp.git Inventory: allocate bevorzugt jetzt früherere Lagerbewegung --- 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;