summaryrefslogtreecommitdiff
path: root/httemplate/search/report_tax.cgi
diff options
context:
space:
mode:
authorivan <ivan>2009-05-26 02:48:44 +0000
committerivan <ivan>2009-05-26 02:48:44 +0000
commit40fb7f29f74ef7c8f843588464567062bb1e7539 (patch)
treeabadee3882d4b2c4649a11dc279b909b518226ca /httemplate/search/report_tax.cgi
parent8b678a1d6b3f9414fa67d368bcc6bc8b04a18e1c (diff)
and also fix "tax invoiced" portion of total line when using config option for some basic tax grouping by name, RT#5446
Diffstat (limited to 'httemplate/search/report_tax.cgi')
-rwxr-xr-xhttemplate/search/report_tax.cgi39
1 files changed, 24 insertions, 15 deletions
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 );