From: Sven Schöling Date: Wed, 23 Aug 2017 11:18:29 +0000 (+0200) Subject: shipped_qty: Testfall uas realem Bug X-Git-Tag: release-3.5.4~869 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=72c4037da884663b53e86c3757e020a6e79ef6b9;p=kivitendo-erp.git shipped_qty: Testfall uas realem Bug --- diff --git a/t/helper/shipped_qty.t b/t/helper/shipped_qty.t index 5d6c70938..dc2f9dd3b 100644 --- a/t/helper/shipped_qty.t +++ b/t/helper/shipped_qty.t @@ -206,6 +206,57 @@ is ($number_of_linked_items , 6, "6 record_links for items, 3 from sales order, clear_up(); +{ +# legacy unlinked scenario: +# +# order with two positions of the same part, qtys: 5, 3. +# 3 linked delivery orders, with positions: +# 1: 3 unlinked +# 2: 1 linked to 1, 3 linked to 2 +# 3: 1 linked to 1 +# +# should be resolved under fill_up as 5/3, but gets resolved as 4/4 + my $part = new_part()->save; + my $order = create_sales_order( + orderitems => [ + create_order_item(part => $part, qty => 5), + create_order_item(part => $part, qty => 3), + ], + )->save; + my $do1 = create_sales_delivery_order( + orderitems => [ + create_delivery_order_item(part => $part, qty => 3), + ], + ); + my $do2 = create_sales_delivery_order( + orderitems => [ + create_delivery_order_item(part => $part, qty => 1), + create_delivery_order_item(part => $part, qty => 3), + ], + ); + my $do3 = create_sales_delivery_order( + orderitems => [ + create_delivery_order_item(part => $part, qty => 1), + ], + ); + $order->link_to_record($do1); + $order->link_to_record($do2); + $order->items_sorted->[0]->link_to_record($do2->items_sorted->[0]); + $order->items_sorted->[1]->link_to_record($do2->items_sorted->[1]); + $order->link_to_record($do3); + $order->items_sorted->[0]->link_to_record($do3->items->[0]); + + SL::Helper::ShippedQty + ->new(fill_up => 1, require_stock_out => 0) + ->calculate($order) + ->write_to_objects; + + is $order->items_sorted->[0]->{shipped_qty}, 5, 'unlinked legacy position test 1'; + is $order->items_sorted->[1]->{shipped_qty}, 3, 'unlinked legacy position test 2'; +} + +clear_up(); + done_testing; sub clear_up {