From 111861a55c8fefc7291cf5c28bb24f6a654d5939 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 5 Feb 2015 10:40:24 +0100 Subject: [PATCH] =?utf8?q?CreatePeriodicInvoices:=20refactoring=20der=20Pa?= =?utf8?q?rameter=C3=BCbergabe=20an=20=5Freplace=5Fvars?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/BackgroundJob/CreatePeriodicInvoices.pm | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/SL/BackgroundJob/CreatePeriodicInvoices.pm b/SL/BackgroundJob/CreatePeriodicInvoices.pm index 1abe8c36b..6624d6a3e 100644 --- a/SL/BackgroundJob/CreatePeriodicInvoices.pm +++ b/SL/BackgroundJob/CreatePeriodicInvoices.pm @@ -105,14 +105,13 @@ sub _generate_time_period_variables { } sub _replace_vars { - my $object = shift; - my $vars = shift; - my $sub = shift; - my $str = $object->$sub; + my (%params) = @_; + my $sub = $params{attribute}; + my $str = $params{object}->$sub; $str =~ s{ <\% ([a-z0-9_]+) ( \s+ format \s*=\s* (.*?) \s* )? \%>}{ my ($key, $format) = ($1, $3); - if (!$vars->{$key}) { + if (!$params{vars}->{$key}) { ''; } elsif ($format) { @@ -120,14 +119,14 @@ sub _replace_vars { pattern => $format, locale => 'de_DE', time_zone => 'local', - )->format_datetime($vars->{$key}->[0]); + )->format_datetime($params{vars}->{$key}->[0]); } else { - $vars->{$1}->[1]->($vars->{$1}->[0]); + $params{vars}->{$1}->[1]->($params{vars}->{$1}->[0]); } }eigx; - $object->$sub($str); + $params{object}->$sub($str); } sub _create_periodic_invoice { @@ -154,10 +153,10 @@ sub _create_periodic_invoice { employee => $order->employee, # new_from sets employee to import user ); - _replace_vars($invoice, $time_period_vars, $_) for qw(notes intnotes transaction_description); + _replace_vars(object => $invoice, vars => $time_period_vars, attribute => $_) for qw(notes intnotes transaction_description); foreach my $item (@{ $invoice->items }) { - _replace_vars($item, $time_period_vars, $_) for qw(description longdescription); + _replace_vars(object => $item, vars => $time_period_vars, attribute => $_) for qw(description longdescription); } $invoice->post(ar_id => $config->ar_chart_id) || die; -- 2.20.1