From 34d2f9da09e77fee134bf138c1fff801b28990ec Mon Sep 17 00:00:00 2001 From: Werner Hahn Date: Sat, 5 Feb 2022 07:04:43 +0100 Subject: [PATCH] MassRecordCreationAndPrinting: Shopstatus setzen --- .../MassRecordCreationAndPrinting.pm | 14 ++++++++++++++ SL/Controller/MassInvoiceCreatePrint.pm | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/SL/BackgroundJob/MassRecordCreationAndPrinting.pm b/SL/BackgroundJob/MassRecordCreationAndPrinting.pm index 0ab03bd4e..371e587f7 100644 --- a/SL/BackgroundJob/MassRecordCreationAndPrinting.pm +++ b/SL/BackgroundJob/MassRecordCreationAndPrinting.pm @@ -55,6 +55,20 @@ sub create_invoices { my $invoice = $sales_delivery_order->convert_to_invoice(%conversion_params); die $db->error if !$invoice; + # 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; diff --git a/SL/Controller/MassInvoiceCreatePrint.pm b/SL/Controller/MassInvoiceCreatePrint.pm index acc300e0a..098126015 100644 --- a/SL/Controller/MassInvoiceCreatePrint.pm +++ b/SL/Controller/MassInvoiceCreatePrint.pm @@ -83,6 +83,23 @@ sub action_create_invoices { $::form->error($db->error); } + foreach my $invoice( @invoices ) { + # 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"); + } + } + my $key = sprintf('%d-%d', Time::HiRes::gettimeofday()); $::auth->set_session_value("MassInvoiceCreatePrint::ids-${key}" => [ map { $_->id } @invoices ]); -- 2.20.1