X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FBackgroundJob%2FCreatePeriodicInvoices.pm;h=18abf7c1adb6b4e98d500a7e70ef0d6ac9a5e498;hb=4bb9bf41d5f989445548e788c87699d27d8774da;hp=ccb0b27f0440c6a9e71448dbae244349f9af33f6;hpb=1ad7929fcdc527edd6ede82fa5afac798683074d;p=kivitendo-erp.git diff --git a/SL/BackgroundJob/CreatePeriodicInvoices.pm b/SL/BackgroundJob/CreatePeriodicInvoices.pm index ccb0b27f0..18abf7c1a 100644 --- a/SL/BackgroundJob/CreatePeriodicInvoices.pm +++ b/SL/BackgroundJob/CreatePeriodicInvoices.pm @@ -188,27 +188,8 @@ sub _create_periodic_invoice { } sub _calculate_dates { - my $config = shift; - - my $cur_date = $config->first_billing_date || $config->start_date; - my $start_date = $config->get_previous_invoice_date || DateTime->new(year => 1970, month => 1, day => 1); - my $end_date = $config->end_date || DateTime->new(year => 2100, month => 1, day => 1); - my $tomorrow = DateTime->today_local->add(days => 1); - my $period_len = $config->get_period_length; - - $end_date = $tomorrow if $end_date > $tomorrow; - - my @dates; - - while (1) { - last if $cur_date >= $end_date; - - push @dates, $cur_date->clone if $cur_date > $start_date; - - $cur_date->add(months => $period_len); - } - - return @dates; + my ($config) = @_; + return $config->calculate_invoice_dates(end_date => DateTime->today_local); } sub _send_email { @@ -232,7 +213,7 @@ sub _send_email { return unless $template; my $email_template = $config{periodic_invoices}->{email_template}; - my $filename = $email_template || ( (SL::DB::Default->get->templates || "templates/webpages") . "/periodic_invoices_email.txt" ); + my $filename = $email_template || ( (SL::DB::Default->get->templates || "templates/webpages") . "/oe/periodic_invoices_email.txt" ); my %params = ( POSTED_INVOICES => $posted_invoices, PRINTED_INVOICES => $printed_invoices );