Revision 50e99be3
Von Moritz Bunkus vor fast 4 Jahren hinzugefügt
SL/MT940.pm | ||
---|---|---|
5 | 5 |
|
6 | 6 |
use Data::Dumper; |
7 | 7 |
use DateTime; |
8 |
use SL::DB::Default; |
|
8 | 9 |
use Encode; |
9 | 10 |
use File::Slurp qw(read_file); |
10 | 11 |
|
... | ... | |
27 | 28 |
|
28 | 29 |
my ($local_bank_code, $local_account_number, %transaction, @transactions, @lines); |
29 | 30 |
my $line_number = 0; |
31 |
my $default_currency = substr(SL::DB::Default->get_default_currency, -1, 1); |
|
30 | 32 |
|
31 | 33 |
my $store_transaction = sub { |
32 | 34 |
if (%transaction) { |
... | ... | |
58 | 60 |
$local_bank_code = $1; |
59 | 61 |
$local_account_number = $2; |
60 | 62 |
|
61 |
} elsif ($line->[0] =~ m{^:61: (\d{2}) (\d{2}) (\d{2}) (\d{2}) (\d{2}) (C|D|RC|RD) (.) (\d+) (?:, (\d*))? N (.{3}) (.*)}x) {
|
|
62 |
# 1 2 3 4 5 6 7 8 9 10 11
|
|
63 |
} elsif ($line->[0] =~ m{^:61: (\d{2}) (\d{2}) (\d{2}) (\d{4})? (C|D|RC|RD) ([a-zA-Z]?) (\d+) (?:, (\d*))? N (.{3}) (.*)}x) {
|
|
64 |
# 1 2 3 4 5 6 7 8 9 10
|
|
63 | 65 |
# :61:2008060806CR952,N051NONREF |
64 | 66 |
|
65 | 67 |
$store_transaction->(); |
... | ... | |
67 | 69 |
my $valuta_year = $1 * 1 + 2000; |
68 | 70 |
my $valuta_month = $2; |
69 | 71 |
my $valuta_day = $3; |
70 |
my $trans_month = $4; |
|
71 |
my $trans_day = $5;
|
|
72 |
my $debit_credit = $6;
|
|
73 |
my $currency = $7;
|
|
74 |
my $amount1 = $8;
|
|
75 |
my $amount2 = $9 || 0;
|
|
76 |
my $transaction_code = $10;
|
|
77 |
my $reference = $11;
|
|
72 |
my $trans_month = $4 ? substr($4, 0, 2) : $valuta_month;
|
|
73 |
my $trans_day = $4 ? substr($4, 2, 2) : $valuta_day;
|
|
74 |
my $debit_credit = $5;
|
|
75 |
my $currency = $6 || $default_currency;
|
|
76 |
my $amount1 = $7;
|
|
77 |
my $amount2 = $8 || 0;
|
|
78 |
my $transaction_code = $9;
|
|
79 |
my $reference = $10;
|
|
78 | 80 |
|
79 | 81 |
my $valuta_date = DateTime->new_local(year => $valuta_year, month => $valuta_month, day => $valuta_day); |
80 | 82 |
my $trans_date = DateTime->new_local(year => $valuta_year, month => $trans_month, day => $trans_day); |
Auch abrufbar als: Unified diff
MT940: Zeile 61: Felder »Buchungsdatum« und »Währungsart« sind optional