X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FHelper%2FShippedQty.pm;h=af2a4f47cbad5115418e3caa16a51233e329c869;hb=c4104eb32fe068961c83d5905816686637d4abc6;hp=a50cebcdc90828d2b27769eaa65fc08dbbe496ed;hpb=0d6c87b05048688066bab51642390947b1cad2d4;p=kivitendo-erp.git diff --git a/SL/Helper/ShippedQty.pm b/SL/Helper/ShippedQty.pm index a50cebcdc..af2a4f47c 100644 --- a/SL/Helper/ShippedQty.pm +++ b/SL/Helper/ShippedQty.pm @@ -104,8 +104,6 @@ sub calculate { die 'Need exactly one argument, either id, object or arrayref of ids or objects.' unless 2 == @_; - return $self if !$data || ('ARRAY' eq ref $data && !@$data); - $self->normalize_input($data); return $self unless @{ $self->oe_ids }; @@ -235,6 +233,8 @@ sub write_to { sub write_to_objects { my ($self) = @_; + return unless @{ $self->oe_ids }; + die 'Can only use write_to_objects, when calculate was called with objects. Use write_to instead.' unless $self->objects_or_ids; $self->write_to($self->objects); @@ -258,6 +258,7 @@ sub normalize_input { $self->objects($data); } else { die 'object or reference in data while expecting ids' if any { ref($_) } @$data; + die 'ids need to be numbers' if any { ! ($_ * 1) } @$data; $self->oe_ids($data); } @@ -485,6 +486,13 @@ was found it will be set to zero. C is guaranteed only to be the correct boolean value, but not any specific value. +Note: C will avoid loading unnecessary objects. This means if it is +called with an Order object that has not loaded its orderitems yet, only +C will be set in the Order object. A subsequent C<< +$order->orderitems->[0]->{delivered} >> will return C, and C<< +$order->orderitems->[0]->shipped_qty >> will invoke another implicit +calculation. + =item C Valid after L. Returns a hasref with shipped qtys by orderitems id. @@ -522,6 +530,8 @@ false, the match was made in the fill up stage. =back +=back + =head1 REPLACED FUNCTIONALITY =head2 delivered mode