]> wagnertech.de Git - mfinanz.git/blobdiff - SL/DB/DeliveryOrder.pm
Zeiterfassung: Lieferschein new_from_time_recording: undef-Warnung vermeiden
[mfinanz.git] / SL / DB / DeliveryOrder.pm
index fef0ee5a3bea53d2840fdfc725ee6d234b6500de..1e0cb49b52d978914a745791ad7d12cd4508534e 100644 (file)
@@ -19,8 +19,9 @@ use SL::DB::Unit;
 
 use SL::Helper::Number qw(_format_total _round_total);
 
-use List::Util qw(first notall);
+use List::Util qw(first);
 use List::MoreUtils qw(any);
+use Math::Round qw(nhimult);
 
 __PACKAGE__->meta->add_relationship(orderitems => { type         => 'one to many',
                                                     class        => 'SL::DB::DeliveryOrderItem',
@@ -226,9 +227,12 @@ sub new_from_time_recordings {
     }
 
     my $date = $source->start_time->to_kivitendo;
-    $entries->{$part_id}->{$date}->{duration} += _round_total($source->duration_in_hours);
+    $entries->{$part_id}->{$date}->{duration} += $source->{rounding}
+                                               ? nhimult(0.25, ($source->duration_in_hours))
+                                               : _round_total($source->duration_in_hours);
     # add content if not already in description
-    my $new_description = $source->description_as_stripped_html;
+    my $new_description = '' . $source->description_as_stripped_html;
+    $entries->{$part_id}->{$date}->{content} ||= '';
     $entries->{$part_id}->{$date}->{content}  .= '<li>' . $new_description . '</li>'
       unless $entries->{$part_id}->{$date}->{content} =~ m/\Q$new_description/;
 
@@ -399,7 +403,7 @@ order.
 
 =item C<new_from_time_recordings $sources, %params>
 
-Creates a new C<SL::DB::DeliveryOrder> instace from the time recordings
+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