Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision fde528b6

Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt

  • ID fde528b67be0e4375fdee44b2cadbfb7e0adadbd
  • Vorgänger a222e324
  • Nachfolger 1734e1ad

SL::DB::PeriodicInvoicesConfig: Datumsberechnung aus Backgroundjob verschoben

Unterschiede anzeigen:

SL/DB/PeriodicInvoicesConfig.pm
4 4

  
5 5
use SL::DB::MetaSetup::PeriodicInvoicesConfig;
6 6

  
7
use List::Util qw(max min);
8

  
7 9
__PACKAGE__->meta->initialize;
8 10

  
9 11
# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
......
74 76
  return ref $max_transdate ? $max_transdate : $self->db->parse_date($max_transdate);
75 77
}
76 78

  
79
sub calculate_invoice_dates {
80
  my ($self, %params) = @_;
81

  
82
  my $cur_date   = $self->first_billing_date        || $self->start_date;
83
  my $start_date = $self->get_previous_invoice_date || DateTime->new(year => 1970, month => 1, day => 1);
84
  my $end_date   = $self->end_date                  || DateTime->today_local->add(years => 10);
85
  my $period_len = $self->get_period_length;
86

  
87
  $start_date    = max($start_date, $params{start_date}) if $params{start_date};
88
  $end_date      = min($end_date,   $params{end_date})   if $params{end_date};
89

  
90
  my @dates;
91

  
92
  while ($cur_date < $end_date) {
93
    push @dates, $cur_date->clone if $cur_date > $start_date;
94

  
95
    $cur_date->add(months => $period_len);
96
  }
97

  
98
  return @dates;
99
}
100

  
77 101
1;

Auch abrufbar als: Unified diff