From: Sven Schöling Date: Tue, 20 Oct 2009 08:50:49 +0000 (+0200) Subject: strictness für Menu und Ca X-Git-Tag: release-2.6.1beta1~213 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=c621a9187eb258019fa540490de21b248c709516;p=kivitendo-erp.git strictness für Menu und Ca --- diff --git a/SL/CA.pm b/SL/CA.pm index a537085c9..4f66c9b2b 100644 --- a/SL/CA.pm +++ b/SL/CA.pm @@ -38,12 +38,14 @@ package CA; use Data::Dumper; use SL::DBUtils; +use strict; + sub all_accounts { $main::lxdebug->enter_sub(); my ($self, $myconfig, $form, $chart_id) = @_; - my %amount; + my (%amount, $acc_cash_where); # connect to database my $dbh = $form->dbconnect($myconfig); @@ -104,7 +106,7 @@ sub all_accounts { $form->{CA} = []; - while (my $ca = $sth->fetchrow_hashref(NAME_lc)) { + while (my $ca = $sth->fetchrow_hashref("NAME_lc")) { $ca->{amount} = $amount{ $ca->{accno} }; if ($ca->{amount} < 0) { $ca->{debit} = $ca->{amount} * -1; @@ -145,7 +147,7 @@ sub all_transactions { # $where .= " AND ac.transdate <= '$form->{todate}'"; # } - my (@values, @where_values, @subwhere_values); + my (@values, @where_values, @subwhere_values, $subwhere); if ($form->{fromdate}) { $where .= qq| AND ac.transdate >= ?|; $subwhere .= qq| AND transdate >= ?|; @@ -163,7 +165,7 @@ sub all_transactions { my $sortorder = join ', ', $form->sort_columns(qw(transdate reference description)); - my $false = ($myconfig->{dbdriver} eq 'Pg') ? FALSE: q|'0'|; + my $false = ($myconfig->{dbdriver} eq 'Pg') ? "FALSE" : q|'0'|; # Oracle workaround, use ordinal positions my %ordinal = (transdate => 4, @@ -236,16 +238,16 @@ sub all_transactions { ($form->{old_balance_credit}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{fromdate}, $form->{accno}); # get current saldo - my $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : ""; + $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : ""; $query = qq|SELECT sum(ac.amount) FROM acc_trans ac LEFT JOIN chart c ON (ac.chart_id = c.id) WHERE ((select date_trunc('year', ac.transdate::date)) >= (select date_trunc('year', ?::date))) $todate AND c.accno = ? AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL)|; ($form->{saldo_new}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{accno}); #get current balance - my $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : ""; + $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : ""; $query = qq|SELECT sum(ac.amount) FROM acc_trans ac LEFT JOIN chart c ON (ac.chart_id = c.id) WHERE ((select date_trunc('year', ac.transdate::date)) >= (select date_trunc('year', ?::date))) $todate AND c.accno = ? AND ac.amount < 0 AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL)|; ($form->{current_balance_debit}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{accno}); - my $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : ""; + $todate = ($form->{todate} ne "") ? " AND ac.transdate <= '$form->{todate}' " : ""; $query = qq|SELECT sum(ac.amount) FROM acc_trans ac LEFT JOIN chart c ON (ac.chart_id = c.id)WHERE ((select date_trunc('year', ac.transdate::date)) >= (select date_trunc('year', ?::date))) $todate AND c.accno = ? AND ac.amount > 0 AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL)|; ($form->{current_balance_credit}) = selectrow_query($form, $dbh, $query, $form->{fromdate}, $form->{accno}); } @@ -301,7 +303,7 @@ sub all_transactions { qq|WHERE | . $where . $dpt_where . $project . qq| AND ac.chart_id = ? | . qq| AND ac.trans_id = a.id | . - qq| AND a.vendor_id = v.id |; + qq| AND a.vendor_id = v.id | . qq| AND (NOT ac.ob_transaction OR ac.ob_transaction IS NULL)| . push(@values, @where_values, @department_values, @project_values, $id, @@ -315,6 +317,17 @@ sub all_transactions { $fromdate_where =~ s/ac\./a\./; $todate_where =~ s/ac\./a\./; +# strict check 20.10.2009 sschoeling +# the previous version contained the var $ar_ap_cash_where, which was ONLY set by +# RP->trial_balance() I tried to figure out which bizarre flow through the +# program would happen to set that var, so that it would be used here later on, +# (which would be nonsense, since you would normally load chart before +# claculating balance of said charts) and then decided that any mechanic that +# complex should fail anyway. + +# if anyone is missing a time check on charts, that broke arounf the time +# trial_balance was rewritten, this would be it + $query .= qq|UNION ALL | . @@ -331,7 +344,6 @@ sub all_transactions { $todate_where . $dpt_where . $project . - $ar_ap_cash_where . qq|UNION ALL | . qq|SELECT a.id, a.invnumber, v.name, a.transdate, | . @@ -346,8 +358,7 @@ sub all_transactions { $fromdate_where . $todate_where . $dpt_where . - $project . - $ar_ap_cash_where; + $project; push(@values, $id, @department_values, @project_values, $id, @department_values, @project_values); @@ -363,17 +374,17 @@ sub all_transactions { my $sort = grep({ $form->{sort} eq $_ } qw(transdate reference description)) ? $form->{sort} : 'transdate'; $query .= qq|ORDER BY $sort|; - $sth = prepare_execute_query($form, $dbh, $query, @values); + my $sth = prepare_execute_query($form, $dbh, $query, @values); #get detail information for each transaction - $trans_query = + my $trans_query = qq|SELECT accno, | . qq|amount, transdate FROM acc_trans LEFT JOIN chart ON (chart_id=chart.id) WHERE | . qq|trans_id = ? AND sign(amount) <> sign(?) AND chart_id <> ? AND transdate = ?|; my $trans_sth = $dbh->prepare($trans_query); $form->{CA} = []; - while (my $ca = $sth->fetchrow_hashref(NAME_lc)) { + while (my $ca = $sth->fetchrow_hashref("NAME_lc")) { # ap if ($ca->{module} eq "ap") { $ca->{module} = ($ca->{invoice}) ? 'ir' : 'ap'; @@ -397,7 +408,7 @@ sub all_transactions { #get detail information for this transaction $trans_sth->execute($ca->{id}, $ca->{amount}, $ca->{chart_id}, $ca->{transdate}) || $form->dberror($trans_query . " (" . join(", ", $ca->{id}) . ")"); - while (my $trans = $trans_sth->fetchrow_hashref(NAME_lc)) { + while (my $trans = $trans_sth->fetchrow_hashref("NAME_lc")) { if (($ca->{transdate} eq $trans->{transdate}) && ($ca->{amount} * $trans->{amount} < 0)) { if ($trans->{amount} < 0) { $trans->{debit} = $trans->{amount} * -1; diff --git a/SL/Menu.pm b/SL/Menu.pm index 26e3512eb..adac1b006 100644 --- a/SL/Menu.pm +++ b/SL/Menu.pm @@ -37,6 +37,8 @@ package Menu; use SL::Auth; use SL::Inifile; +use strict; + sub new { $main::lxdebug->enter_sub(); @@ -91,7 +93,7 @@ sub menuitem { # add other params foreach my $key (keys %{ $self->{$item} }) { $str .= "&" . $form->escape($key, 1) . "="; - ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); + my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); $value = $myconfig->{$value} . "/$conf" if ($conf); $str .= $form->escape($value, 1); } @@ -135,7 +137,7 @@ sub menuitem_js { # add other params foreach my $key (keys %{ $self->{$item} }) { $str .= "&" . $form->escape($key, 1) . "="; - ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); + my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); $value = $myconfig->{$value} . "/$conf" if ($conf); $str .= $form->escape($value, 1); } @@ -149,7 +151,8 @@ sub menuitem_new { my ($self, $name, $item) = @_; - my $form = $main::form; + my $form = $main::form; + my $myconfig = \%main::myconfig; my $module = $self->{$name}->{module} || $form->{script}; my $action = $self->{$name}->{action}; @@ -207,7 +210,7 @@ sub menuitem_v3 { # add other params foreach my $key (keys %{ $self->{$item} }) { $str .= "&" . $form->escape($key, 1) . "="; - ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); + my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); $value = $myconfig->{$value} . "/$conf" if ($conf); $str .= $form->escape($value, 1); } @@ -267,7 +270,7 @@ sub menuitem_XML { # add other params foreach my $key (keys %{ $self->{$item} }) { $str .= "&" . $form->escape($key, 1) . "="; - ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); + my ($value, $conf) = split(/=/, $self->{$item}{$key}, 2); $value = $myconfig->{$value} . "/$conf" if ($conf); $str .= $form->escape($value, 1); } @@ -311,6 +314,10 @@ sub parse_access_string { my $key = shift; my $access = shift; + my $form = $main::form; + my $auth = $main::auth; + my $myconfig = \%main::myconfig; + my @stack; my $cur_ary = []; @@ -331,7 +338,7 @@ sub parse_access_string { } elsif ($token eq ")") { pop @stack; if (!@stack) { - $main::form->error("Error in menu.ini for entry ${key}: missing '('"); + $form->error("Error in menu.ini for entry ${key}: missing '('"); } $cur_ary = $stack[-1]; @@ -339,16 +346,16 @@ sub parse_access_string { push @{$cur_ary}, $token; } else { - push @{$cur_ary}, $main::auth->check_right($main::form->{login}, $token, 1); + push @{$cur_ary}, $auth->check_right($form->{login}, $token, 1); } } if ($access) { - $main::form->error("Error in menu.ini for entry ${name}: unrecognized token at the start of '$access'\n"); + $form->error("Error in menu.ini for entry ${key}: unrecognized token at the start of '$access'\n"); } if (1 < scalar @stack) { - $main::form->error("Error in menu.ini for entry ${name}: Missing ')'\n"); + $main::form->error("Error in menu.ini for entry ${key}: Missing ')'\n"); } return SL::Auth::evaluate_rights_ary($stack[0]);