Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 47326326

Von Tamino Steinert vor 24 Tagen hinzugefügt

  • ID 4732632672bed462ccb3763c950a67f9492e7fa7
  • Vorgänger 4a1385db
  • Nachfolger 5d3e8761

S:D:PeriodicInvoicesConfig: Helferfunk. add_month über Klasse aufrufbar

Unterschiede anzeigen:

SL/DB/PeriodicInvoicesConfig.pm
42 42
    my $new_order = clone($orig_order);
43 43
    $new_order->reqdate($period_start_date);
44 44
    $new_order->tax_point(
45
      add_months(
45
      $self->add_months(
46 46
        $period_start_date, $self->get_billing_period_length || $self->get_order_value_period_length || 1
47 47
      )->add(days => -1)
48 48
    );
......
94 94
        || $self->first_billing_date || $self->start_date;
95 95
      my @dates = $self->calculate_invoice_dates(
96 96
        start_date => $start_date,
97
        end_date => add_months($start_date, $b_period),
97
        end_date => $self->add_months($start_date, $b_period),
98 98
      );
99 99
      my $once_date = scalar @dates ? $dates[0] : undef;
100 100
      return if $period_start_date != $once_date;
......
116 116
      my $periods = $max_periods;
117 117
      if ($item_config->start_date) {
118 118
        $periods-- while $periods > 0
119
          && add_months($period_start_date, -1 * ($periods - 1) * $i_period) < $item_config->start_date;
119
          && $self->add_months($period_start_date, -1 * ($periods - 1) * $i_period) < $item_config->start_date;
120 120
      }
121 121
      if ($item_config->end_date) {
122 122
        my $periods_from_end = 0;
123 123
        $periods_from_end++ while $periods_from_end < $periods
124
          && add_months($period_start_date, -1 * ($periods_from_end)) > $item_config->end_date;
124
          && $self->add_months($period_start_date, -1 * ($periods_from_end)) > $item_config->end_date;
125 125
        $periods -= $periods_from_end;
126 126
      }
127 127
      return if $periods == 0;
......
201 201

  
202 202
    my $month_to_start = $start_date->year * 12 + $start_date->month - $months_first_period;
203 203
    $month_to_start += 1
204
      if add_months($first_period_start_date, $month_to_start) < $start_date;
204
      if $self->add_months($first_period_start_date, $month_to_start) < $start_date;
205 205

  
206 206
    my $month_after_last_created = 0;
207 207
    if ($last_created_on_date) {
208 208
      $month_after_last_created =
209 209
        $last_created_on_date->year * 12 + $last_created_on_date->month - $months_first_period;
210 210
      $month_after_last_created += 1
211
        if add_months($first_period_start_date, $month_after_last_created) <= $last_created_on_date;
211
        if $self->add_months($first_period_start_date, $month_after_last_created) <= $last_created_on_date;
212 212
    }
213 213

  
214 214
    my $months_from_period_start = max(
......
219 219
    my $period_count = int($months_from_period_start / $billing_period_length); # floor
220 220
    $period_count += $months_from_period_start % $billing_period_length != 0 ? 1 : 0; # ceil
221 221

  
222
    my $next_period_start_date = add_months($first_period_start_date, $period_count * $billing_period_length);
222
    my $next_period_start_date = $self->add_months($first_period_start_date, $period_count * $billing_period_length);
223 223
    while ($next_period_start_date <= $end_date) {
224 224
      push @start_dates, $next_period_start_date;
225 225
      $period_count++;
226
      $next_period_start_date = add_months($first_period_start_date, $period_count * $billing_period_length);
226
      $next_period_start_date = $self->add_months($first_period_start_date, $period_count * $billing_period_length);
227 227
    }
228 228
  } else { # single
229 229
    push @start_dates, $first_period_start_date
......
247 247
}
248 248

  
249 249
sub add_months {
250
  my ($date, $months) = @_;
250
  my ($self, $date, $months) = @_;
251 251

  
252 252
  my $start_months_of_date = $date->month;
253 253
  $date = $date->clone();
......
285 285
      $active = 1;
286 286

  
287 287
      my $end_date = $self->end_date;
288
      $end_date = add_months($end_date, $self->extend_automatically_by) while $today > $end_date;
288
      $end_date = $self->add_months($end_date, $self->extend_automatically_by) while $today > $end_date;
289 289
      _log_msg("HAE for " . $self->id . " from " . $self->end_date . " to " . $end_date . " on " . $today . "\n");
290 290
      $self->update_attributes(end_date => $end_date);
291 291
    }
......
302 302
        $active = 1;
303 303

  
304 304
        my $end_date = $item_config->end_date;
305
        $end_date = add_months($end_date, $item_config->extend_automatically_by) while $today > $end_date;
305
        $end_date = $self->add_months($end_date, $item_config->extend_automatically_by) while $today > $end_date;
306 306
        _log_msg("HAE for item " . $item->id . " from " . $item_config->end_date . " to " . $end_date . " on " . $today . "\n");
307 307
        $item_config->update_attributes(end_date => $end_date);
308 308
      }

Auch abrufbar als: Unified diff