From: Jan Büren Date: Mon, 14 Jun 2021 10:15:28 +0000 (+0200) Subject: 1. fix für #480, Im Einkauf wird der Status geliefert falsch im Auftrag gesetzt X-Git-Tag: kivitendo-mebil_0.1-0~9^2~177 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=fa04f8138cc6447;p=kivitendo-erp.git 1. fix für #480, Im Einkauf wird der Status geliefert falsch im Auftrag gesetzt --- 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";