Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 14304a6a

Von Martin Helmling martin.helmling@octosoft.eu vor etwa 8 Jahren hinzugefügt

  • ID 14304a6a27f1057646fc088364fd4625c24860dd
  • Vorgänger 4a42f524
  • Nachfolger 3b263d51

MT940-Import: Transaktionstype mit in BankTransaction

Eine Erweiterung um z.B. Sammellastschriften zu erkennen
Dazu wurde ein eigenes Importprofil für aqbanking-cli erstellt
und die Tabelle bank_transactions erweitert.

Das Profile ist in users/aqbanking.conf

Unterschiede anzeigen:

SL/Controller/CsvImport/BankTransaction.pm
88 88

  
89 89
  $self->SUPER::setup_displayable_columns;
90 90

  
91
  # TODO: don't show fields cleared, invoice_amount and transaction_id in the help text, as these should not be imported
92 91
  $self->add_displayable_columns({ name => 'local_bank_code',       description => $::locale->text('Own bank code') },
93 92
                                 { name => 'local_account_number',  description => $::locale->text('Own bank account number or IBAN') },
94 93
                                 { name => 'local_bank_account_id', description => $::locale->text('ID of own bank account') },
......
101 100
                                 { name => 'currency_id',           description => $::locale->text('Currency (database ID)')          },
102 101
                                 { name => 'remote_name',           description => $::locale->text('Name of the goal/source (if field names remote_name and remote_name_1 exist they will be combined into field "remote_name")') },
103 102
                                 { name => 'purpose',               description => $::locale->text('Purpose (if field names purpose, purpose1, purpose2 ... exist they will all combined into the field "purpose")') },
103
                                 { name => 'transactionCode',       description => $::locale->text('Transaction Code') },
104
                                 { name => 'transactionText',       description => $::locale->text('Transaction Text') },
104 105
                                 );
105 106
}
106 107

  
......
148 149
    $object->local_bank_account_id($bank_account->id);
149 150
    $entry->{info_data}->{local_bank_name} = $bank_account->name;
150 151
  }
151

  
152 152
  return $object->local_bank_account_id ? 1 : 0;
153 153
}
154 154

  
SL/DB/MetaSetup/BankTransaction.pm
21 21
  remote_bank_code      => { type => 'text' },
22 22
  remote_name           => { type => 'text' },
23 23
  transaction_id        => { type => 'integer' },
24
  transactioncode       => { type => 'text' },
25
  transactiontext       => { type => 'text' },
24 26
  transdate             => { type => 'date', not_null => 1 },
25 27
  valutadate            => { type => 'date', not_null => 1 },
26 28
);
SL/Helper/MT940.pm
1 1
package SL::Helper::MT940;
2 2

  
3 3
use strict;
4
use File::Path qw(mkpath);
5
use File::Copy qw(copy);
4 6

  
5 7
sub convert_mt940_data {
6 8
  my ($mt940_data) = @_;
......
13 15
  $sfile->fh->print($mt940_data);
14 16
  $sfile->fh->close;
15 17

  
18
  my $todir = $sfile->get_path . '/imexporters/csv/profiles';
19
  mkpath $todir;
20
  File::Copy::copy('users/aqbanking.conf', $todir.'/kivi.conf');
21

  
16 22
  my $aqbin = $::lx_office_conf{applications}->{aqbanking};
17 23
  die "Can't find aqbanking-cli, please check your configuration file.\n" unless -f $aqbin;
18
  my $cmd = "$aqbin --cfgdir=\"" . $sfile->get_path . "\" import --importer=\"swift\" --profile=\"SWIFT-MT940\" -f " . $sfile->get_path . "/$import_filename | $aqbin --cfgdir=\"" . $sfile->get_path . "\" listtrans --exporter=\"csv\" --profile=\"AqMoney2\" ";
24
  my $cmd = "$aqbin --cfgdir=\"" . $sfile->get_path . "\" import --importer=\"swift\" --profile=\"SWIFT-MT940\" -f " .
25
          $sfile->get_path . "/$import_filename | $aqbin --cfgdir=\"" . $sfile->get_path . "\" listtrans --exporter=\"csv\" --profile=kivi 2> /dev/null ";
19 26

  
20
  my $converted_data = '"empty";"local_bank_code";"local_account_number";"remote_bank_code";"remote_account_number";"transdate";"valutadate";"amount";"currency";"remote_name";"remote_name_1";"purpose";"purpose1";"purpose2";"purpose3";"purpose4";"purpose5";"purpose6";"purpose7";"purpose8";"purpose9";"purpose10";"purpose11"' . "\n";
27
  my $converted_data = '"empty";"local_bank_code";"local_account_number";"remote_bank_code";"remote_account_number";"transdate";"valutadate";"amount";'.
28
    '"currency";"remote_name";"remote_name_1";"purpose";"purpose1";"purpose2";"purpose3";"purpose4";"purpose5";"purpose6";"purpose7";"purpose8";"purpose9";'.
29
    '"purpose10";"purpose11";"transactionKey";"customerReference";"bankReference";"transactionCode";"transactionText"'."\n";
21 30

  
22 31
  open my $mt, "-|", "$cmd" || die "Problem with executing aqbanking\n";
23 32
  my $headerline = <$mt>;  # discard original aqbanking header line
locale/de/all
3187 3187
  'Trans Type'                  => 'Transfertyp',
3188 3188
  'Transaction'                 => 'Buchung',
3189 3189
  'Transaction %d cancelled.'   => 'Buchung %d erfolgreich storniert.',
3190
  'Transaction Code'            => 'Transaktionscode',
3190 3191
  'Transaction Date missing!'   => 'Buchungsdatum fehlt!',
3191 3192
  'Transaction ID missing.'     => 'Die Buchungs-ID fehlt.',
3193
  'Transaction Text'            => 'Transaktionstext',
3192 3194
  'Transaction deleted!'        => 'Buchung gelöscht!',
3193 3195
  'Transaction description'     => 'Vorgangsbezeichnung',
3194 3196
  'Transaction has already been cancelled!' => 'Diese Buchung wurde bereits storniert.',
sql/Pg-upgrade2/bank_transactions_type.sql
1
-- @tag: bank_transactions_type
2
-- @description: Erweitern der Tabelle bank_transactions mit Typ der Transaktion.
3
-- @depends: bank_transactions
4

  
5
ALTER TABLE bank_transactions ADD COLUMN transactionCode TEXT;
6
ALTER TABLE bank_transactions ADD COLUMN transactionText TEXT;
users/aqbanking.conf
1

  
2
char name="kivi"
3
char shortDescr="Profile for kivitendo CSV files"
4
char version="5.6.4"
5
char longDescr="This profile supports the CSV format used by AqMoney2"
6
int import="1"
7
int export="1"
8

  
9
char type="csv"
10
char groupNames="transaction", "transfer", "debitnote", "line"
11
char dateFormat="YYYYMMDD"
12
int utc="0"
13

  
14
params {
15
  # if 1 then values are quoted
16
  quote="1"
17
  
18
  # if 1 then a title line will be written containing the names of each
19
  # column
20
  title="1"
21
  
22
  # special values are "TAB" and "SPACE"
23
  delimiter=";" 
24
  
25
  # this is the group name looked for in the given data to GWEN_CSV_Write
26
  # if not given then all groups match
27
  #group="transaction"
28
  
29
  # this group contains the definition for each column
30
  # each variable in this group has its number as name
31
  # you can use index variables in the names (using square brackets)
32
  # the value of each of these variables is the name of a variable to be looked
33
  # up in the data given to GWEN_CSV_Write
34
  columns {
35
    1="empty"
36
    2="localBankCode"
37
    3="localAccountNumber"
38
    4="remoteBankCode"
39
    5="remoteAccountNumber"
40
    6="date"
41
    7="valutadate"
42
    8="value/value"
43
    9="value/currency"
44
    10="remoteName[0]"
45
    11="remoteName[1]"
46
    12="purpose[0]"
47
    13="purpose[1]"
48
    14="purpose[2]"
49
    15="purpose[3]"
50
    16="purpose[4]"
51
    17="purpose[5]"
52
    18="purpose[6]"
53
    19="purpose[7]"
54
    20="purpose[8]"
55
    21="purpose[9]"
56
    22="purpose[10]"
57
    23="purpose[11]"
58
    24="transactionKey"
59
    25="customerReference"
60
    26="bankReference"
61
    27="transactionCode"
62
    28="transactionText"
63
  } # columns
64

  
65
} # params
66

  

Auch abrufbar als: Unified diff