Filemanagement: Speichern der erzeugten Mahnungsdokumente
authorMartin Helmling martin.helmling@octosoft.eu <martin.helmling@octosoft.eu>
Wed, 19 Jul 2017 12:20:05 +0000 (14:20 +0200)
committerMartin Helmling martin.helmling@octosoft.eu <martin.helmling@octosoft.eu>
Wed, 19 Jul 2017 13:14:06 +0000 (15:14 +0200)
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
SL/DN.pm
SL/Form.pm
SL/Helper/File.pm
locale/de/all

index add213b..ee41dd3 100644 (file)
@@ -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));
index b29cf51..51ab07b 100644 (file)
--- 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);
index 7f66f6f..645d7a0 100644 (file)
@@ -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'),
index fcf48d6..d59fb56 100644 (file)
@@ -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 E<lt>martin.helmling@opendynamic.deE<gt>
 
 
 =cut
-
index b1c3b3d..2f22d96 100755 (executable)
@@ -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',