Revision 502a10d4
Von Moritz Bunkus vor fast 4 Jahren hinzugefügt
SL/Controller/BankImport.pm | ||
---|---|---|
16 | 16 |
|
17 | 17 |
use Rose::Object::MakeMethods::Generic |
18 | 18 |
( |
19 |
scalar => [ qw(file_name transactions statistics) ], |
|
19 |
scalar => [ qw(file_name transactions statistics charset) ],
|
|
20 | 20 |
'scalar --get_set_init' => [ qw(bank_accounts) ], |
21 | 21 |
); |
22 | 22 |
|
... | ... | |
43 | 43 |
$file->fh->print($::form->{file}); |
44 | 44 |
$file->fh->close; |
45 | 45 |
|
46 |
$self->charset($::form->{charset}); |
|
46 | 47 |
$self->file_name($file->file_name); |
47 | 48 |
$self->parse_and_analyze_transactions; |
48 | 49 |
|
... | ... | |
56 | 57 |
die "missing file for action import_mt940" unless $::form->{file_name}; |
57 | 58 |
|
58 | 59 |
$self->file_name($::form->{file_name}); |
60 |
$self->charset($::form->{charset}); |
|
59 | 61 |
$self->parse_and_analyze_transactions; |
60 | 62 |
$self->import_transactions; |
61 | 63 |
|
... | ... | |
71 | 73 |
|
72 | 74 |
my $currency_id = SL::DB::Default->get->currency_id; |
73 | 75 |
|
74 |
$self->transactions([ sort { $a->{transdate} cmp $b->{transdate} } SL::MT940->parse($self->file_name) ]); |
|
76 |
$self->transactions([ sort { $a->{transdate} cmp $b->{transdate} } SL::MT940->parse($self->file_name, charset => $self->charset) ]);
|
|
75 | 77 |
|
76 | 78 |
foreach my $transaction (@{ $self->transactions }) { |
77 | 79 |
$transaction->{bank_account} = $self->bank_accounts->{ make_bank_account_idx($transaction->{local_bank_code}, $transaction->{local_account_number}) }; |
SL/MT940.pm | ||
---|---|---|
24 | 24 |
} |
25 | 25 |
|
26 | 26 |
sub parse { |
27 |
my ($class, $file_name) = @_; |
|
27 |
my ($class, $file_name, %params) = @_;
|
|
28 | 28 |
|
29 | 29 |
my ($local_bank_code, $local_account_number, %transaction, @transactions, @lines); |
30 | 30 |
my $line_number = 0; |
... | ... | |
40 | 40 |
my ($active_field); |
41 | 41 |
foreach my $line (read_file($file_name)) { |
42 | 42 |
chomp $line; |
43 |
$line = Encode::decode('UTF-8', $line); |
|
43 |
$line = Encode::decode($params{charset} // 'UTF-8', $line);
|
|
44 | 44 |
$line =~ s{\r+}{}; |
45 | 45 |
$line_number++; |
46 | 46 |
|
locale/de/all | ||
---|---|---|
1680 | 1680 |
'Import CSV' => 'CSV-Import', |
1681 | 1681 |
'Import Status' => 'Import Status', |
1682 | 1682 |
'Import a Factur-X/ZUGFeRD file:' => 'Eine Factur-X-/ZUGFeRD-Datei importieren', |
1683 |
'Import a MT940 file:' => 'Laden Sie eine MT940 Datei hoch:', |
|
1684 | 1683 |
'Import all' => 'Importiere Alle', |
1685 | 1684 |
'Import documents from #1' => 'Importiere Dateien von Quelle \'#1\'', |
1686 | 1685 |
'Import file' => 'Import-Datei', |
... | ... | |
1929 | 1928 |
'MAILED' => 'Gesendet', |
1930 | 1929 |
'MD' => 'PT', |
1931 | 1930 |
'MIME type' => 'MIME-Typ', |
1931 |
'MT940 file' => 'MT940-Datei', |
|
1932 | 1932 |
'MT940 import' => 'MT940 Import', |
1933 | 1933 |
'MT940 import preview' => 'MT940-Import-Vorschau', |
1934 | 1934 |
'MT940 import result' => 'MT940-Import-Ergebnis', |
templates/webpages/bank_import/import_mt940.html | ||
---|---|---|
8 | 8 |
[% IF preview %] |
9 | 9 |
<form method="post" action="controller.pl" enctype="multipart/form-data" id="form"> |
10 | 10 |
[% L.hidden_tag('file_name', SELF.file_name) %] |
11 |
[% L.hidden_tag('charset', SELF.charset) %] |
|
11 | 12 |
</form> |
12 | 13 |
[% END %] |
13 | 14 |
|
templates/webpages/bank_import/upload_mt940.html | ||
---|---|---|
7 | 7 |
|
8 | 8 |
<h1>[% FORM.title %]</h1> |
9 | 9 |
|
10 |
<p> |
|
11 |
[% "Import a MT940 file:" | $T8 %] |
|
12 |
</p> |
|
13 |
|
|
14 | 10 |
<form method="post" action="controller.pl" enctype="multipart/form-data" id="form"> |
15 |
[% L.input_tag('file', '', type => 'file', accept => '*') %] |
|
11 |
<table> |
|
12 |
<tr> |
|
13 |
<td>[% LxERP.t8("Charset") %]:</td> |
|
14 |
<td>[% L.select_tag('charset', [ [ 'ISO-8859-15', 'ISO-8859-15 (Latin 1)' ], [ 'UTF-8', 'UTF-8' ], [ 'Windows-1252', 'Windows-1252' ] ], default='UTF-8') %]</td> |
|
15 |
</tr> |
|
16 |
|
|
17 |
<tr> |
|
18 |
<td>[% LxERP.t8("MT940 file") %]:</td> |
|
19 |
<td>[% L.input_tag('file', '', type => 'file', accept => '*') %]</td> |
|
20 |
</tr> |
|
21 |
</table> |
|
16 | 22 |
</form> |
Auch abrufbar als: Unified diff
MT940: Zeichensatz der Datei bei Import auswählen können