neue Methode items_sorted für Order, DeliveryOrder, Invoice, PurchaseInvoice
[kivitendo-erp.git] / SL / DB / Order.pm
index b3edda5..f4ca003 100644 (file)
@@ -37,8 +37,14 @@ __PACKAGE__->meta->initialize;
 
 # methods
 
-sub items         { goto &orderitems; }
-sub payment_terms { goto &payment;    }
+sub items { goto &orderitems; }
+
+sub items_sorted {
+  my ($self) = @_;
+
+  my @sorted =  sort {$a->id <=> $b->id } @{ $self->items };
+  return wantarray ? @sorted : \@sorted;
+}
 
 sub type {
   my $self = shift;
@@ -69,7 +75,7 @@ sub displayable_type {
 
 sub is_sales {
   croak 'not an accessor' if @_ > 1;
-  return shift->customer_id;
+  return !!shift->customer_id;
 }
 
 sub invoices {
@@ -133,6 +139,10 @@ sub number {
   return $self->${ \ $number_method{$self->type} }(@_);
 }
 
+sub date {
+  goto &transdate;
+}
+
 1;
 
 __END__