SL::DB::CustomVariable->value für Typ Nummer auch wirklich Nummer zurückgeben
[kivitendo-erp.git] / SL / DB / DeliveryOrder.pm
index 436c9b1..94725a8 100644 (file)
@@ -50,6 +50,7 @@ sub _before_save_set_donumber {
 
 sub items { goto &orderitems; }
 sub add_items { goto &add_orderitems; }
+sub payment_terms { goto &payment; }
 
 sub sales_order {
   my $self   = shift;
@@ -104,15 +105,12 @@ sub new_from {
     $item_parent_column    = 'order';
   }
 
-  my $terms = $source->can('payment_id') && $source->payment_id ? $source->payment_terms->terms_netto : 0;
-
   my %args = ( map({ ( $_ => $source->$_ ) } qw(cp_id currency_id customer_id cusordnumber department_id employee_id globalproject_id intnotes language_id notes
-                                                ordnumber reqdate salesman_id shippingpoint shipvia taxincluded taxzone_id transaction_description vendor_id
+                                                ordnumber payment_id reqdate salesman_id shippingpoint shipvia taxincluded taxzone_id transaction_description vendor_id
                                              )),
                closed    => 0,
                is_sales  => !!$source->customer_id,
                delivered => 0,
-               terms     => $terms,
                transdate => DateTime->today_local,
             );
 
@@ -162,6 +160,7 @@ sub new_from {
 
   } @{ $items };
 
+  @items = grep { $params{item_filter}->($_) } @items if $params{item_filter};
   @items = grep { $_->qty * 1 } @items if $params{skip_items_zero_qty};
   @items = grep { $_->qty >=0 } @items if $params{skip_items_negative_qty};
 
@@ -247,6 +246,12 @@ a quantity of 0 are not affected by this option.
 
 If trueish then items with a quantity of 0 are skipped.
 
+=item C<item_filter>
+
+An optional code reference that is called for each item with the item
+as its sole parameter. Items for which the code reference returns a
+falsish value will be skipped.
+
 =item C<attributes>
 
 An optional hash reference. If it exists then it is passed to C<new>