From 30683648cea6389ea0938654004b1c5153dd91ef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 10 Sep 2021 13:58:21 +0200 Subject: [PATCH] =?utf8?q?CsvImport=20Lieferscheine:=20ShippedQty-Helper?= =?utf8?q?=20f=C3=BCr=20Pr=C3=BCfung,=20ob=20komplett=20geliefert?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/CsvImport/DeliveryOrder.pm | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/SL/Controller/CsvImport/DeliveryOrder.pm b/SL/Controller/CsvImport/DeliveryOrder.pm index 62ecb11fe..b66278721 100644 --- a/SL/Controller/CsvImport/DeliveryOrder.pm +++ b/SL/Controller/CsvImport/DeliveryOrder.pm @@ -21,6 +21,7 @@ use SL::DB::Unit; use SL::DB::Inventory; use SL::DB::TransferType; use SL::DBUtils; +use SL::Helper::ShippedQty; use SL::PriceSource; use SL::TransNumber; use SL::Util qw(trim); @@ -1112,18 +1113,8 @@ sub save_additions { # delivery order for all positions created? if (scalar(@$orders)) { - foreach my $order (@{ $orders }) { - my $all_deliverd; - foreach my $orderitem (@{ $order->items }) { - my $delivered_qty = 0; - foreach my $do_item (@{$orderitem->linked_records(to => 'DeliveryOrderItem')}) { - $delivered_qty += $do_item->unit_obj->convert_to($do_item->qty, $orderitem->unit_obj); - } - $all_deliverd = $orderitem->qty <= $delivered_qty; - last if !$all_deliverd; - } - $order->update_attributes(delivered => !!$all_deliverd); - } + SL::Helper::ShippedQty->new->calculate($orders)->write_to_objects; + $_->update_attributes(delivered => $_->delivered) for @{ $orders }; } # inventory (or use WH->transfer?) -- 2.20.1