Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 6348a23d

Von Tamino Steinert vor mehr als 1 Jahr hinzugefügt

  • ID 6348a23d2c7956520870e6ccca26d65b464a102d
  • Vorgänger b0914304
  • Nachfolger ea5b6825

Dunning: Ursprungs-Rechnungsbeleg konfigurierbar (neu oder bestehender)

Unterschiede anzeigen:

SL/DN.pm
78 78
  }
79 79

  
80 80
  $query =
81
    qq|SELECT dunning_ar_amount_fee, dunning_ar_amount_interest, dunning_ar, dunning_creator
81
    qq|SELECT dunning_ar_amount_fee, dunning_ar_amount_interest, dunning_ar, dunning_creator,
82
              dunning_original_invoice_creation_mode
82 83
       FROM defaults|;
83
  ($form->{AR_amount_fee}, $form->{AR_amount_interest}, $form->{AR}, $form->{dunning_creator})
84
  ($form->{AR_amount_fee}, $form->{AR_amount_interest}, $form->{AR}, $form->{dunning_creator},
85
   $form->{dunning_original_invoice_creation_mode})
84 86
    = selectrow_query($form, $dbh, $query);
85 87

  
86 88
  $main::lxdebug->leave_sub();
......
147 149
  }
148 150

  
149 151
  $query  = qq|UPDATE defaults SET dunning_ar_amount_fee = ?, dunning_ar_amount_interest = ?, dunning_ar = ?,
150
               dunning_creator = ?|;
152
               dunning_creator = ?, dunning_original_invoice_creation_mode = ?|;
151 153
  @values = (conv_i($form->{AR_amount_fee}), conv_i($form->{AR_amount_interest}), conv_i($form->{AR}),
152
             $form->{dunning_creator});
154
             $form->{dunning_creator}, $form->{dunning_original_invoice_creation_mode});
153 155
  do_query($form, $dbh, $query, @values);
154 156

  
155 157
  return 1;
......
1218 1220

  
1219 1221
  die "Invalid invoice object" unless ref($invoice) eq 'SL::DB::Invoice';
1220 1222

  
1223
  my $filestore_enabled = SL::DB::Default->get->webdav
1224
                       || SL::DB::Default->get->doc_storage;
1225
  if ($::instance_conf->get_dunning_original_invoice_creation_mode eq 'use_last_created_or_create_new'
1226
      && $filestore_enabled) {
1227
    my ($file_name, $file_path);
1228
    # search file in files and webdav
1229
    if (SL::DB::Default->get->doc_storage) {
1230
      my $file_entry = SL::DB::Manager::File->get_first(
1231
        query => [
1232
          object_type => $invoice->type,
1233
          object_id   => $invoice->id,
1234
        ],
1235
      );
1236
      if ($file_entry) {
1237
        my $file = SL::File::Object->new(
1238
          db_file => $file_entry,
1239
          id => $file_entry->id,
1240
          loaded => 1,
1241
        );
1242
        $file_name = $file->file_name();
1243
        $file_path = $file->get_file();
1244
      }
1245
    } elsif (SL::DB::Default->get->webdav) {
1246
      my $webdav = SL::Webdav->new(
1247
        type   => $invoice->type,
1248
        number => $invoice->record_number,
1249
      );
1250
      my @latest_object = $webdav->get_all_latest();
1251
      if (scalar @latest_object) {
1252
        $file_name = $latest_object[0]->basename . "." . $latest_object[0]->extension;
1253
        $file_path = $latest_object[0]->full_filedescriptor();
1254
      }
1255
    } # end file search
1256

  
1257
    my $attachment_filename    = $form->get_formname_translation('invoice') . "_" . $invoice->invnumber . ".pdf";
1258
    if ($file_name ne '' and $file_path ne '') {
1259
      my $spool = $::lx_office_conf{paths}->{spool};
1260
      my $spool_path = File::Spec->catfile($spool, $file_name);
1261

  
1262
      copy($file_path, $spool_path) or die "The copy operation failed: $!";
1263

  
1264
      push @{ $form->{DUNNING_PDFS} }        , $file_name;
1265
      push @{ $form->{DUNNING_PDFS_EMAIL} }  , {
1266
        'path'       => $file_path,
1267
        'name'       => $file_name, };
1268
      push @{ $form->{DUNNING_PDFS_STORAGE} }, {
1269
        'dunning_id' => $dunning_id,
1270
        'path'       => $file_path,
1271
        'name'       => $file_name };
1272
      return;
1273
    }
1274
  }
1275

  
1221 1276
  my $print_form          = Form->new('');
1222 1277
  $print_form->{type}     = 'invoice';
1223 1278
  $print_form->{formname} = 'invoice',

Auch abrufbar als: Unified diff