From 24e928a5db664197697cdee8a0d65937845bea24 Mon Sep 17 00:00:00 2001 From: "Martin Helmling martin.helmling@octosoft.eu" Date: Wed, 20 Nov 2019 15:46:59 +0100 Subject: [PATCH] =?utf8?q?Inventory-Helper:=20Restmenge=20auch=20runden,?= =?utf8?q?=20St=C3=BCck=20immer=20ganzzahlig?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Helper/Inventory.pm | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/SL/Helper/Inventory.pm b/SL/Helper/Inventory.pm index c26d855c9..bb163ade2 100644 --- a/SL/Helper/Inventory.pm +++ b/SL/Helper/Inventory.pm @@ -7,6 +7,7 @@ use Exporter qw(import); use List::Util qw(min sum); use List::UtilsBy qw(sort_by); use List::MoreUtils qw(any); +use POSIX qw(ceil); use SL::Locale::String qw(t8); use SL::MoreCommon qw(listify); @@ -210,15 +211,15 @@ sub allocate { reserve_for_table => $chunk->{reserve_for_table}, oe_id => undef, ); - $rest_qty -= $qty; + $rest_qty -= _round_qty($qty); } - + $rest_qty = _round_qty($rest_qty); last if $rest_qty == 0; } if ($rest_qty > 0) { die SL::X::Inventory::Allocation->new( error => 'not enough to allocate', - msg => t8("can not allocate #1 units of #2, missing #3 units", $qty, $part->displayable_name, $rest_qty), + msg => t8("can not allocate #1 units of #2, missing #3 units", _qty($qty), $part->displayable_name, _qty($rest_qty)), ); } else { if ($params{constraints}) { @@ -239,8 +240,13 @@ sub allocate_for_assembly { my %parts_to_allocate; for my $assembly ($part->assemblies) { + next if $assembly->part->dispotype eq 'no_stock'; + + my $tmpqty = $assembly->assembly_part->is_recipe ? $assembly->qty * $qty / $assembly->assembly_part->scalebasis + : $assembly->part->unit eq 'Stck' ? ceil($assembly->qty * $qty) + : $assembly->qty * $qty; $parts_to_allocate{ $assembly->part->id } //= 0; - $parts_to_allocate{ $assembly->part->id } += $assembly->qty * $qty; # TODO recipe factor + $parts_to_allocate{ $assembly->part->id } += $tmpqty; } my @allocations; -- 2.20.1