X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/dccb820ac74462367f37c2d7d4afab8b214a37ad..f217d072d76183bc07723dcc29503b732bd2022d:/SL/Controller/BankImport.pm diff --git a/SL/Controller/BankImport.pm b/SL/Controller/BankImport.pm index 04d72d368..20c376418 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}) }; @@ -135,7 +137,7 @@ sub import_transactions { next if $transaction->{error} || $transaction->{duplicate}; SL::DB::BankTransaction->new( - map { ($_ => $transaction->{$_}) } qw(amount currency_id local_bank_account_id purpose remote_account_number remote_bank_code remote_name transaction_code transdate valutadate) + map { ($_ => $transaction->{$_}) } qw(amount currency_id local_bank_account_id purpose remote_account_number remote_bank_code remote_name transaction_code transdate valutadate end_to_end_id) )->save; $imported++; @@ -168,16 +170,18 @@ sub make_transaction_idx { my ($transaction) = @_; if (ref($transaction) eq 'SL::DB::BankTransaction') { - $transaction = { map { ($_ => $transaction->$_) } qw(local_bank_account_id transdate valutadate amount purpose) }; + $transaction = { map { ($_ => $transaction->$_) } qw(local_bank_account_id remote_account_number transdate valutadate amount purpose end_to_end_id) }; } + my @other_fields = $transaction->{end_to_end_id} && $::instance_conf->get_check_bt_duplicates_endtoend + ? qw(end_to_end_id remote_account_number) : qw(purpose); return normalize_text(join '/', map { $_ // '' } ($transaction->{local_bank_account_id}, $transaction->{transdate}->ymd, $transaction->{valutadate}->ymd, (apply { s{0+$}{} } $transaction->{amount} * 1), - $transaction->{purpose})); + map { $transaction->{$_} } @other_fields)); } sub init_bank_accounts {