From 97422880ec1448b61c609c3d2a6257c1f5d582bf Mon Sep 17 00:00:00 2001 From: "Martin Helmling martin.helmling@octosoft.eu" Date: Wed, 19 Jul 2017 14:20:05 +0200 Subject: [PATCH] Filemanagement: Speichern der erzeugten Mahnungsdokumente MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Die Dokumente werden nun bei der entsprechenden Rechnung abgespeichert. Da ja Rechnungen zusammengefasst werden können, wäre die Zuordnung ggf bei den Kundendaten besser impl redmine #274 --- SL/Controller/File.pm | 5 ++++- SL/DN.pm | 18 +++++++++++++++--- SL/Form.pm | 4 ++++ SL/Helper/File.pm | 6 +++--- locale/de/all | 2 ++ 5 files changed, 28 insertions(+), 7 deletions(-) diff --git a/SL/Controller/File.pm b/SL/Controller/File.pm index add213b04..ee41dd3c8 100644 --- a/SL/Controller/File.pm +++ b/SL/Controller/File.pm @@ -373,8 +373,11 @@ sub _do_list { my @files; $main::lxdebug->message(LXDebug->DEBUG2(), "do_list: object_id=".$self->object_id." object_type=".$self->object_type." file_type=".$self->file_type." json=".$json); if ( $self->file_type eq 'document' ) { + my @object_types; + push @object_types, $self->object_type; + push @object_types, ('dunning','dunning1','dunning2','dunning3') if $self->object_type eq 'invoice'; @files = SL::File->get_all_versions(object_id => $self->object_id , - object_type => $self->object_type, + object_type => \@object_types, file_type => $self->file_type ); $main::lxdebug->message(LXDebug->DEBUG2(), "cnt1=".scalar(@files)); diff --git a/SL/DN.pm b/SL/DN.pm index b29cf51a2..51ab07b3c 100644 --- a/SL/DN.pm +++ b/SL/DN.pm @@ -837,6 +837,7 @@ sub print_dunning { c.greeting, c.contact, c.phone, c.fax, c.homepage, c.email, c.taxincluded, c.business_id, c.taxnumber, c.iban, c.ustid, + ar.id AS invoice_id, co.* FROM dunning d LEFT JOIN ar ON (d.trans_id = ar.id) @@ -850,7 +851,7 @@ sub print_dunning { $query = qq|SELECT - cfg.interest_rate, cfg.template AS formname, + cfg.interest_rate, cfg.template AS formname, cfg.dunning_level, cfg.email_subject, cfg.email_body, cfg.email_attachment, d.transdate AS dunning_date, (SELECT SUM(fee) @@ -909,6 +910,12 @@ sub print_dunning { $form->get_employee_data('prefix' => 'employee', 'id' => $form->{employee_id}); $form->get_employee_data('prefix' => 'salesman', 'id' => $form->{salesman_id}); + $form->{attachment_type} = "dunning"; + if ( $form->{dunning_level} ) { + $form->{attachment_type} .= $form->{dunning_level} if $form->{dunning_level} < 4; + } + $form->{attachment_filename} = $form->get_formname_translation($form->{attachment_type}) . "_${dunning_id}.pdf"; + $form->{attachment_id} = $form->{invoice_id}; $form->parse_template($myconfig); $main::lxdebug->leave_sub(); @@ -926,11 +933,13 @@ sub print_invoice_for_fees { $query = qq|SELECT d.fee_interest_ar_id, - dcfg.template + d.trans_id AS invoice_id, + dcfg.template, + dcfg.dunning_level FROM dunning d LEFT JOIN dunning_config dcfg ON (d.dunning_config_id = dcfg.id) WHERE d.dunning_id = ?|; - my ($ar_id, $template) = selectrow_query($form, $dbh, $query, $dunning_id); + my ($ar_id, $invoice_id, $template, $dunning_level) = selectrow_query($form, $dbh, $query, $dunning_id); if (!$ar_id) { $main::lxdebug->leave_sub(); @@ -998,6 +1007,9 @@ sub print_invoice_for_fees { map { delete $form->{$_} } grep /^[a-z_]+_\d+$/, keys %{ $form }; + $form->{attachment_filename} = $form->get_formname_translation('dunning_invoice') . "_${dunning_id}.pdf"; + $form->{attachment_type} = "dunning"; + $form->{attachment_id} = $form->{invoice_id}; $form->parse_template($myconfig); restore_form($saved_form); diff --git a/SL/Form.pm b/SL/Form.pm index 7f66f6fbf..645d7a061 100644 --- a/SL/Form.pm +++ b/SL/Form.pm @@ -1279,6 +1279,10 @@ sub get_formname_translation { sales_delivery_order => $main::locale->text('Delivery Order'), purchase_delivery_order => $main::locale->text('Delivery Order'), dunning => $main::locale->text('Dunning'), + dunning1 => $main::locale->text('Payment Reminder'), + dunning2 => $main::locale->text('Dunning'), + dunning3 => $main::locale->text('Last Dunning'), + dunning_invoice => $main::locale->text('Dunning Invoice'), letter => $main::locale->text('Letter'), ic_supply => $main::locale->text('Intra-Community supply'), statement => $main::locale->text('Statement'), diff --git a/SL/Helper/File.pm b/SL/Helper/File.pm index fcf48d67d..d59fb56ac 100644 --- a/SL/Helper/File.pm +++ b/SL/Helper/File.pm @@ -11,7 +11,8 @@ sub store_pdf { my ($self, $form) = @_; return unless $::instance_conf->get_doc_storage; my $type = $form->{type}; - $type = $form->{formname} if $form->{formname} && !$form->{type}; + $type = $form->{formname} if $form->{formname} && !$form->{type}; + $type = $form->{attachment_type} if $form->{attachment_type}; my $id = $form->{id}; $id = $form->{attachment_id} if $form->{attachment_id} && !$form->{id}; return if !$id || !$type; @@ -83,7 +84,7 @@ SL::Helper::File - Helper for $::Form to store generated PDF-Documents $self->append_general_pdf_attachments(filepath => $pdf_filename, type => $form->{type}) if ( $ext_for_format eq 'pdf' ); #It is also used in MassPrint Helper -# +# =head1 DESCRIPTION @@ -151,4 +152,3 @@ Martin Helmling Emartin.helmling@opendynamic.deE =cut - diff --git a/locale/de/all b/locale/de/all index b1c3b3dcf..2f22d9616 100755 --- a/locale/de/all +++ b/locale/de/all @@ -1040,6 +1040,7 @@ $self->{texts} = { 'Dunning Description' => 'Mahnstufenbeschreibung', 'Dunning Description missing in row ' => 'Mahnstufenbeschreibung fehlt in Zeile ', 'Dunning Duedate' => 'Zahlbar bis', + 'Dunning Invoice' => 'Mahnrechnung', 'Dunning Level' => 'Mahnlevel', 'Dunning Level missing in row ' => 'Mahnlevel fehlt in ', 'Dunning Process Config saved!' => 'Mahnwesenkonfiguration gespeichert!', @@ -1654,6 +1655,7 @@ $self->{texts} = { 'Last Cost' => 'Einkaufspreis', 'Last Credit Note Number' => 'Letzte Gutschriftnummer', 'Last Customer Number' => 'Letzte Kundennummer', + 'Last Dunning' => 'Letzte Mahnung', 'Last Invoice Number' => 'Letzte Rechnungsnummer', 'Last Purchase Delivery Order Number' => 'Letzte Lieferscheinnummer (Einkauf)', 'Last Purchase Order Number' => 'Letzte Lieferantenautragsnummer', -- 2.20.1