From e0fb092b1a1ac0429036b41abc0a85a011e0d9a8 Mon Sep 17 00:00:00 2001 From: Werner Hahn Date: Sat, 5 Feb 2022 08:41:58 +0100 Subject: [PATCH] MassRecordCreationAndPrinting - MassInvoiceCreatePrint: Auftrag schliessen --- SL/BackgroundJob/MassRecordCreationAndPrinting.pm | 7 +++++++ SL/Controller/MassInvoiceCreatePrint.pm | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/SL/BackgroundJob/MassRecordCreationAndPrinting.pm b/SL/BackgroundJob/MassRecordCreationAndPrinting.pm index 371e587f7..ebd20e13e 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 = SL::DB->client->dbh; $job_obj->set_data(status => CONVERTING_DELIVERY_ORDERS())->save; @@ -55,6 +57,11 @@ sub create_invoices { my $invoice = $sales_delivery_order->convert_to_invoice(%conversion_params); 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', diff --git a/SL/Controller/MassInvoiceCreatePrint.pm b/SL/Controller/MassInvoiceCreatePrint.pm index 098126015..bfaf0a290 100644 --- a/SL/Controller/MassInvoiceCreatePrint.pm +++ b/SL/Controller/MassInvoiceCreatePrint.pm @@ -19,6 +19,7 @@ use SL::Helper::File qw(store_pdf append_general_pdf_attachments doc_storage_ena use SL::Helper::Flash; use SL::Locale::String; use SL::SessionFile; +use SL::ARAP; use SL::System::TaskServer; use Rose::Object::MakeMethods::Generic ( @@ -57,6 +58,7 @@ sub action_create_invoices { } my $db = SL::DB::Invoice->new->db; + my $dbh = SL::DB->client->dbh; my @invoices; my @already_closed_delivery_orders; @@ -73,6 +75,11 @@ sub action_create_invoices { } else { my $invoice = $delivery_order->convert_to_invoice() || die $db->error; + + ARAP->close_orders_if_billed('dbh' => $dbh, + 'arap_id' => $invoice->id, + 'table' => 'ar',); + push @invoices, $invoice; } } -- 2.20.1