neue Methode items_sorted für Order, DeliveryOrder, Invoice, PurchaseInvoice
[kivitendo-erp.git] / SL / DB / Invoice.pm
index d93de71..18aa8db 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;