In Helper kein use SL::DB::Objects
[kivitendo-erp.git] / SL / DB / Invoice.pm
index d93de71..302179c 100644 (file)
@@ -47,6 +47,12 @@ __PACKAGE__->meta->initialize;
 
 sub items { goto &invoiceitems; }
 
+sub items_sorted {
+  my ($self) = @_;
+
+  return [ sort {$a->id <=> $b->id } @{ $self->items } ];
+}
+
 sub is_sales {
   # For compatibility with Order, DeliveryOrder
   croak 'not an accessor' if @_ > 1;
@@ -128,7 +134,7 @@ sub new_from {
                                     base_qty subtotal longdescription lastcost price_factor_id)),
                             deliverydate => $source_item->reqdate,
                             fxsellprice  => $source_item->sellprice,);
-  } @{ $source->items };
+  } @{ $source->items_sorted };
 
   $invoice->invoiceitems(\@items);