X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FBackgroundJob%2FMassRecordCreationAndPrinting.pm;h=16823dcbd02c94bafabb0eedb9527d3cd6867e30;hb=a5e4f9ca835489c2250db39f2c3abe6ac4ba04e6;hp=bd878384974408b5d779d7bbefe92f96c0eac066;hpb=ee75e5986c75b6cf9886bf315e83d05ae210add0;p=kivitendo-erp.git diff --git a/SL/BackgroundJob/MassRecordCreationAndPrinting.pm b/SL/BackgroundJob/MassRecordCreationAndPrinting.pm index bd8783849..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; @@ -185,16 +180,10 @@ sub print_pdfs { foreach my $local_printer_id ($printer_id, $copy_printer_id) { next unless $local_printer_id; - my $printer = SL::DB::Printer->new(id => $local_printer_id)->load; - my $command = SL::Template::create(type => 'ShellCommand', form => Form->new(''))->parse($printer->printer_command); - if (!open $out, '|-', $command) { - push @{ $data->{print_errors} }, { message => $::locale->text('Could not execute printer command: #1', $!) }; - $job_obj->update_attributes(data_as_hash => $data); - return; - } - binmode $out; - print $out $self->{merged_pdf}; - close $out; + SL::DB::Printer + ->new(id => $local_printer_id) + ->load + ->print_document(content => $self->{merged_pdf}); } }