From: Bernd Bleßmann Date: Fri, 7 Jun 2013 11:21:52 +0000 (+0200) Subject: neue Methode items_sorted für Order, DeliveryOrder, Invoice, PurchaseInvoice X-Git-Tag: release-3.1.0beta1~353 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=56b91fb4030432fde4159c11a0ca97a7571535f3;p=kivitendo-erp.git neue Methode items_sorted für Order, DeliveryOrder, Invoice, PurchaseInvoice --- diff --git a/SL/DB/DeliveryOrder.pm b/SL/DB/DeliveryOrder.pm index 8e235fc35..c00bcaf61 100644 --- a/SL/DB/DeliveryOrder.pm +++ b/SL/DB/DeliveryOrder.pm @@ -25,6 +25,13 @@ __PACKAGE__->meta->initialize; sub items { goto &orderitems; } +sub items_sorted { + my ($self) = @_; + + my @sorted = sort {$a->id <=> $b->id } @{ $self->items }; + return wantarray ? @sorted : \@sorted; +} + sub sales_order { my $self = shift; my %params = @_; diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index d93de711a..18aa8dbdb 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -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; diff --git a/SL/DB/Order.pm b/SL/DB/Order.pm index 63d23f79f..f4ca003a2 100644 --- a/SL/DB/Order.pm +++ b/SL/DB/Order.pm @@ -39,6 +39,13 @@ __PACKAGE__->meta->initialize; 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; diff --git a/SL/DB/PurchaseInvoice.pm b/SL/DB/PurchaseInvoice.pm index f74ee19e1..01885e7ea 100644 --- a/SL/DB/PurchaseInvoice.pm +++ b/SL/DB/PurchaseInvoice.pm @@ -29,6 +29,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;