X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/c20a734c09a7561e27c76014258037f8d629cb1a..20004cac8f656f67e86e63fdb85f6dc083cf83d7:/SL/BackgroundJob/CreatePeriodicInvoices.pm diff --git a/SL/BackgroundJob/CreatePeriodicInvoices.pm b/SL/BackgroundJob/CreatePeriodicInvoices.pm index 48f41b48c..521dc1b30 100644 --- a/SL/BackgroundJob/CreatePeriodicInvoices.pm +++ b/SL/BackgroundJob/CreatePeriodicInvoices.pm @@ -358,7 +358,7 @@ sub _print_invoice { $form->parse_template(\%::myconfig); 1; } or do { - push @{ $self->{job_errors} }, $EVAL_ERROR->getMessage; + push @{ $self->{job_errors} }, $EVAL_ERROR->error; }; }); } @@ -376,12 +376,15 @@ sub _email_invoice { grep { $_ } map { trim($_) } (split(m{,}, $data->{config}->email_recipient_address), - $data->{config}->email_recipient_contact ? ($data->{config}->email_recipient_contact->cp_email) : ()); + $data->{config}->email_recipient_contact ? ($data->{config}->email_recipient_contact->cp_email) : (), + $data->{invoice}->{customer}->invoice_mail ? ($data->{invoice}->{customer}->invoice_mail) : () + ); return unless @recipients; + my $language = $data->{invoice}->language ? $data->{invoice}->language->template_code : undef; my %create_params = ( - template => $self->find_template(name => 'invoice'), + template => scalar($self->find_template(name => 'invoice', language => $language)), variables => Form->new(''), return => 'file_name', variable_content_types => { @@ -395,6 +398,7 @@ sub _email_invoice { $create_params{variables}->prepare_for_printing; my $pdf_file_name; + my $label = $language && Locale::is_supported($language) ? Locale->new($language)->text('Invoice') : $::locale->text('Invoice'); eval { $pdf_file_name = $self->create_pdf(%create_params); @@ -421,7 +425,7 @@ sub _email_invoice { $mail->{message} = $data->{config}->email_body; $mail->{attachments} = [{ path => $pdf_file_name, - name => sprintf('%s %s.pdf', $::locale->text('Invoice'), $data->{invoice}->invnumber), + name => sprintf('%s %s.pdf', $label, $data->{invoice}->invnumber), }]; my $error = $mail->send;