die t8("missing file for action import") unless ($::form->{file});
my $filename= $::form->{ATTACHMENTS}{file}{filename};
die t8("missing file for action import") unless ($::form->{file});
my $filename= $::form->{ATTACHMENTS}{file}{filename};
# check name and first fields of CSV data
die t8("Wrong file name, expects name like: DTVF_*_LOHNBUCHUNG*.csv") unless $filename =~ /^DTVF_.*_LOHNBUCHUNGEN_LUG.*\.csv$/;
# check name and first fields of CSV data
die t8("Wrong file name, expects name like: DTVF_*_LOHNBUCHUNG*.csv") unless $filename =~ /^DTVF_.*_LOHNBUCHUNGEN_LUG.*\.csv$/;
die t8("not a valid DTVF file, expected field header start with 'Umsatz; (..) ;Konto;Gegenkonto'")
unless ($::form->{file} =~ m/Umsatz;S\/H;;;;;Konto;Gegenkonto.*;;Belegdatum;Belegfeld 1;Belegfeld 2;;Buchungstext/);
# check if file is already imported
die t8("not a valid DTVF file, expected field header start with 'Umsatz; (..) ;Konto;Gegenkonto'")
unless ($::form->{file} =~ m/Umsatz;S\/H;;;;;Konto;Gegenkonto.*;;Belegdatum;Belegfeld 1;Belegfeld 2;;Buchungstext/);
# check if file is already imported
- my $acc_trans_doc = SL::DB::Manager::AccTransaction->get_first(source => $filename);
- die t8("Already imported") if ref $acc_trans_doc eq 'SL::DB::AccTransaction';
+ my $acc_trans_doc = SL::DB::Manager::AccTransaction->get_first(query => [ source => $filename ]);
+ die t8("Already imported: ") . $acc_trans_doc->source if ref $acc_trans_doc eq 'SL::DB::AccTransaction';
# Read/parse CSV
# Umsatz S/H Konto Gegenkonto (ohne BU-Schlüssel) Belegdatum Belegfeld 1 Belegfeld 2 Buchungstext
my $year = substr($csv->getline($fh)->[12], 0, 4);
# Read/parse CSV
# Umsatz S/H Konto Gegenkonto (ohne BU-Schlüssel) Belegdatum Belegfeld 1 Belegfeld 2 Buchungstext
my $year = substr($csv->getline($fh)->[12], 0, 4);
if ($::instance_conf->get_doc_storage) {
my $file = SL::File->save(object_id => $current_transaction->id,
if ($::instance_conf->get_doc_storage) {
my $file = SL::File->save(object_id => $current_transaction->id,
source => 'uploaded',
file_type => 'attachment',
file_name => $::form->{ATTACHMENTS}{file}{filename},
source => 'uploaded',
file_type => 'attachment',
file_name => $::form->{ATTACHMENTS}{file}{filename},