From: ivan Date: Tue, 26 May 2009 02:48:44 +0000 (+0000) Subject: and also fix "tax invoiced" portion of total line when using config option for some... X-Git-Tag: root_of_svc_elec_features~1177 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=40fb7f29f74ef7c8f843588464567062bb1e7539 and also fix "tax invoiced" portion of total line when using config option for some basic tax grouping by name, RT#5446 --- diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index 1b761739c..dc93d513b 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -460,6 +460,25 @@ my $_taxamount_sub = sub { scalar_sql($r, \@taxparam, $sql ); }; +#tax-report_groups filtering +my($group_op, $group_value) = ( '', '' ); +if ( $cgi->param('report_group') =~ /^(=|!=) (.*)$/ ) { + ( $group_op, $group_value ) = ( $1, $2 ); +} +my $group_test = sub { + my $label = shift; + return 1 unless $group_op; #in case we get called inadvertantly + if ( $label eq $out ) { #don't display "out of taxable region" in this case + 0; + } elsif ( $group_op eq '=' ) { + $label =~ /^$group_value/; + } elsif ( $group_op eq '!=' ) { + $label !~ /^$group_value/; + } else { + die "guru meditation #00de: group_op $group_op\n"; + } +}; + my $tot_tax = 0; #foreach my $label ( keys %regions ) { foreach my $r ( qsearch(\%qsearch) ) { @@ -467,6 +486,9 @@ foreach my $r ( qsearch(\%qsearch) ) { #warn join('-', map { $r->$_() } qw( country state county taxname ) )."\n"; my $label = getlabel($r); + if ( $group_op ) { + next unless &{$group_test}($label); + } #my $fromwhere = $join_pkg. $where. " AND payby != 'COMP' "; #my @param = @base_param; @@ -503,21 +525,8 @@ if ( $cgi->param('show_taxclasses') ) { my @regions = keys %regions; #tax-report_groups filtering -my($group_op, $group_value) = ( '', '' ); -if ( $cgi->param('report_group') =~ /^(=|!=) (.*)$/ ) { - ( $group_op, $group_value ) = ( $1, $2 ); - @regions = grep { - if ( $_ eq $out ) { #don't display "out of taxable region" in this case - 0; - } elsif ( $group_op eq '=' ) { - $_ =~ /^$group_value \(/; - } elsif ( $group_op eq '!=' ) { - $_ !~ /^$group_value \(/; - } else { - die "guru meditation #00de: group_op $group_op\n"; - } - } @regions; -} +@regions = grep &{$group_test}($_), @regions + if $group_op; #now calculate totals my( $total, $tot_taxable, $tot_owed ) = ( 0, 0, 0 );