X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/f08036d731f13eb80ac63b951b1c9da77693867a..aeeea53192101dd80e4f3a5fae86b0e979bff1e5:/SL/BackgroundJob/MassRecordCreationAndPrinting.pm diff --git a/SL/BackgroundJob/MassRecordCreationAndPrinting.pm b/SL/BackgroundJob/MassRecordCreationAndPrinting.pm index e4c75b812..16823dcbd 100644 --- a/SL/BackgroundJob/MassRecordCreationAndPrinting.pm +++ b/SL/BackgroundJob/MassRecordCreationAndPrinting.pm @@ -46,17 +46,12 @@ sub create_invoices { my $data = $job_obj->data_as_hash; eval { - my $invoice; my $sales_delivery_order = SL::DB::DeliveryOrder->new(id => $delivery_order_id)->load; $number = $sales_delivery_order->donumber; + my %conversion_params = $data->{transdate} ? ('attributes' => { transdate => $data->{transdate} }) : (); + my $invoice = $sales_delivery_order->convert_to_invoice(%conversion_params); - if (!$db->do_transaction(sub { - $invoice = $sales_delivery_order->convert_to_invoice(sub { $data->{transdate} ? ('attributes' => { transdate => $data->{transdate} }) : - undef }->() ) || die $db->error; - 1; - })) { - die $db->error; - } + die $db->error if !$invoice; $data->{num_created}++; push @{ $data->{invoice_ids} }, $invoice->id;