From 1baea8cb6d9de284e35c8dc981c7a9559e9e9888 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 10 Nov 2020 11:38:12 +0100 Subject: [PATCH] Leistungsdatum: wiederkehrende Rechnungen --- SL/BackgroundJob/CreatePeriodicInvoices.pm | 7 +++++++ SL/DB/Helper/FlattenToForm.pm | 2 +- SL/DB/Invoice.pm | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/SL/BackgroundJob/CreatePeriodicInvoices.pm b/SL/BackgroundJob/CreatePeriodicInvoices.pm index 52415f20e..f7b9100ad 100644 --- a/SL/BackgroundJob/CreatePeriodicInvoices.pm +++ b/SL/BackgroundJob/CreatePeriodicInvoices.pm @@ -224,10 +224,17 @@ sub _create_periodic_invoice { $invoice = SL::DB::Invoice->new_from($order); + my $tax_point = ($invoice->tax_point // $time_period_vars->{period_end_date}->[0])->clone; + + while ($tax_point < $period_start_date) { + $tax_point->add(months => $config->get_billing_period_length); + } + my $intnotes = $invoice->intnotes ? $invoice->intnotes . "\n\n" : ''; $intnotes .= "Automatisch am " . $invdate->to_lxoffice . " erzeugte Rechnung"; $invoice->assign_attributes(deliverydate => $period_start_date, + tax_point => $tax_point, intnotes => $intnotes, employee => $order->employee, # new_from sets employee to import user direct_debit => $config->direct_debit, diff --git a/SL/DB/Helper/FlattenToForm.pm b/SL/DB/Helper/FlattenToForm.pm index 7c001af88..5ba2f3d57 100644 --- a/SL/DB/Helper/FlattenToForm.pm +++ b/SL/DB/Helper/FlattenToForm.pm @@ -15,7 +15,7 @@ sub flatten_to_form { _copy($self, $form, '', '', 0, qw(id type taxzone_id ordnumber quonumber invnumber donumber cusordnumber taxincluded shippingpoint shipvia notes intnotes cp_id employee_id salesman_id closed department_id language_id payment_id delivery_customer_id delivery_vendor_id shipto_id proforma globalproject_id delivered transaction_description container_type accepted_by_customer invoice storno storno_id dunning_config_id - orddate quodate reqdate gldate duedate deliverydate datepaid transdate delivery_term_id)); + orddate quodate reqdate gldate duedate deliverydate datepaid transdate tax_point delivery_term_id)); $form->{currency} = $form->{curr} = $self->currency_id ? $self->currency->name || '' : ''; if ( $vc eq 'customer' ) { diff --git a/SL/DB/Invoice.pm b/SL/DB/Invoice.pm index 0a6079885..23847553d 100644 --- a/SL/DB/Invoice.pm +++ b/SL/DB/Invoice.pm @@ -156,7 +156,7 @@ sub new_from { my (@columns, @item_columns, $item_parent_id_column, $item_parent_column); if (ref($source) eq 'SL::DB::Order') { - @columns = qw(quonumber delivery_customer_id delivery_vendor_id); + @columns = qw(quonumber delivery_customer_id delivery_vendor_id tax_point); @item_columns = qw(subtotal); $item_parent_id_column = 'trans_id'; -- 2.20.1