Revision e4783220
Von Moritz Bunkus vor mehr als 4 Jahren hinzugefügt
SL/Helper/MT940.pm | ||
---|---|---|
1 |
package SL::Helper::MT940; |
|
2 |
|
|
3 |
use strict; |
|
4 |
use File::Path qw(mkpath); |
|
5 |
use File::Copy qw(copy); |
|
6 |
|
|
7 |
sub convert_mt940_data { |
|
8 |
my ($mt940_data) = @_; |
|
9 |
|
|
10 |
# takes the data from an uploaded mt940 file, converts it to csv via aqbanking and returns the converted data |
|
11 |
# The uploaded file data is stored as a session file, just like the aqbanking settings file. |
|
12 |
|
|
13 |
my $import_filename = 'bank_transfer.940'; |
|
14 |
my $sfile = SL::SessionFile->new($import_filename, mode => '>'); |
|
15 |
$sfile->fh->print($mt940_data); |
|
16 |
$sfile->fh->close; |
|
17 |
|
|
18 |
# create needed dir structure for aqbanking 5.x and 6.x |
|
19 |
my $todir = $sfile->get_path . '/imexporters/csv/profiles'; |
|
20 |
mkpath $todir; |
|
21 |
die "Cannot create $todir" unless -d $todir; |
|
22 |
|
|
23 |
File::Copy::copy('users/aqbanking.conf', $todir.'/kivi.conf'); |
|
24 |
die "Cannot create local aqbanking conf " unless -f $todir.'/kivi.conf'; |
|
25 |
|
|
26 |
mkpath $sfile->get_path . '/settings6/aqbanking'; |
|
27 |
|
|
28 |
my $aqbin = $::lx_office_conf{applications}->{aqbanking}; |
|
29 |
die "Can't find aqbanking-cli, please check your configuration file.\n" unless -f $aqbin; |
|
30 |
my $cmd = "$aqbin --cfgdir=\"" . $sfile->get_path . "\" import --importer=\"swift\" --profile=\"SWIFT-MT940\" -f " . |
|
31 |
$sfile->get_path . "/$import_filename | $aqbin --cfgdir=\"" . $sfile->get_path . "\" export --profile=kivi 2> /dev/null "; |
|
32 |
|
|
33 |
my $converted_data = '"empty";"local_bank_code";"local_account_number";"remote_bank_code";"remote_account_number";"transdate";"valutadate";"amount";'. |
|
34 |
'"currency";"remote_name";"remote_name_1";"purpose";"purpose1";"purpose2";"purpose3";"purpose4";"purpose5";"purpose6";"purpose7";"purpose8";"purpose9";'. |
|
35 |
'"purpose10";"purpose11";"transaction_key";"customer_reference";"bank_reference";"transaction_code";"transaction_text"'."\n"; |
|
36 |
|
|
37 |
open my $mt, "-|", "$cmd" || die "Problem with executing aqbanking\n"; |
|
38 |
my $headerline = <$mt>; # discard original aqbanking header line |
|
39 |
while (<$mt>) { |
|
40 |
$converted_data .= $_; |
|
41 |
}; |
|
42 |
close $mt; |
|
43 |
return $converted_data; |
|
44 |
}; |
|
45 |
|
|
46 |
1; |
config/kivitendo.conf.default | ||
---|---|---|
172 | 172 |
# binary. |
173 | 173 |
python_uno = python |
174 | 174 |
|
175 |
# Location of the aqbanking binary to use when converting MT940 files |
|
176 |
# into the kivitendo import format |
|
177 |
aqbanking = /usr/bin/aqbanking-cli |
|
178 |
|
|
179 | 175 |
[environment] |
180 | 176 |
# Add the following paths to the PATH environment variable. |
181 | 177 |
path = /usr/local/bin:/usr/X11R6/bin:/usr/X11/bin |
doc/dokumentation.xml | ||
---|---|---|
430 | 430 |
libimage-info-perl libgd-gd2-perl libapache2-mod-fcgid \ |
431 | 431 |
libfile-copy-recursive-perl postgresql libalgorithm-checkdigits-perl \ |
432 | 432 |
libcrypt-pbkdf2-perl git libcgi-pm-perl libtext-unidecode-perl libwww-perl\ |
433 |
postgresql-contrib aqbanking-tools poppler-utils libhtml-restrict-perl\
|
|
433 |
postgresql-contrib poppler-utils libhtml-restrict-perl\ |
|
434 | 434 |
libdatetime-set-perl libset-infinite-perl liblist-utilsby-perl\ |
435 | 435 |
libdaemon-generic-perl libfile-flock-perl libfile-slurp-perl\ |
436 | 436 |
libfile-mimeinfo-perl libpbkdf2-tiny-perl libregexp-ipv6-perl \ |
... | ... | |
557 | 557 |
<title>Andere Pakete installieren</title> |
558 | 558 |
|
559 | 559 |
<itemizedlist> |
560 |
<listitem> |
|
561 |
<para><literal>aqbanking-tools</literal> Für das Parsen des MT940 Bankformats (Version 6 oder höher)</para> |
|
562 |
</listitem> |
|
563 | 560 |
<listitem> |
564 | 561 |
<para><literal>poppler-utils</literal> 'pdfinfo' zum Erkennen der Seitenanzahl bei der PDF-Generierung</para> |
565 | 562 |
</listitem> |
... | ... | |
567 | 564 |
<para><literal>Postgres Trigram-Index</literal> Für datenbankoptimierte Suchanfragen. Bspw. im Paket <literal>postgresql-contrib</literal> enthalten</para> |
568 | 565 |
</listitem> |
569 | 566 |
</itemizedlist> |
570 |
<para>Debian und Ubuntu: <programlisting>apt install aqbanking-tools postgresql-contrib poppler-utils</programlisting></para>
|
|
571 |
<para>Fedora: <programlisting>dnf install aqbanking poppler-utils postgresql-contrib</programlisting></para>
|
|
572 |
<para>openSUSE: <programlisting>zypper install aqbanking-tools poppler-tools</programlisting></para>
|
|
567 |
<para>Debian und Ubuntu: <programlisting>apt install postgresql-contrib poppler-utils</programlisting></para> |
|
568 |
<para>Fedora: <programlisting>dnf install poppler-utils postgresql-contrib</programlisting></para> |
|
569 |
<para>openSUSE: <programlisting>zypper install poppler-tools</programlisting></para> |
|
573 | 570 |
</sect2> |
574 | 571 |
</sect1> |
575 | 572 |
|
scripts/installation_check.pl | ||
---|---|---|
95 | 95 |
if ($check{o}) { |
96 | 96 |
print_header('Checking Optional Modules'); |
97 | 97 |
check_module($_, optional => 1) for @SL::InstallationCheck::optional_modules; |
98 |
check_aqbanking(); |
|
99 | 98 |
} |
100 | 99 |
if ($check{d}) { |
101 | 100 |
print_header('Checking Developer Modules'); |
... | ... | |
242 | 241 |
} |
243 | 242 |
} |
244 | 243 |
|
245 |
sub check_aqbanking { |
|
246 |
my $aqbin = $::lx_office_conf{applications}->{aqbanking}; |
|
247 |
if ( !$aqbin ) { |
|
248 |
print_line('Looking for aqbanking executable', 'not configured','red'); |
|
249 |
} |
|
250 |
else { |
|
251 |
my $line = "Looking for aqbanking executable '".$aqbin."'"; |
|
252 |
my $shell_out = `$aqbin versions 2>&1 | grep AqBanking-CLI 2> /dev/null`; |
|
253 |
my ($label,$version) = split /:/,$shell_out; |
|
254 |
if ( $label && $label eq ' AqBanking-CLI' ) { |
|
255 |
chop $version; |
|
256 |
my ($number_version) = $version =~ /(\d+)/; |
|
257 |
if ($number_version < 6) { |
|
258 |
print_line($line, "Requires at least version 6, current version is " . $version, 'red'); |
|
259 |
} else { |
|
260 |
print_line($line, $version, 'green'); |
|
261 |
} |
|
262 |
} else { |
|
263 |
print_line($line, 'not installed','red'); |
|
264 |
my %modinfo = ( name => 'aqbanking' ); |
|
265 |
push @missing_modules, \%modinfo; |
|
266 |
} |
|
267 |
} |
|
268 |
} |
|
269 |
|
|
270 | 244 |
sub check_module { |
271 | 245 |
my ($module, %role) = @_; |
272 | 246 |
|
Auch abrufbar als: Unified diff
MT940-Import: AQBanking-Unterstützung entfernt