summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorivan <ivan>2009-06-22 10:06:11 +0000
committerivan <ivan>2009-06-22 10:06:11 +0000
commit74cb9e1c3974d8899bf9745564d0dfce5875454c (patch)
treedf9174cc66c9127bbe9fdb18a35846b360d65b74 /httemplate
parent73e382b838f031512684138fedb7d813684ddd28 (diff)
finish basic implemention of tax exemption by tax name hack, RT#5127
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/search/cust_bill_pkg.cgi19
-rwxr-xr-xhttemplate/search/report_tax.cgi18
2 files changed, 35 insertions, 2 deletions
diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi
index 4654425..4a31611 100644
--- a/httemplate/search/cust_bill_pkg.cgi
+++ b/httemplate/search/cust_bill_pkg.cgi
@@ -274,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') ) {
diff --git a/httemplate/search/report_tax.cgi b/httemplate/search/report_tax.cgi
index bcceaf1..e89c665 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;