BankImport: Csv-Datei mit zufälligem Dateinamen speichern und im Profil übergeben
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 20 Feb 2017 20:09:03 +0000 (21:09 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 3 Mar 2017 20:57:10 +0000 (21:57 +0100)
siehe auch commit "CsvImport: zufälligen Dateinamen für jeden Import. Ablegen in
temporärem Profil"

SL/Controller/BankImport.pm

index 7e08fc6..bc65d17 100644 (file)
@@ -6,6 +6,7 @@ use parent qw(SL::Controller::Base);
 use SL::Locale::String qw(t8);
 use SL::DB::CsvImportProfile;
 use SL::Helper::MT940;
+use SL::SessionFile::Random;
 
 use Rose::Object::MakeMethods::Generic
 (
@@ -28,10 +29,12 @@ sub action_import_mt940 {
 
   my $converted_data = SL::Helper::MT940::convert_mt940_data($::form->{file});
 
-  # store the converted data in a session file with a name expected by the profile type "bank_transactions"
-  my $file = SL::SessionFile->new("csv-import-bank_transactions.csv", mode => '>');
+  # store the converted data in a session file and create a temporary profile with it's name
+  my $file = SL::SessionFile::Random->new(mode => '>');
   $file->fh->print($converted_data);
   $file->fh->close;
+  $self->profile->set('file_name', $file->file_name);
+  $self->profile($self->profile->clone_and_reset_deep)->save;
 
   die t8("The MT940 import needs an import profile called MT940") unless $self->profile;