X-Git-Url: http://wagnertech.de/git?p=kivitendo-erp.git;a=blobdiff_plain;f=SL%2FBackgroundJob%2FMassRecordCreationAndPrinting.pm;fp=SL%2FBackgroundJob%2FMassRecordCreationAndPrinting.pm;h=4cc2519d50a32d489e8232eb3cbe7b0534265b9e;hp=0ab03bd4e97914450284b8e45692c99090cfd533;hb=b293ff8ad52fc76ba0c44783e3982418114d6b08;hpb=d4925a8b60f04674885e30d9316dc0263f8b9a84 diff --git a/SL/BackgroundJob/MassRecordCreationAndPrinting.pm b/SL/BackgroundJob/MassRecordCreationAndPrinting.pm index 0ab03bd4e..4cc2519d5 100644 --- a/SL/BackgroundJob/MassRecordCreationAndPrinting.pm +++ b/SL/BackgroundJob/MassRecordCreationAndPrinting.pm @@ -11,6 +11,7 @@ use SL::DB::Invoice; use SL::DB::Printer; use SL::SessionFile; use SL::Template; +use SL::ARAP; use SL::Locale::String qw(t8); use SL::Helper::MassPrintCreatePDF qw(:all); use SL::Helper::CreatePDF qw(:all); @@ -41,6 +42,7 @@ sub create_invoices { my $job_obj = $self->{job_obj}; my $db = $job_obj->db; + my $dbh = $db->dbh; $job_obj->set_data(status => CONVERTING_DELIVERY_ORDERS())->save; @@ -56,6 +58,25 @@ sub create_invoices { die $db->error if !$invoice; + ARAP->close_orders_if_billed('dbh' => $dbh, + 'arap_id' => $invoice->id, + 'table' => 'ar',); + + # update shop status + my @linked_shop_orders = $invoice->linked_records( + from => 'ShopOrder', + via => [ 'DeliveryOrder', 'Order' ], + ); + #if (scalar @linked_shop_orders[0][0] >= 1){ + #do update + my $shop_order = $linked_shop_orders[0][0]; + if ($shop_order){ + require SL::Shop; + my $shop_config = SL::DB::Manager::Shop->get_first( query => [ id => $shop_order->shop_id ] ); + my $shop = SL::Shop->new( config => $shop_config ); + $shop->connector->set_orderstatus($shop_order->shop_trans_id, "completed"); + } + $data->{num_created}++; push @{ $data->{invoice_ids} }, $invoice->id; push @{ $self->{invoices} }, $invoice;