From fa04f8138cc644757c8b602a8b21bc93bf867b50 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Mon, 14 Jun 2021 12:15:28 +0200 Subject: [PATCH] =?utf8?q?1.=20fix=20f=C3=BCr=20#480,=20Im=20Einkauf=20wir?= =?utf8?q?d=20der=20Status=20geliefert=20falsch=20im=20Auftrag=20gesetzt?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Helper/ShippedQty.pm | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/SL/Helper/ShippedQty.pm b/SL/Helper/ShippedQty.pm index 274959e71..b23e4fa45 100644 --- a/SL/Helper/ShippedQty.pm +++ b/SL/Helper/ShippedQty.pm @@ -220,16 +220,13 @@ sub write_to { $obj->{shipped_qty} = $shipped_qty->{$obj->id} //= 0; $obj->{delivered} = $shipped_qty->{$obj->id} == $obj->qty; } elsif ('SL::DB::Order' eq ref $obj) { - if (defined $obj->{orderitems}) { - $self->write_to($obj->{orderitems}); - if ($self->services_deliverable) { - $obj->{delivered} = all { $_->{delivered} } grep { !$_->{optional} } @{ $obj->{orderitems} }; - } else { - $obj->{delivered} = all { $_->{delivered} } grep { !$_->{optional} && !$_->part->is_service } @{ $obj->{orderitems} }; - } + # load all orderitems unless not already loaded + $obj->orderitems unless (defined $obj->{orderitems}); + $self->write_to($obj->{orderitems}); + if ($self->services_deliverable) { + $obj->{delivered} = all { $_->{delivered} } grep { !$_->{optional} } @{ $obj->{orderitems} }; } else { - # don't force a load on items. just compute by oe_id directly - $obj->{delivered} = $self->delivered->{$obj->id}; + $obj->{delivered} = all { $_->{delivered} } grep { !$_->{optional} && !$_->part->is_service } @{ $obj->{orderitems} }; } } else { die "unknown reference '@{[ ref $obj ]}' for @{[ __PACKAGE__ ]}::write_to"; -- 2.20.1