X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FBackgroundJob%2FCreatePeriodicInvoices.pm;h=22f9bf985eaa84cb018475bfa4d3b5351ec287f7;hb=5737ce39a18326f1c3ae70a5afcc2d494fb901c7;hp=55c53aac285b632fd2ac651ded7a656630b3b3be;hpb=02b714e791e082d96a723649747103f05c256a25;p=kivitendo-erp.git diff --git a/SL/BackgroundJob/CreatePeriodicInvoices.pm b/SL/BackgroundJob/CreatePeriodicInvoices.pm index 55c53aac2..22f9bf985 100644 --- a/SL/BackgroundJob/CreatePeriodicInvoices.pm +++ b/SL/BackgroundJob/CreatePeriodicInvoices.pm @@ -75,7 +75,7 @@ sub run { ); if (@{ $self->{job_errors} }) { - my $msg = @{ $self->{job_errors} }; + my $msg = join "\n", @{ $self->{job_errors} }; _log_msg("Errors: $msg"); die $msg; } @@ -92,7 +92,7 @@ sub _log_msg { sub _generate_time_period_variables { my $config = shift; my $period_start_date = shift; - my $period_end_date = $period_start_date->clone->truncate(to => 'month')->add(months => $config->get_billing_period_length)->subtract(days => 1); + my $period_end_date = $period_start_date->clone->add(months => $config->get_billing_period_length)->subtract(days => 1); my @month_names = ('', $::locale->text('January'), $::locale->text('February'), $::locale->text('March'), $::locale->text('April'), $::locale->text('May'), $::locale->text('June'), @@ -115,8 +115,8 @@ sub _generate_time_period_variables { previous_year => [ $period_start_date->clone->truncate(to => 'year')->subtract(years => 1), sub { $_[0]->year } ], next_year => [ $period_start_date->clone->truncate(to => 'year')->add( years => 1), sub { $_[0]->year } ], - period_start_date => [ $period_start_date->clone->truncate(to => 'month'), sub { $::locale->format_date(\%::myconfig, $_[0]) } ], - period_end_date => [ $period_end_date, sub { $::locale->format_date(\%::myconfig, $_[0]) } ], + period_start_date => [ $period_start_date->clone, sub { $::locale->format_date(\%::myconfig, $_[0]) } ], + period_end_date => [ $period_end_date, sub { $::locale->format_date(\%::myconfig, $_[0]) } ], }; return $vars; @@ -205,7 +205,7 @@ sub _create_periodic_invoice { my $order = $config->order; my $invoice; - if (!$self->{db_obj}->db->do_transaction(sub { + if (!$self->{db_obj}->db->with_transaction(sub { 1; # make Emacs happy $invoice = SL::DB::Invoice->new_from($order); @@ -254,6 +254,8 @@ sub _create_periodic_invoice { _log_msg("_create_invoice created for period start date $period_start_date id " . $invoice->id . " number " . $invoice->invnumber . " netamount " . $invoice->netamount . " amount " . $invoice->amount); # die $invoice->transaction_description; + + 1; })) { $::lxdebug->message(LXDebug->WARN(), "_create_invoice failed: " . join("\n", (split(/\n/, $self->{db_obj}->db->error))[0..2])); return undef;