Merge branch 'pflichtenhefte'
[kivitendo-erp.git] / SL / BackgroundJob / CreatePeriodicInvoices.pm
index ccb0b27..dc740cc 100644 (file)
@@ -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->add(days => 1));
 }
 
 sub _send_email {