S/DB/Order convert_to_delivery_order delivered in Abhängigkeit von stock_out setzen
authorJan Büren <jan@kivitendo.de>
Wed, 23 Jun 2021 11:13:52 +0000 (13:13 +0200)
committerJan Büren <jan@kivitendo.de>
Wed, 23 Jun 2021 11:13:52 +0000 (13:13 +0200)
Testfall ergänzt

SL/DB/Order.pm
t/helper/shipped_qty.t

index b3741df..fe0b321 100644 (file)
@@ -275,7 +275,7 @@ sub convert_to_delivery_order {
       }
     }
 
-    $self->update_attributes(delivered => 1);
+    $self->update_attributes(delivered => 1) unless $::instance_conf->get_shipped_qty_require_stock_out;
     1;
   })) {
     return undef;
index f9fc4f9..592134b 100644 (file)
@@ -75,6 +75,7 @@ my $purchase_order = create_purchase_order(
 Rose::DB::Object::Helpers::forget_related($purchase_order, 'orderitems');
 $purchase_order->orderitems;
 
+local $::instance_conf->data->{shipped_qty_require_stock_out} = 1;
 SL::Helper::ShippedQty
   ->new(require_stock_out => 1)  # should make no difference while there is no delivery order
   ->calculate($purchase_order)
@@ -88,6 +89,7 @@ my $purchase_orderitem_part1 = SL::DB::Manager::OrderItem->find_by( parts_id =>
 is($purchase_orderitem_part1->shipped_qty, 0, "OrderItem shipped_qty method ok");
 
 is($purchase_order->closed,     0, 'purchase order is open');
+# set delivered only if the do is also stocked in
 ok(!$purchase_order->delivered,    'purchase order is not delivered');
 
 note('converting purchase order to delivery order');