X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/2714604a9184071fcb3986ac19056da50e5c4a4a..fff57e55bed689ab673bf72937bfd71eab26a293:/SL/DB/Invoice.pm diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 8c6965fc4..8a4f4ec8e 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -160,7 +160,8 @@ sub new_from { $args{quodate} = $source->transdate; } - my $invoice = $class->new(%args, %params); + my $invoice = $class->new(%args, %{ $params{attributes} || {} }); + my $items = delete($params{items}) || $source->items_sorted; my @items = map { my $source_item = $_; @@ -174,7 +175,9 @@ sub new_from { custom_variables => \@custom_variables, ); - } @{ $source->items_sorted }; + } @{ $items }; + + @items = grep { $_->qty * 1 } @items if $params{skip_items_zero_qty}; $invoice->invoiceitems(\@items); @@ -313,7 +316,7 @@ SL::DB::Invoice: Rose model for invoices (table "ar") =over 4 -=item C +=item C Creates a new C instance and copies as much information from C<$source> as possible. At the moment only sales @@ -323,6 +326,29 @@ The conversion copies order items into invoice items. Dates are copied as appropriate, e.g. the C field from an order will be copied into the invoice's C field. +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. + +=item C + +An optional hash reference. If it exists then it is passed to C +allowing the caller to set certain attributes for the new delivery +order. + +=back + Amounts, prices and taxes are not calculated. L can be used for this.