X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FBackgroundJob%2FCreatePeriodicInvoices.pm;h=851bf3ff26b7a0ca70b96c4deb5917e551830b65;hb=0084e295cf384c8c13001923f20de278d74435ea;hp=490f21ea37cd0a823c551ebcadc141e8d23c4e39;hpb=2a1e7ba222323c441f55da0c192413a471c0b4cb;p=kivitendo-erp.git diff --git a/SL/BackgroundJob/CreatePeriodicInvoices.pm b/SL/BackgroundJob/CreatePeriodicInvoices.pm index 490f21ea3..851bf3ff2 100644 --- a/SL/BackgroundJob/CreatePeriodicInvoices.pm +++ b/SL/BackgroundJob/CreatePeriodicInvoices.pm @@ -36,7 +36,7 @@ sub run { _log_msg("Periodic invoice configuration ID " . $config->id . " extended through " . $new_end_date->strftime('%d.%m.%Y') . "\n") if $new_end_date; } - my (@new_invoices, @invoices_to_print, @invoices_to_email); + my (@new_invoices, @invoices_to_print, @invoices_to_email, @disabled_orders); _log_msg("Number of configs: " . scalar(@{ $configs})); @@ -61,7 +61,13 @@ sub run { push @invoices_to_print, $data if $config->print; push @invoices_to_email, $data if $config->send_email; - # last; + my $inactive_ordnumber = $config->disable_one_time_config; + if ($inactive_ordnumber) { + # disable one time configs and skip eventual invoices + _log_msg("Order " . $inactive_ordnumber . " deavtivated \n"); + push @disabled_orders, $inactive_ordnumber; + last; + } } } @@ -72,6 +78,7 @@ sub run { [ map { $_->{invoice} } @new_invoices ], [ map { $_->{invoice} } @invoices_to_print ], [ map { $_->{invoice} } @invoices_to_email ], + \@disabled_orders , ); if (@{ $self->{job_errors} }) { @@ -275,8 +282,8 @@ sub _calculate_dates { } sub _send_summary_email { - my ($self, $posted_invoices, $printed_invoices, $emailed_invoices) = @_; - + my ($self, $posted_invoices, $printed_invoices, $emailed_invoices, + $disabled_orders) = @_; my %config = %::lx_office_conf; return if !$config{periodic_invoices} || !$config{periodic_invoices}->{send_email_to} || !scalar @{ $posted_invoices }; @@ -298,7 +305,8 @@ sub _send_summary_email { my $filename = $email_template || ( (SL::DB::Default->get->templates || "templates/webpages") . "/oe/periodic_invoices_email.txt" ); my %params = ( POSTED_INVOICES => $posted_invoices, PRINTED_INVOICES => $printed_invoices, - EMAILED_INVOICES => $emailed_invoices ); + EMAILED_INVOICES => $emailed_invoices, + DISABLED_ORDERS => $disabled_orders ); my $output; $template->process($filename, \%params, \$output); @@ -332,13 +340,8 @@ sub _print_invoice { $form->{OUT} = $config->printer->printer_command; $form->{OUT_MODE} = '|-'; - $form->{TEMPLATE_DRIVER_OPTIONS} = { - variable_content_types => { - longdescription => 'html', - partnotes => 'html', - notes => 'html', - }, - }; + $form->{TEMPLATE_DRIVER_OPTIONS} = { }; + $form->{TEMPLATE_DRIVER_OPTIONS}->{variable_content_types} = $form->get_variable_content_types(); $form->prepare_for_printing; @@ -404,7 +407,7 @@ sub _email_invoice { $mail->{subject} = $data->{config}->email_subject; $mail->{message} = $data->{config}->email_body; $mail->{attachments} = [{ - filename => $pdf_file_name, + path => $pdf_file_name, name => sprintf('%s %s.pdf', $::locale->text('Invoice'), $data->{invoice}->invnumber), }];