From: Moritz Bunkus Date: Mon, 24 Feb 2014 09:11:29 +0000 (+0100) Subject: SL::DB::{DeliveryOrder,Invoice}->new_from: Option items für Übergabe der zu verwenden... X-Git-Tag: release-3.2.0beta~491^2~5 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=53aad992851d0e653fe5d3f291d72ebe5b5ac1e5;p=kivitendo-erp.git SL::DB::{DeliveryOrder,Invoice}->new_from: Option items für Übergabe der zu verwendenden Positionen Gründe dafür können sein: - eigene Sortierung - gewisse Positionen herauslassen - weitere Positionen hinzufügen --- 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