From b019bd393629352431702f8d0d9f122508ec56ca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Fri, 4 Dec 2015 16:43:14 +0100 Subject: [PATCH] GoBD: Bei unbalanced ledger Fehlern abbrechen und Fehler zeigen --- SL/Controller/GoBD.pm | 12 +++++++++++- SL/GoBD.pm | 4 ++++ locale/de/all | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/SL/Controller/GoBD.pm b/SL/Controller/GoBD.pm index 463c6d743..a151adb0c 100644 --- a/SL/Controller/GoBD.pm +++ b/SL/Controller/GoBD.pm @@ -35,6 +35,7 @@ sub action_export { return; } + my $filename; my $gobd = SL::GoBD->new( company => $::instance_conf->get_company, location => $::instance_conf->get_address, @@ -42,7 +43,16 @@ sub action_export { to => $self->to, ); - my $filename = $gobd->generate_export; + eval { + $filename = $gobd->generate_export; + } or do { + my $errors = $@; + flash('error', t8('The export failed because of malformed transactions. Please fix those before exporting.')); + + $::lxdebug->dump(0, "GoBD errors:", \@$errors); + $self->action_filter; + return; + }; $self->send_file($filename, name => t8('gobd-#1-#2.zip', $self->from->ymd, $self->to->ymd), unlink => 1); } diff --git a/SL/GoBD.pm b/SL/GoBD.pm index e8a055891..2992b5f4e 100644 --- a/SL/GoBD.pm +++ b/SL/GoBD.pm @@ -419,6 +419,10 @@ sub do_datev_csv_export { $datev->_get_transactions(from_to => $datev->fromto); + if ($datev->errors) { + die [ $datev->errors ]; + } + for my $transaction (@{ $datev->{DATEV} }) { for my $entry (@{ $transaction }) { $entry->{sortkey} = join '-', map { lc } (DateTime->from_kivitendo($entry->{transdate})->strftime('%Y%m%d'), $entry->{name}, $entry->{reference}); diff --git a/locale/de/all b/locale/de/all index 82715cf90..b4038f0c9 100755 --- a/locale/de/all +++ b/locale/de/all @@ -2904,6 +2904,7 @@ $self->{texts} = { 'The execution schedule is invalid.' => 'Der Ausführungszeitplan ist ungültig.', 'The execution type is invalid.' => 'Der Ausführungstyp ist ungültig.', 'The existing record has been created from the link target to add.' => 'Der bestehende Beleg wurde aus dem auszuwählenden Verknüpfungsziel erstellt.', + 'The export failed because of malformed transactions. Please fix those before exporting.' => 'Es sind fehlerhafte Buchungen im Exportzeitraum vorhanden. Bitte korrigieren Sie diese vor dem Export.', 'The factor is missing in row %d.' => 'Der Faktor fehlt in Zeile %d.', 'The factor is missing.' => 'Der Faktor fehlt.', 'The file has been sent to the printer.' => 'Die Datei wurde an den Drucker geschickt.', -- 2.20.1