+
+ if ( $cgi->param('out') ) {
+ # separate from the rest, in that we're not going to join cust_main_county
+ # in the outer query
+
+ my @exclude = ( 'cust_tax_exempt_pkg.billpkgnum',
+ 'cust_bill_pkg_tax_location.taxable_billpkgnum'
+ );
+ foreach my $col (@exclude) {
+ my ($table) = split(/\./, $col);
+ my $this_where = 'WHERE ' . join(' AND ',
+ "$col = cust_bill_pkg.billpkgnum",
+ @tax_where
+ );
+
+ push @where,
+ "NOT EXISTS(SELECT 1 FROM $table
+ JOIN cust_main_county USING (taxnum)
+ $this_where
+ )";
+ }
+
+ } else {
+ # everything that returns things joined to a tax definition