From: Moritz Bunkus Date: Thu, 18 Mar 2021 11:29:47 +0000 (+0100) Subject: MT940: Zeichensatz der Datei bei Import auswählen können X-Git-Tag: kivitendo-mebil_0.1-0~9^2~421 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=502a10d47975bb857364282ac2bfe7f995b21a86;p=kivitendo-erp.git MT940: Zeichensatz der Datei bei Import auswählen können --- diff --git a/SL/Controller/BankImport.pm b/SL/Controller/BankImport.pm index 04d72d368..1b20deca3 100644 --- a/SL/Controller/BankImport.pm +++ b/SL/Controller/BankImport.pm @@ -16,7 +16,7 @@ use SL::SessionFile::Random; use Rose::Object::MakeMethods::Generic ( - scalar => [ qw(file_name transactions statistics) ], + scalar => [ qw(file_name transactions statistics charset) ], 'scalar --get_set_init' => [ qw(bank_accounts) ], ); @@ -43,6 +43,7 @@ sub action_import_mt940_preview { $file->fh->print($::form->{file}); $file->fh->close; + $self->charset($::form->{charset}); $self->file_name($file->file_name); $self->parse_and_analyze_transactions; @@ -56,6 +57,7 @@ sub action_import_mt940 { die "missing file for action import_mt940" unless $::form->{file_name}; $self->file_name($::form->{file_name}); + $self->charset($::form->{charset}); $self->parse_and_analyze_transactions; $self->import_transactions; @@ -71,7 +73,7 @@ sub parse_and_analyze_transactions { my $currency_id = SL::DB::Default->get->currency_id; - $self->transactions([ sort { $a->{transdate} cmp $b->{transdate} } SL::MT940->parse($self->file_name) ]); + $self->transactions([ sort { $a->{transdate} cmp $b->{transdate} } SL::MT940->parse($self->file_name, charset => $self->charset) ]); foreach my $transaction (@{ $self->transactions }) { $transaction->{bank_account} = $self->bank_accounts->{ make_bank_account_idx($transaction->{local_bank_code}, $transaction->{local_account_number}) }; diff --git a/SL/MT940.pm b/SL/MT940.pm index dd965deea..2a97e5e79 100644 --- a/SL/MT940.pm +++ b/SL/MT940.pm @@ -24,7 +24,7 @@ sub _join_entries { } sub parse { - my ($class, $file_name) = @_; + my ($class, $file_name, %params) = @_; my ($local_bank_code, $local_account_number, %transaction, @transactions, @lines); my $line_number = 0; @@ -40,7 +40,7 @@ sub parse { my ($active_field); foreach my $line (read_file($file_name)) { chomp $line; - $line = Encode::decode('UTF-8', $line); + $line = Encode::decode($params{charset} // 'UTF-8', $line); $line =~ s{\r+}{}; $line_number++; diff --git a/locale/de/all b/locale/de/all index 23c8fccca..878561b19 100755 --- a/locale/de/all +++ b/locale/de/all @@ -1680,7 +1680,6 @@ $self->{texts} = { 'Import CSV' => 'CSV-Import', 'Import Status' => 'Import Status', 'Import a Factur-X/ZUGFeRD file:' => 'Eine Factur-X-/ZUGFeRD-Datei importieren', - 'Import a MT940 file:' => 'Laden Sie eine MT940 Datei hoch:', 'Import all' => 'Importiere Alle', 'Import documents from #1' => 'Importiere Dateien von Quelle \'#1\'', 'Import file' => 'Import-Datei', @@ -1929,6 +1928,7 @@ $self->{texts} = { 'MAILED' => 'Gesendet', 'MD' => 'PT', 'MIME type' => 'MIME-Typ', + 'MT940 file' => 'MT940-Datei', 'MT940 import' => 'MT940 Import', 'MT940 import preview' => 'MT940-Import-Vorschau', 'MT940 import result' => 'MT940-Import-Ergebnis', diff --git a/templates/webpages/bank_import/import_mt940.html b/templates/webpages/bank_import/import_mt940.html index b08eaa83a..e2baa5feb 100644 --- a/templates/webpages/bank_import/import_mt940.html +++ b/templates/webpages/bank_import/import_mt940.html @@ -8,6 +8,7 @@ [% IF preview %]
[% L.hidden_tag('file_name', SELF.file_name) %] + [% L.hidden_tag('charset', SELF.charset) %]
[% END %] diff --git a/templates/webpages/bank_import/upload_mt940.html b/templates/webpages/bank_import/upload_mt940.html index b45185603..7d3233f5b 100644 --- a/templates/webpages/bank_import/upload_mt940.html +++ b/templates/webpages/bank_import/upload_mt940.html @@ -7,10 +7,16 @@

[% FORM.title %]

-

- [% "Import a MT940 file:" | $T8 %] -

-
- [% L.input_tag('file', '', type => 'file', accept => '*') %] + + + + + + + + + + +
[% LxERP.t8("Charset") %]:[% L.select_tag('charset', [ [ 'ISO-8859-15', 'ISO-8859-15 (Latin 1)' ], [ 'UTF-8', 'UTF-8' ], [ 'Windows-1252', 'Windows-1252' ] ], default='UTF-8') %]
[% LxERP.t8("MT940 file") %]:[% L.input_tag('file', '', type => 'file', accept => '*') %]