]> wagnertech.de Git - mfinanz.git/blobdiff - SL/DB/Invoice.pm
Artikel-Reihenfolge beibehalten beim Erzeugen und autom. Drucken wiederkehrender...
[mfinanz.git] / SL / DB / Invoice.pm
index d93de711aad58a09823c4f1f3d7ad8c447f46703..2382c6e126275d817f0a3e9d384483a1571210be 100644 (file)
@@ -47,6 +47,13 @@ __PACKAGE__->meta->initialize;
 
 sub items { goto &invoiceitems; }
 
+sub items_sorted {
+  my ($self) = @_;
+
+  my @sorted =  sort {$a->id <=> $b->id } @{ $self->items };
+  return wantarray ? @sorted : \@sorted;
+}
+
 sub is_sales {
   # For compatibility with Order, DeliveryOrder
   croak 'not an accessor' if @_ > 1;
@@ -128,7 +135,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);