From b9436847a02c9f8c58383a8a3a1d64ce055ec35d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20B=C3=BCren?= Date: Mon, 19 Nov 2018 11:26:38 +0100 Subject: [PATCH] CreatePeriodicInvoices: Transaktionssicher MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Aufträge verarbeiten, Rechnungen erzeugen, Drucken und E-Mail-Versand in einer Transaktion --- SL/BackgroundJob/CreatePeriodicInvoices.pm | 8 ++++++++ 1 file changed, 8 insertions(+) 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"); -- 2.20.1