X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_bill_pkg.cgi;h=4a31611cd4a518a934874dea1643e8be5727a915;hb=883f6c25e41831d9183e9500accb89f4cb23ae73;hp=b150989ce54190f7654fd18f73aed15508f1b379;hpb=aeae062630d148cad199305dd601ce33e37714f1;p=freeside.git diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi index b150989ce..4a31611cd 100644 --- a/httemplate/search/cust_bill_pkg.cgi +++ b/httemplate/search/cust_bill_pkg.cgi @@ -95,7 +95,10 @@ if ( $cgi->param('classnum') =~ /^(\d+)$/ ) { } } -push @where, map ' taxclass = '.dbh->quote($_), $cgi->param('taxclass') +push @where, ' ( '. join(' OR ', + map ' taxclass = '.dbh->quote($_), $cgi->param('taxclass') + ). + ' ) ' if $cgi->param('taxclass') && ! $cgi->param('istax'); #no part_pkg.taxclass in this case #(should we save a taxclass or a link to taxnum @@ -166,7 +169,7 @@ if ( $cgi->param('out') ) { my $locs_sql = ' ( '. join(' OR ', map { - my %ph = ( 'county' => $_, + my %ph = ( 'county' => dbh->quote($_), map { $_ => dbh->quote( $cgi->param($_) ) } qw( state country ) ); @@ -271,7 +274,24 @@ if ( $cgi->param('report_group') =~ /^(=|!=) (.*)$/ && $cgi->param('istax') ) { push @where, 'cust_bill_pkg.pkgnum != 0' if $cgi->param('nottax'); push @where, 'cust_bill_pkg.pkgnum = 0' if $cgi->param('istax'); -push @where, " tax = 'Y' " if $cgi->param('cust_tax'); +if ( $cgi->param('cust_tax') ) { + #false laziness -ish w/report_tax.cgi + my $cust_exempt; + if ( $cgi->param('taxname') ) { + my $q_taxname = dbh->quote($cgi->param('taxname')); + $cust_exempt = + "( tax = 'Y' + OR EXISTS ( SELECT 1 FROM cust_main_exemption + WHERE cust_main_exemption.custnum = cust_main.custnum + AND cust_main_exemption.taxname = $q_taxname ) + ) + "; + } else { + $cust_exempt = " tax = 'Y' "; + } + + push @where, $cust_exempt; +} my $count_query; if ( $cgi->param('pkg_tax') ) {