}
}
-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
my $locs_sql =
' ( '. join(' OR ', map {
- my %ph = ( 'county' => $_,
+ my %ph = ( 'county' => dbh->quote($_),
map { $_ => dbh->quote( $cgi->param($_) ) }
qw( state country )
);
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') ) {