+sub _store_pdf_in_webdav {
+ my ($self, $pdf_file_name, $invoice) = @_;
+
+ return unless $::instance_conf->get_webdav_documents;
+
+ my $form = Form->new('');
+
+ $form->{cwd} = SL::System::Process->exe_dir;
+ $form->{tmpdir} = ($pdf_file_name =~ m{(.+)/})[0];
+ $form->{tmpfile} = ($pdf_file_name =~ m{.+/(.+)})[0];
+ $form->{format} = 'pdf';
+ $form->{formname} = 'invoice';
+ $form->{type} = 'invoice';
+ $form->{vc} = 'customer';
+ $form->{invnumber} = $invoice->invnumber;
+ $form->{recipient_locale} = $invoice->language ? $invoice->language->template_code : '';
+
+ 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);
+}
+