From 662ded382ad646d46d1e2613df42ed35ee2f6265 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sven=20Sch=C3=B6ling?= Date: Tue, 20 Jul 2010 10:57:44 +0200 Subject: [PATCH] Globale Variablen entfernt/umgewandelt. Conflicts: bin/mozilla/ar.pl --- bin/mozilla/ap.pl | 4 +++- bin/mozilla/ar.pl | 2 ++ bin/mozilla/io.pl | 4 +--- bin/mozilla/is.pl | 8 +++----- bin/mozilla/rp.pl | 40 +++++++++++++++++++++------------------- 5 files changed, 30 insertions(+), 28 deletions(-) diff --git a/bin/mozilla/ap.pl b/bin/mozilla/ap.pl index c815dd0f1..ae2bda36b 100644 --- a/bin/mozilla/ap.pl +++ b/bin/mozilla/ap.pl @@ -972,6 +972,8 @@ sub post_payment { $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); + my $invdate = $form->datetonum($form->{transdate}, \%myconfig); + for my $i (1 .. $form->{paidaccounts}) { if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) { my $datepaid = $form->datetonum($form->{"datepaid_$i"}, \%myconfig); @@ -983,7 +985,7 @@ sub post_payment { if ($form->{defaultcurrency} && ($form->{currency} ne $form->{defaultcurrency})) { $form->{"exchangerate_$i"} = $form->{exchangerate} - if ($form->{transdate} == $datepaid); + if ($invdate == $datepaid); $form->isblank("exchangerate_$i", $locale->text('Exchangerate for payment missing!')); } diff --git a/bin/mozilla/ar.pl b/bin/mozilla/ar.pl index 158d82cfb..be99f5477 100644 --- a/bin/mozilla/ar.pl +++ b/bin/mozilla/ar.pl @@ -1035,6 +1035,8 @@ sub post_payment { $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); + my $invdate = $form->datetonum($form->{transdate}, \%myconfig); + for my $i (1 .. $form->{paidaccounts}) { if ($form->parse_amount(\%myconfig, $form->{"paid_$i"})) { diff --git a/bin/mozilla/io.pl b/bin/mozilla/io.pl index cd019264c..2bf8e0786 100644 --- a/bin/mozilla/io.pl +++ b/bin/mozilla/io.pl @@ -1952,13 +1952,11 @@ sub new_license { $form->{script} = "licenses.pl"; - our $name; - map { $form->{$_} = $form->{"old_$_"} } qw(partnumber description); map { $form->{$_} = $form->escape($form->{$_}, 1) } qw(partnumber description); $form->{callback} = - qq|$form->{script}?action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$name&type=$form->{type}&customer=$customer&partnumber=$form->{partnumber}&description=$form->{description}&previousform="$previousform"&initial=1|; + qq|$form->{script}?action=add&vc=$form->{db}&$form->{db}_id=$form->{id}&$form->{db}=$form->{name}&type=$form->{type}&customer=$customer&partnumber=$form->{partnumber}&description=$form->{description}&previousform="$previousform"&initial=1|; $form->redirect; $main::lxdebug->leave_sub(); diff --git a/bin/mozilla/is.pl b/bin/mozilla/is.pl index 4a08e7185..a506512dd 100644 --- a/bin/mozilla/is.pl +++ b/bin/mozilla/is.pl @@ -285,7 +285,7 @@ sub form_header { $main::auth->assert('invoice_edit'); - our %TMPL_VAR = (); + my %TMPL_VAR = (); my @custom_hiddens; $form->{employee_id} = $form->{old_employee_id} if $form->{old_employee_id}; @@ -596,7 +596,7 @@ sub post_payment { $main::auth->assert('invoice_edit'); - our $invdate; + my $invdate = $form->datetonum($form->{invdate}, \%myconfig); $form->{defaultcurrency} = $form->get_default_currency(\%myconfig); for my $i (1 .. $form->{paidaccounts}) { @@ -886,8 +886,6 @@ sub credit_note { $form->{title} = $locale->text('Add Credit Note'); $form->{script} = 'is.pl'; - our $script = "is"; - our $buysell = 'buy'; # bo creates the id, reset it @@ -906,7 +904,7 @@ sub credit_note { &invoice_links; $form->{currency} = $currency; - $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{invdate}, $buysell); + $form->{forex} = $form->check_exchangerate( \%myconfig, $form->{currency}, $form->{invdate}, 'buy'); $form->{exchangerate} = $form->{forex} || ''; $form->{creditremaining} -= ($form->{oldinvtotal} - $form->{ordtotal}); diff --git a/bin/mozilla/rp.pl b/bin/mozilla/rp.pl index 663a20ebc..b7adc2176 100644 --- a/bin/mozilla/rp.pl +++ b/bin/mozilla/rp.pl @@ -107,10 +107,6 @@ my $rp_access_map = { 'balance_sheet' => 'report', }; -# subs use these pretty freely, so declare them here -our (%column_data, @column_index); -our ($subtotalnetamount, $subtotaltax, $subtotal); - sub check_rp_access { my $form = $main::form; @@ -2115,19 +2111,19 @@ sub generate_tax_report { my $descvar = "$form->{accno}_description"; my $description = $form->escape($form->{$descvar}); my $ratevar = "$form->{accno}_rate"; - our $taxrate; # most likely error + my ($subtotalnetamount, $subtotaltax, $subtotal) = (0, 0, 0); my $department = $form->escape($form->{department}); # construct href my $href = - "$form->{script}?&action=generate_tax_report&fromdate=$form->{fromdate}&todate=$form->{todate}&db=$form->{db}&method=$form->{method}&accno=$form->{accno}&$descvar=$description&department=$department&$ratevar=$taxrate&report=$form->{report}"; + "$form->{script}?&action=generate_tax_report&fromdate=$form->{fromdate}&todate=$form->{todate}&db=$form->{db}&method=$form->{method}&accno=$form->{accno}&$descvar=$description&department=$department&report=$form->{report}"; # construct callback $description = $form->escape($form->{$descvar}, 1); $department = $form->escape($form->{department}, 1); my $callback = - "$form->{script}?&action=generate_tax_report&fromdate=$form->{fromdate}&todate=$form->{todate}&db=$form->{db}&method=$form->{method}&accno=$form->{accno}&$descvar=$description&department=$department&$ratevar=$taxrate&report=$form->{report}"; + "$form->{script}?&action=generate_tax_report&fromdate=$form->{fromdate}&todate=$form->{todate}&db=$form->{db}&method=$form->{method}&accno=$form->{accno}&$descvar=$description&department=$department&report=$form->{report}"; my $title = $form->escape($form->{title}); $href .= "&title=$title"; @@ -2138,6 +2134,7 @@ sub generate_tax_report { my @columns = $form->sort_columns(qw(id transdate invnumber name netamount tax amount)); + my @column_index; foreach my $item (@columns) { if ($form->{"l_$item"} eq "Y") { @@ -2242,7 +2239,7 @@ sub generate_tax_report { if ($form->{l_subtotal} eq 'Y') { if ($sameitem ne $ref->{ $form->{sort} }) { - &tax_subtotal; + tax_subtotal(\@column_index, \$subtotalnetamount, \$subtotaltax, \$subtotal); $sameitem = $ref->{ $form->{sort} }; } } @@ -2258,6 +2255,7 @@ sub generate_tax_report { $ref->{$_} = $form->format_amount(\%myconfig, $ref->{$_}, 2, " "); } qw(netamount tax amount); + my %column_data; $column_data{id} = qq|$ref->{id}|; $column_data{invnumber} = qq|{id}&callback=$callback>$ref->{invnumber}|; @@ -2282,9 +2280,10 @@ sub generate_tax_report { } if ($form->{l_subtotal} eq 'Y') { - &tax_subtotal; + tax_subtotal(\@column_index, \$subtotalnetamount, \$subtotaltax, \$subtotal); } + my %column_data; map { $column_data{$_} = qq| | } @column_index; print qq| @@ -2322,27 +2321,30 @@ sub generate_tax_report { sub tax_subtotal { $main::lxdebug->enter_sub(); + my ($column_index, $subtotalnetamount, $subtotaltax, $subtotal) = @_; + my $form = $main::form; my %myconfig = %main::myconfig; my $locale = $main::locale; - map { $column_data{$_} = " " } @column_index; + my %column_data; + map { $column_data{$_} = " " } @{ $column_index }; - $subtotalnetamount = $form->format_amount(\%myconfig, $subtotalnetamount, 2, " "); - $subtotaltax = $form->format_amount(\%myconfig, $subtotaltax, 2, " "); - $subtotal = $form->format_amount(\%myconfig, $subtotalnetamount + $subtotaltax, 2, " "); + $$subtotalnetamount = $form->format_amount(\%myconfig, $$subtotalnetamount, 2, " "); + $$subtotaltax = $form->format_amount(\%myconfig, $$subtotaltax, 2, " "); + $$subtotal = $form->format_amount(\%myconfig, $$subtotalnetamount + $$subtotaltax, 2, " "); - $column_data{netamount} = "$subtotalnetamount"; - $column_data{tax} = "$subtotaltax"; - $column_data{amount} = "$subtotal"; + $column_data{netamount} = "$$subtotalnetamount"; + $column_data{tax} = "$$subtotaltax"; + $column_data{amount} = "$$subtotal"; - $subtotalnetamount = 0; - $subtotaltax = 0; + $$subtotalnetamount = 0; + $$subtotaltax = 0; print qq| |; - map { print "\n$column_data{$_}" } @column_index; + map { print "\n$column_data{$_}" } @{ $column_index }; print qq| -- 2.20.1