From 4f0087b87f8c92049cc07aa6f3cf79ce8033e098 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 19 Mar 2021 12:20:25 +0100 Subject: [PATCH] =?utf8?q?Mahnungen:=20DMS/WebDAV:=20erzeugte=20Dokumente?= =?utf8?q?=20zum=20Mahnlauf=20ablegen=20=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit und nicht zur gemahnten Rechnung. --- SL/DN.pm | 118 +++++++++++++++++++++------------------------- SL/Webdav.pm | 1 + bin/mozilla/dn.pl | 13 +---- 3 files changed, 56 insertions(+), 76 deletions(-) diff --git a/SL/DN.pm b/SL/DN.pm index 9016aaad4..46d3c8e9e 100644 --- a/SL/DN.pm +++ b/SL/DN.pm @@ -418,7 +418,7 @@ sub _save_dunning { $self->print_dunning($myconfig, $form, $dunning_id, $dbh); if ($print_invoice) { - $self->print_original_invoice($myconfig, $form, $_) for @invoice_ids; + $self->print_original_invoice($myconfig, $form, $dunning_id, $_) for @invoice_ids; } if ($send_email) { @@ -862,7 +862,7 @@ sub print_dunning { $dunning_id =~ s|[^\d]||g; - my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates, @dunned_invoices); + my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates); if ($form->{"language_id"}) { ($language_tc, $output_numberformat, $output_dateformat, $output_longdates) = AM->get_language_details($myconfig, $form, $form->{language_id}); @@ -884,7 +884,7 @@ sub print_dunning { ar.transdate, ar.duedate, ar.customer_id, ar.invnumber, ar.ordnumber, ar.cp_id, ar.amount, ar.netamount, ar.paid, - ar.employee_id, ar.salesman_id, ar.id AS dunned_invoice_id, + ar.employee_id, ar.salesman_id, (SELECT cu.name FROM currencies cu WHERE cu.id = ar.currency_id) AS curr, (SELECT description from department WHERE id = ar.department_id) AS department, ar.amount - ar.paid AS open_amount, @@ -906,7 +906,6 @@ sub print_dunning { map { $ref->{$_} = $form->format_amount($myconfig, $ref->{$_}, 2) } qw(amount netamount paid open_amount fee interest linetotal); map { $form->{$_} = $ref->{$_} } keys %$ref; map { push @{ $form->{TEMPLATE_ARRAYS}->{"dn_$_"} }, $ref->{$_} } keys %$ref; - push @dunned_invoices, {id => $ref->{dunned_invoice_id}, invnumber => $ref->{invnumber}}; } $sth->finish(); @@ -1020,31 +1019,28 @@ sub print_dunning { # this generates the file in the spool directory $form->parse_template($myconfig); - # save dunning pdf in filemanagement/webdav for each invoice - foreach my $dunned_invoice (@dunned_invoices) { - if ($::instance_conf->get_doc_storage) { - SL::File->save( - object_id => $dunned_invoice->{id}, - object_type => $form->{attachment_type}, - mime_type => 'application/pdf', - source => 'created', - file_type => 'document', - file_name => $form->{attachment_filename}, - file_path => "${spool}/$filename", - ); - } - - if ($::instance_conf->get_webdav_documents) { - my $webdav = SL::Webdav->new( - type => 'invoice', - number => $dunned_invoice->{invnumber}, - ); - my $webdav_file = SL::Webdav::File->new( - webdav => $webdav, - filename => $form->{attachment_filename}, - ); - $webdav_file->store(file => "${spool}/$filename"); - } + # save dunning pdf in filemanagement/webdav + if ($::instance_conf->get_doc_storage) { + SL::File->save( + object_id => $dunning_id, + object_type => 'dunning', + mime_type => 'application/pdf', + source => 'created', + file_type => 'document', + file_name => $form->{attachment_filename}, + file_path => "${spool}/$filename", + ); + } + if ($::instance_conf->get_webdav_documents) { + my $webdav = SL::Webdav->new( + type => 'dunning', + number => $dunning_id, + ); + my $webdav_file = SL::Webdav::File->new( + webdav => $webdav, + filename => $form->{attachment_filename}, + ); + $webdav_file->store(file => "${spool}/$filename"); } $main::lxdebug->leave_sub(); @@ -1148,36 +1144,28 @@ sub print_invoice_for_fees { push @{ $form->{DUNNING_PDFS_EMAIL} }, { 'path' => "${spool}/$filename", 'name' => $attachment_filename }; - # save dunning fee pdf in filemanagement/webdav for each dunned invoice - if ($::instance_conf->get_doc_storage || $::instance_conf->get_webdav_documents) { - $query = qq|SELECT trans_id, invnumber FROM dunning LEFT JOIN ar ON (ar.id = trans_id) WHERE dunning_id = ?|; - my $dunned_invoices = selectall_hashref_query($form, $dbh, $query, $dunning_id); - - foreach my $dunned_invoice (@$dunned_invoices) { - if ($::instance_conf->get_doc_storage) { - SL::File->save( - object_id => $dunned_invoice->{trans_id}, - object_type => 'dunning', - mime_type => 'application/pdf', - source => 'created', - file_type => 'document', - file_name => $attachment_filename, - file_path => "${spool}/$filename", - ); - } - - if ($::instance_conf->get_webdav_documents) { - my $webdav = SL::Webdav->new( - type => 'invoice', - number => $dunned_invoice->{invnumber}, - ); - my $webdav_file = SL::Webdav::File->new( - webdav => $webdav, - filename => $attachment_filename, - ); - $webdav_file->store(file => "${spool}/$filename"); - } - } + # save dunning fee pdf in filemanagement/webdav + if ($::instance_conf->get_doc_storage) { + SL::File->save( + object_id => $dunning_id, + object_type => 'dunning', + mime_type => 'application/pdf', + source => 'created', + file_type => 'document', + file_name => $attachment_filename, + file_path => "${spool}/$filename", + ); + } + if ($::instance_conf->get_webdav_documents) { + my $webdav = SL::Webdav->new( + type => 'dunning', + number => $dunning_id, + ); + my $webdav_file = SL::Webdav::File->new( + webdav => $webdav, + filename => $attachment_filename, + ); + $webdav_file->store(file => "${spool}/$filename"); } $main::lxdebug->leave_sub(); @@ -1205,7 +1193,7 @@ sub set_customer_cvars { } sub print_original_invoice { - my ($self, $myconfig, $form, $invoice_id) = @_; + my ($self, $myconfig, $form, $dunning_id, $invoice_id) = @_; # get one invoice as object and print to pdf my $invoice = SL::DB::Invoice->new(id => $invoice_id)->load; @@ -1252,11 +1240,11 @@ sub print_original_invoice { $form->{recipient_locale} = $saved_reicpient_locale; - # save original invoice pdf in filemanagement/webdav for dunned invoice + # save original invoice pdf in filemanagement/webdav for dunning if ($::instance_conf->get_doc_storage) { SL::File->save( - object_id => $invoice_id, - object_type => 'dunning_orig_invoice', + object_id => $dunning_id, + object_type => 'dunning', mime_type => 'application/pdf', source => 'created', file_type => 'document', @@ -1266,8 +1254,8 @@ sub print_original_invoice { } if ($::instance_conf->get_webdav_documents) { my $webdav = SL::Webdav->new( - type => 'invoice', - number => $invoice->invnumber, + type => 'dunning', + number => $dunning_id, ); my $webdav_file = SL::Webdav::File->new( webdav => $webdav, diff --git a/SL/Webdav.pm b/SL/Webdav.pm index c513925e0..0b27d7dc6 100644 --- a/SL/Webdav.pm +++ b/SL/Webdav.pm @@ -34,6 +34,7 @@ my %type_to_path = ( accounts_payable => 'kreditorenbuchungen', customer => 'kunden', vendor => 'lieferanten', + dunning => 'mahnungen', ); sub get_all_files { diff --git a/bin/mozilla/dn.pl b/bin/mozilla/dn.pl index 376b56efb..e690bb9c6 100644 --- a/bin/mozilla/dn.pl +++ b/bin/mozilla/dn.pl @@ -448,18 +448,9 @@ sub show_dunning { } if ($::instance_conf->get_doc_storage) { - # object_types dunning1-dunning3 are the dunnings for the according levels. - my @files = SL::File->get_all_versions(object_id => $ref->{id}, - object_type => 'dunning' . $ref->{dunning_level}, - file_type => 'document',); - # object_type dunning is the dunning invoice with the fees. - push @files, SL::File->get_all_versions(object_id => $ref->{id}, + my @files = SL::File->get_all_versions(object_id => $ref->{dunning_id}, object_type => 'dunning', file_type => 'document',); - # object_type dunning_orig_invoice is the original dunned invoice. - push @files, SL::File->get_all_versions(object_id => $ref->{id}, - object_type => 'dunning_orig_invoice', - file_type => 'document',); if (scalar @files) { my $html = join '
', map { SL::Presenter::FileObject::file_object($_) } @files; my $text = join "\n", map { $_->file_name } @files; @@ -564,7 +555,7 @@ sub print_multiple { # print original dunned invoices, if they where printed on dunning run my $dunnings = SL::DB::Manager::Dunning->get_all(where => [dunning_id => $dunning_id, original_invoice_printed => 1]); - DN->print_original_invoice(\%myconfig, $form, $_->trans_id) for @$dunnings; + DN->print_original_invoice(\%myconfig, $form, $dunning_id, $_->trans_id) for @$dunnings; $i++; } -- 2.20.1