X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=httemplate%2Fsearch%2Freport_tax.cgi;h=e89c66536c2037ad2d736db4c4875a75d58bf5ec;hb=74cb9e1c3974d8899bf9745564d0dfce5875454c;hp=bcceaf17593ba76ab4c78dc61f29a982ac7ea2ae;hpb=73e382b838f031512684138fedb7d813684ddd28;p=freeside.git diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi index bcceaf175..e89c66536 100755 --- a/httemplate/search/report_tax.cgi +++ b/httemplate/search/report_tax.cgi @@ -355,9 +355,25 @@ foreach my $r ( qsearch({ 'table' => 'cust_main_county', # ); # } + #false laziness -ish w/report_tax.cgi + my $cust_exempt; + if ( $r->taxname ) { + my $q_taxname = dbh->quote($r->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' "; + } + my $x_cust = scalar_sql($r, \@param, "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) - $fromwhere AND $nottax AND tax = 'Y' " + $fromwhere AND $nottax AND $cust_exempt " ); $regions{$label}->{'exempt_cust'} += $x_cust;