From 56b91fb4030432fde4159c11a0ca97a7571535f3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 7 Jun 2013 13:21:52 +0200 Subject: [PATCH] =?utf8?q?neue=20Methode=20items=5Fsorted=20f=C3=BCr=20Ord?= =?utf8?q?er,=20DeliveryOrder,=20Invoice,=20PurchaseInvoice?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/DeliveryOrder.pm | 7 +++++++ SL/DB/Invoice.pm | 7 +++++++ SL/DB/Order.pm | 7 +++++++ SL/DB/PurchaseInvoice.pm | 7 +++++++ 4 files changed, 28 insertions(+) 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; -- 2.20.1