Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6b019910

Von Bernd Bleßmann vor fast 4 Jahren hinzugefügt

  • ID 6b019910eddbbdc1dc21b6d343957d6cd186bc46
  • Vorgänger b82c5043
  • Nachfolger 07aa9777

Mahnungen: alle erzeugten Dokumente zu jeder gemahnten Rechnung im DMS ablegen

Dazu die Dateien nicht mehr in SL::Form::parse_template speichern lassen,
sondern in SL::DN selber für jede gemahnt Rechnung ablegen.

Unterschiede anzeigen:

SL/DN.pm
40 40
use SL::DB::AuthUser;
41 41
use SL::DB::Default;
42 42
use SL::DB::Employee;
43
use SL::File;
43 44
use SL::GenericTranslations;
44 45
use SL::IS;
45 46
use SL::Mailer;
......
858 859

  
859 860
  $dunning_id =~ s|[^\d]||g;
860 861

  
861
  my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates);
862
  my ($language_tc, $output_numberformat, $output_dateformat, $output_longdates, @dunned_invoice_ids);
862 863
  if ($form->{"language_id"}) {
863 864
    ($language_tc, $output_numberformat, $output_dateformat, $output_longdates) =
864 865
      AM->get_language_details($myconfig, $form, $form->{language_id});
......
880 881
         ar.transdate,       ar.duedate,      ar.customer_id,
881 882
         ar.invnumber,       ar.ordnumber,    ar.cp_id,
882 883
         ar.amount,          ar.netamount,    ar.paid,
883
         ar.employee_id,     ar.salesman_id,
884
         ar.employee_id,     ar.salesman_id,  ar.id AS dunned_invoice_id,
884 885
         (SELECT cu.name FROM currencies cu WHERE cu.id = ar.currency_id) AS curr,
885 886
         (SELECT description from department WHERE id = ar.department_id) AS department,
886 887
         ar.amount - ar.paid AS open_amount,
......
902 903
    map { $ref->{$_} = $form->format_amount($myconfig, $ref->{$_}, 2) } qw(amount netamount paid open_amount fee interest linetotal);
903 904
    map { $form->{$_} = $ref->{$_} } keys %$ref;
904 905
    map { push @{ $form->{TEMPLATE_ARRAYS}->{"dn_$_"} }, $ref->{$_} } keys %$ref;
906
    push @dunned_invoice_ids, $ref->{dunned_invoice_id};
905 907
  }
906 908
  $sth->finish();
907 909

  
......
1011 1013
  }
1012 1014
  $form->{attachment_filename} = $form->get_formname_translation($form->{attachment_type}) . "_${dunning_id}.pdf";
1013 1015
  $form->{attachment_id} = $form->{invoice_id};
1016

  
1017
  # this generates the file in the spool directory
1014 1018
  $form->parse_template($myconfig);
1015 1019

  
1020
  # save dunning pdf in filemanagement for each invoice
1021
  if ($::instance_conf->get_doc_storage) {
1022
    foreach my $dunned_invoice_id (@dunned_invoice_ids) {
1023
      SL::File->save(
1024
        object_id   => $dunned_invoice_id,
1025
        object_type => $form->{attachment_type},
1026
        mime_type   => 'application/pdf',
1027
        source      => 'created',
1028
        file_type   => 'document',
1029
        file_name   => $form->{attachment_filename},
1030
        file_path   => "${spool}/$filename",
1031
      );
1032
    }
1033
  }
1034

  
1016 1035
  $main::lxdebug->leave_sub();
1017 1036
}
1018 1037

  
......
1114 1133
  push @{ $form->{DUNNING_PDFS_EMAIL} }, { 'path' => "${spool}/$filename",
1115 1134
                                           'name' => $attachment_filename };
1116 1135

  
1136
  # save dunning fee pdf in filemanagement for each dunned invoice
1137
  if ($::instance_conf->get_doc_storage) {
1138
    $query                 = qq|SELECT trans_id FROM dunning WHERE dunning_id = ?|;
1139
    my @dunned_invoice_ids = selectall_array_query($form, $dbh, $query, $dunning_id);
1140
    foreach my $dunned_invoice_id (@dunned_invoice_ids) {
1141
      SL::File->save(
1142
        object_id   => $dunned_invoice_id,
1143
        object_type => 'dunning',
1144
        mime_type   => 'application/pdf',
1145
        source      => 'created',
1146
        file_type   => 'document',
1147
        file_name   => $attachment_filename,
1148
        file_path   => "${spool}/$filename",
1149
      );
1150
    }
1151
  }
1152

  
1117 1153
  $main::lxdebug->leave_sub();
1118 1154
}
1119 1155

  
......
1178 1214
  my $saved_reicpient_locale = $form->{recipient_locale};
1179 1215
  $form->{recipient_locale}  = $invoice->language;
1180 1216

  
1217
  my $attachment_filename    = $form->get_formname_translation('invoice') . "_" . $invoice->invnumber . ".pdf";
1218

  
1181 1219
  push @{ $form->{DUNNING_PDFS} }, $file_name;
1182 1220
  push @{ $form->{DUNNING_PDFS_EMAIL} }, { 'path' => "${spool}/$file_name",
1183
                                           'name' => $form->get_formname_translation('invoice') . "_" . $invoice->invnumber . ".pdf" };
1221
                                           'name' => $attachment_filename };
1184 1222

  
1185 1223
  $form->{recipient_locale}  = $saved_reicpient_locale;
1224

  
1225
  # save original invoice pdf in filemanagement for dunned invoice
1226
  if ($::instance_conf->get_doc_storage) {
1227
    SL::File->save(
1228
      object_id   => $invoice_id,
1229
      object_type => 'dunning',
1230
      mime_type   => 'application/pdf',
1231
      source      => 'created',
1232
      file_type   => 'document',
1233
      file_name   => $attachment_filename,
1234
      file_path   => "${spool}/$file_name",
1235
    );
1236
  }
1237

  
1186 1238
}
1187 1239

  
1188 1240
1;
SL/Form.pm
934 934
      }
935 935
    }
936 936

  
937
    if (!$self->{preview} && $self->doc_storage_enabled)
937
    if (!$self->{preview} && $self->{attachment_type} !~ m{^dunning} && $self->doc_storage_enabled)
938 938
    {
939 939
      $self->{attachment_filename} ||= $self->generate_attachment_filename;
940 940
      $self->store_pdf($self);
......
954 954
    }
955 955
  }
956 956

  
957
  if ( !$self->{preview} && $ext_for_format eq 'pdf' && $self->doc_storage_enabled) {
957
  if ( !$self->{preview} && $ext_for_format eq 'pdf' && $self->{attachment_type} !~ m{^dunning} && $self->doc_storage_enabled) {
958 958
    $self->{attachment_filename} ||= $self->generate_attachment_filename;
959 959
    my $file_obj = $self->store_pdf($self);
960 960
    $self->{print_file_id} = $file_obj->id if $file_obj;

Auch abrufbar als: Unified diff