Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 111861a5

Von Moritz Bunkus vor fast 10 Jahren hinzugefügt

  • ID 111861a55c8fefc7291cf5c28bb24f6a654d5939
  • Vorgänger a94080db
  • Nachfolger 8abdaf40

CreatePeriodicInvoices: refactoring der Parameterübergabe an _replace_vars

Unterschiede anzeigen:

SL/BackgroundJob/CreatePeriodicInvoices.pm
105 105
}
106 106

  
107 107
sub _replace_vars {
108
  my $object = shift;
109
  my $vars   = shift;
110
  my $sub    = shift;
111
  my $str    = $object->$sub;
108
  my (%params) = @_;
109
  my $sub      = $params{attribute};
110
  my $str      = $params{object}->$sub;
112 111

  
113 112
  $str =~ s{ <\% ([a-z0-9_]+) ( \s+ format \s*=\s* (.*?) \s* )? \%>}{
114 113
    my ($key, $format) = ($1, $3);
115
    if (!$vars->{$key}) {
114
    if (!$params{vars}->{$key}) {
116 115
      '';
117 116

  
118 117
    } elsif ($format) {
......
120 119
        pattern     => $format,
121 120
        locale      => 'de_DE',
122 121
        time_zone   => 'local',
123
      )->format_datetime($vars->{$key}->[0]);
122
      )->format_datetime($params{vars}->{$key}->[0]);
124 123

  
125 124
    } else {
126
      $vars->{$1}->[1]->($vars->{$1}->[0]);
125
      $params{vars}->{$1}->[1]->($params{vars}->{$1}->[0]);
127 126
    }
128 127
  }eigx;
129 128

  
130
  $object->$sub($str);
129
  $params{object}->$sub($str);
131 130
}
132 131

  
133 132
sub _create_periodic_invoice {
......
154 153
                                employee     => $order->employee, # new_from sets employee to import user
155 154
                               );
156 155

  
157
    _replace_vars($invoice, $time_period_vars, $_) for qw(notes intnotes transaction_description);
156
    _replace_vars(object => $invoice, vars => $time_period_vars, attribute => $_) for qw(notes intnotes transaction_description);
158 157

  
159 158
    foreach my $item (@{ $invoice->items }) {
160
      _replace_vars($item, $time_period_vars, $_) for qw(description longdescription);
159
      _replace_vars(object => $item, vars => $time_period_vars, attribute => $_) for qw(description longdescription);
161 160
    }
162 161

  
163 162
    $invoice->post(ar_id => $config->ar_chart_id) || die;

Auch abrufbar als: Unified diff