X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/f559550ffb82e23f3712c11be4161d9c53a4b904..e05e75747d8d08af9611712fb61f25b155213c83:/SL/Helper/ShippedQty.pm diff --git a/SL/Helper/ShippedQty.pm b/SL/Helper/ShippedQty.pm index 2054513de..cf1c70bfe 100644 --- a/SL/Helper/ShippedQty.pm +++ b/SL/Helper/ShippedQty.pm @@ -7,7 +7,7 @@ use SL::AM; use Scalar::Util qw(blessed); use SL::DBUtils qw(selectall_hashref_query selectall_as_map); use List::Util qw(min); -use List::MoreUtils qw(any all); +use List::MoreUtils qw(any all uniq); use List::UtilsBy qw(partition_by); use SL::Locale::String qw(t8); @@ -108,6 +108,8 @@ sub calculate { $self->calculate_item_links; $self->calculate_fill_up if $self->fill_up; + + $self; } sub calculate_item_links { @@ -262,8 +264,9 @@ sub init_oe_ids { die 'oe_ids not initialized in id mode' if !$self->objects_or_ids; die 'objects not initialized before accessing ids' if $self->objects_or_ids && !defined $self->objects; + die 'objects need to be Order or OrderItem' if any { ref($_) !~ /^SL::DB::Order(?:Item)?$/ } @{ $self->objects }; - [ map { $_->id } @{ $self->objects } ] + [ uniq map { ref($_) =~ /Item/ ? $_->trans_id : $_->id } @{ $self->objects } ] } sub init_dbh { SL::DB->client->dbh } @@ -308,6 +311,8 @@ SL::Helper::ShippedQty - Algorithmic module for calculating shipped qty $helper->calculate($order_object); $helper->calculate(\@order_objects); + $helper->calculate($orderitem_object); + $helper->calculate(\@orderitem_objects); $helper->calculate($oe_id); $helper->calculate(\@oe_ids);