From 96186c41fee2317c968474b0ae3ab3314df09810 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 5 Mar 2021 12:32:36 +0100 Subject: [PATCH] wiederkehrende Rechnungen: auch bei E-Mail erzeugtes Dokument im DMS speichern --- SL/BackgroundJob/CreatePeriodicInvoices.pm | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/SL/BackgroundJob/CreatePeriodicInvoices.pm b/SL/BackgroundJob/CreatePeriodicInvoices.pm index f7b9100ad..9c0e58f68 100644 --- a/SL/BackgroundJob/CreatePeriodicInvoices.pm +++ b/SL/BackgroundJob/CreatePeriodicInvoices.pm @@ -16,6 +16,7 @@ use SL::DB::Order; use SL::DB::Invoice; use SL::DB::PeriodicInvoice; use SL::DB::PeriodicInvoicesConfig; +use SL::File; use SL::Helper::CreatePDF qw(create_pdf find_template); use SL::Mailer; use SL::Util qw(trim); @@ -358,6 +359,29 @@ sub _store_pdf_in_webdav { Common::copy_file_to_webdav_folder($form); } +sub _store_pdf_in_filemanagement { + my ($self, $pdf_file, $invoice) = @_; + + return unless $::instance_conf->get_doc_storage; + + # create a form for generate_attachment_filename + my $form = Form->new(''); + $form->{invnumber} = $invoice->invnumber; + $form->{type} = 'invoice'; + $form->{format} = 'pdf'; + $form->{formname} = 'invoice'; + $form->{language} = '_' . $invoice->language->template_code if $invoice->language; + my $doc_name = $form->generate_attachment_filename(); + + SL::File->save(object_id => $invoice->id, + object_type => 'invoice', + mime_type => 'application/pdf', + source => 'created', + file_type => 'document', + file_name => $doc_name, + file_path => $pdf_file); +} + sub _print_invoice { my ($self, $data) = @_; @@ -435,7 +459,8 @@ sub _email_invoice { eval { $pdf_file_name = $self->create_pdf(%create_params); - $self->_store_pdf_in_webdav($pdf_file_name, $data->{invoice}); + $self->_store_pdf_in_webdav ($pdf_file_name, $data->{invoice}); + $self->_store_pdf_in_filemanagement($pdf_file_name, $data->{invoice}); for (qw(email_subject email_body)) { _replace_vars( -- 2.20.1