Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b2224ef6

Von Jan Büren vor 11 Tagen hinzugefügt

  • ID b2224ef63731696a0ca2d16c2197554b36930738
  • Vorgänger 64a0ac19
  • Nachfolger 2981c916

SetNumberRange: Neuer Parameter current_year, falls der Job am 01.01. ...

Unterschiede anzeigen:

SL/BackgroundJob/SetNumberRange.pm
23 23
  if ($data->{multiplier}  && !($data->{multiplier} % 10 == 0)) {
24 24
    die "No valid input for multiplier should be 10, 100, .., 1000000";
25 25
  }
26
  my $next_year  = DateTime->today_local->truncate(to => 'year')->add(years => 1)->year();
27
  $next_year     = ($data->{digits_year} == 2) ? substr($next_year, 2, 2) : $next_year;
26

  
27
  my $running_year  =  $data->{current_year} ? DateTime->today_local->truncate(to => 'year')
28
                     : DateTime->today_local->truncate(to => 'year')->add(years => 1)->year();
29

  
30
  $running_year     = ($data->{digits_year} == 2) ? substr($running_year, 2, 2) : $running_year;
31

  
28 32
  my $multiplier = $data->{multiplier} || 100;
29 33

  
30 34
  my $defaults   = SL::DB::Default->get;
31 35

  
32 36
  foreach (qw(invnumber cnnumber soinumber pqinumber sonumber ponumber pocnumber sqnumber rfqnumber sdonumber pdonumber)) {
33 37
    my $current_number = SL::PrefixedNumber->new(number => $defaults->{$_});
34
    $current_number->set_to($next_year * $multiplier);
38
    $current_number->set_to($running_year * $multiplier);
35 39
    $defaults->{$_} = $current_number->get_current;
36 40
  }
37 41
  $defaults->save() || die "Could not change number ranges";

Auch abrufbar als: Unified diff