From 53aad992851d0e653fe5d3f291d72ebe5b5ac1e5 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 24 Feb 2014 10:11:29 +0100 Subject: [PATCH] =?utf8?q?SL::DB::{DeliveryOrder,Invoice}->new=5Ffrom:=20O?= =?utf8?q?ption=20items=20f=C3=BCr=20=C3=9Cbergabe=20der=20zu=20verwendend?= =?utf8?q?en=20Positionen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Gründe dafür können sein: - eigene Sortierung - gewisse Positionen herauslassen - weitere Positionen hinzufügen --- SL/DB/DeliveryOrder.pm | 10 +++++++++- SL/DB/Invoice.pm | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/SL/DB/DeliveryOrder.pm b/SL/DB/DeliveryOrder.pm index 02d003aab..d8de6beb5 100644 --- a/SL/DB/DeliveryOrder.pm +++ b/SL/DB/DeliveryOrder.pm @@ -133,6 +133,7 @@ sub new_from { } my $delivery_order = $class->new(%args, %{ $params{attributes} || {} }); + my $items = delete($params{items}) || $source->items_sorted; my @items = map { my $source_item = $_; @@ -144,7 +145,7 @@ sub new_from { )), custom_variables => \@custom_variables); - } @{ $source->items_sorted }; + } @{ $items }; @items = grep { $_->qty * 1 } @items if $params{skip_items_zero_qty}; @@ -215,6 +216,13 @@ C<%params> can include the following options: =over 2 +=item C + +An optional array reference of RDBO instances for the items to use. If +missing then the method C will be called on +C<$source>. This option can be used to override the sorting, to +exclude certain positions or to add additional ones. + =item C If trueish then items with a quantity of 0 are skipped. diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 46ecd9b09..987ab72a7 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -161,6 +161,7 @@ sub new_from { } my $invoice = $class->new(%args, %{ $params{attributes} || {} }); + my $items = delete($params{items}) || $source->items_sorted; my @items = map { my $source_item = $_; @@ -174,7 +175,7 @@ sub new_from { custom_variables => \@custom_variables, ); - } @{ $source->items_sorted }; + } @{ $items }; $invoice->invoiceitems(\@items); @@ -327,6 +328,13 @@ C<%params> can include the following options: =over 2 +=item C + +An optional array reference of RDBO instances for the items to use. If +missing then the method C will be called on +C<$source>. This option can be used to override the sorting, to +exclude certain positions or to add additional ones. + =item C An optional hash reference. If it exists then it is passed to C -- 2.20.1