Warnings
[kivitendo-erp.git] / SL / BackgroundJob / CreatePeriodicInvoices.pm
index 1b57cbe..851bf3f 100644 (file)
@@ -61,11 +61,14 @@ 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;
+      }
     }
-    # disable one time configs (periodicity is only one time).
-    my $inactive_ordnumber = $config->disable_one_time_config;
-    push @disabled_orders, $inactive_ordnumber if $inactive_ordnumber;
   }
 
   foreach my $inv ( @invoices_to_print ) { $self->_print_invoice($inv); }
@@ -337,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;
 
@@ -409,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),
       }];