From: Jan Büren Date: Mon, 19 Nov 2018 10:26:38 +0000 (+0100) Subject: CreatePeriodicInvoices: Transaktionssicher X-Git-Tag: release-3.5.4~215 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=b9436847a02c9f8c58383a8a3a1d64ce055ec35d;p=kivitendo-erp.git CreatePeriodicInvoices: Transaktionssicher Aufträge verarbeiten, Rechnungen erzeugen, Drucken und E-Mail-Versand in einer Transaktion --- diff --git a/SL/BackgroundJob/CreatePeriodicInvoices.pm b/SL/BackgroundJob/CreatePeriodicInvoices.pm index b7b3e3305..6cfdf94ff 100644 --- a/SL/BackgroundJob/CreatePeriodicInvoices.pm +++ b/SL/BackgroundJob/CreatePeriodicInvoices.pm @@ -28,6 +28,8 @@ sub run { $self->{db_obj} = shift; $self->{job_errors} = []; + if (!$self->{db_obj}->db->with_transaction(sub { + 1; # make Emacs happy my $configs = SL::DB::Manager::PeriodicInvoicesConfig->get_all(query => [ active => 1 ]); @@ -81,6 +83,12 @@ sub run { \@disabled_orders , ); + 1; + })) { + $::lxdebug->message(LXDebug->WARN(), "_create_invoice failed: " . join("\n", (split(/\n/, $self->{db_obj}->db->error))[0..2])); + return undef; + } + if (@{ $self->{job_errors} }) { my $msg = join "\n", @{ $self->{job_errors} }; _log_msg("Errors: $msg");