Revision 502a10d4
Von Moritz Bunkus vor fast 4 Jahren hinzugefügt
SL/Controller/BankImport.pm | ||
---|---|---|
|
||
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) ],
|
||
);
|
||
|
||
... | ... | |
$file->fh->print($::form->{file});
|
||
$file->fh->close;
|
||
|
||
$self->charset($::form->{charset});
|
||
$self->file_name($file->file_name);
|
||
$self->parse_and_analyze_transactions;
|
||
|
||
... | ... | |
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;
|
||
|
||
... | ... | |
|
||
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}) };
|
SL/MT940.pm | ||
---|---|---|
}
|
||
|
||
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;
|
||
... | ... | |
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++;
|
||
|
locale/de/all | ||
---|---|---|
'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',
|
||
... | ... | |
'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',
|
templates/webpages/bank_import/import_mt940.html | ||
---|---|---|
[% IF preview %]
|
||
<form method="post" action="controller.pl" enctype="multipart/form-data" id="form">
|
||
[% L.hidden_tag('file_name', SELF.file_name) %]
|
||
[% L.hidden_tag('charset', SELF.charset) %]
|
||
</form>
|
||
[% END %]
|
||
|
templates/webpages/bank_import/upload_mt940.html | ||
---|---|---|
|
||
<h1>[% FORM.title %]</h1>
|
||
|
||
<p>
|
||
[% "Import a MT940 file:" | $T8 %]
|
||
</p>
|
||
|
||
<form method="post" action="controller.pl" enctype="multipart/form-data" id="form">
|
||
[% L.input_tag('file', '', type => 'file', accept => '*') %]
|
||
<table>
|
||
<tr>
|
||
<td>[% LxERP.t8("Charset") %]:</td>
|
||
<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>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>[% LxERP.t8("MT940 file") %]:</td>
|
||
<td>[% L.input_tag('file', '', type => 'file', accept => '*') %]</td>
|
||
</tr>
|
||
</table>
|
||
</form>
|
Auch abrufbar als: Unified diff
MT940: Zeichensatz der Datei bei Import auswählen können