]> wagnertech.de Git - mfinanz.git/blobdiff - SL/DB/DeliveryOrder.pm
Files: Druckvariante abspeichern können: sql und rose
[mfinanz.git] / SL / DB / DeliveryOrder.pm
index 8bb89bd8602d4b625282d2867301837f67e18a4c..f4e630148e5eb0fa35cab589842b0d7ca799a7a6 100644 (file)
@@ -127,7 +127,7 @@ sub new_from {
   }
 
   my %args = ( map({ ( $_ => $source->$_ ) } qw(cp_id currency_id customer_id cusordnumber delivery_term_id department_id employee_id globalproject_id intnotes language_id notes
   }
 
   my %args = ( map({ ( $_ => $source->$_ ) } qw(cp_id currency_id customer_id cusordnumber delivery_term_id department_id employee_id globalproject_id intnotes language_id notes
-                                                ordnumber payment_id 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 billing_address_id
                                              )),
                closed    => 0,
                is_sales  => !!$source->customer_id,
                                              )),
                closed    => 0,
                is_sales  => !!$source->customer_id,
@@ -191,20 +191,25 @@ sub new_from_time_recordings {
   #  - ordered and summed by date
   #  - each description goes to an ordered list
   #  - (as time recording descriptions are formatted text by now, use stripped text)
   #  - ordered and summed by date
   #  - each description goes to an ordered list
   #  - (as time recording descriptions are formatted text by now, use stripped text)
-  #  - merge same descriptions (todo)
+  #  - merge same descriptions
   #
 
   #
 
-  my $default_part_id = $params{default_part_id}    ? $params{default_part_id}
-                      : $params{default_partnumber} ? SL::DB::Manager::Part->find_by(partnumber => $params{default_partnumber})->id
-                      : undef;
+  my $default_part_id  = $params{default_part_id}     ? $params{default_part_id}
+                       : $params{default_partnumber}  ? SL::DB::Manager::Part->find_by(partnumber => $params{default_partnumber})->id
+                       : undef;
+  my $override_part_id = $params{override_part_id}    ? $params{override_part_id}
+                       : $params{override_partnumber} ? SL::DB::Manager::Part->find_by(partnumber => $params{override_partnumber})->id
+                       : undef;
 
   # check parts and collect entries
   my %part_by_part_id;
   my $entries;
   foreach my $source (@$sources) {
 
   # check parts and collect entries
   my %part_by_part_id;
   my $entries;
   foreach my $source (@$sources) {
-    my $part_id  = $source->part_id ? $source->part_id
-                 : $default_part_id ? $default_part_id
-                 : undef;
+    next if !$source->duration;
+
+    my $part_id   = $override_part_id;
+    $part_id    ||= $source->part_id;
+    $part_id    ||= $default_part_id;
 
     die 'article not found for entry "' . $source->displayable_times . '"' if !$part_id;
 
 
     die 'article not found for entry "' . $source->displayable_times . '"' if !$part_id;
 
@@ -432,7 +437,8 @@ Creates a new C<SL::DB::DeliveryOrder> instance from the time recordings
 given as C<$sources>. All time recording entries must belong to the same
 customer. Time recordings are sorted by article and date. For each article
 a new delivery order item is created. If no article is associated with an
 given as C<$sources>. All time recording entries must belong to the same
 customer. Time recordings are sorted by article and date. For each article
 a new delivery order item is created. If no article is associated with an
-entry, a default article will be used (hard coded).
+entry, a default article will be used. The article given in the time
+recording entry can be overriden.
 Entries of the same date (for each article) are summed together and form a
 list entry in the long description of the item.
 
 Entries of the same date (for each article) are summed together and form a
 list entry in the long description of the item.
 
@@ -449,6 +455,36 @@ C<%params> can include the following options:
 An optional hash reference. If it exists then it is used to set
 attributes of the newly created delivery order object.
 
 An optional hash reference. If it exists then it is used to set
 attributes of the newly created delivery order object.
 
+=item C<default_part_id>
+
+An optional part id which is used as default value if no part is set
+in the time recording entry.
+
+=item C<default_partnumber>
+
+Like C<default_part_id> but given as partnumber, not as id.
+
+=item C<override_part_id>
+
+An optional part id which is used instead of a value set in the time
+recording entry.
+
+=item C<override_partnumber>
+
+Like C<overrride_part_id> but given as partnumber, not as id.
+
+=item C<related_order>
+
+An optional C<SL::DB::Order> object. If it exists then it is used to
+generate the delivery order from that via C<new_from>.
+The generated items are created from a suitable item of the related
+order. If no suitable item is found, an exception is thrown.
+
+=item C<rounding>
+
+An optional boolean value. If truish, then the durations of the time entries
+are rounded up to the full quarters of an hour.
+
 =back
 
 =item C<sales_order>
 =back
 
 =item C<sales_order>