X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/50e99be3f71714e54a62c431b644aeeab3773517..2d0387d1624b5b7ed6b13b79b9d5a87ce9b6d12b:/SL/MT940.pm diff --git a/SL/MT940.pm b/SL/MT940.pm index 2fbbad696..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; @@ -37,15 +37,25 @@ 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++; + my $current_field; + if ($line =~ m{^:(\d+[a-z]*):}i) { + $current_field = $1; + $active_field = $1; + } + if (@lines && ($line =~ m{^\%})) { $lines[-1]->[0] .= substr($line, 1); + } elsif (@lines && ($active_field eq '86') && !$current_field) { + $lines[-1]->[0] .= $line; + } else { push @lines, [ $line, $line_number ]; }