diff options
author | ivan <ivan> | 2009-06-22 10:06:11 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-06-22 10:06:11 +0000 |
commit | 74cb9e1c3974d8899bf9745564d0dfce5875454c (patch) | |
tree | df9174cc66c9127bbe9fdb18a35846b360d65b74 /httemplate | |
parent | 73e382b838f031512684138fedb7d813684ddd28 (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.cgi | 19 | ||||
-rwxr-xr-x | httemplate/search/report_tax.cgi | 18 |
2 files changed, 35 insertions, 2 deletions
diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi index 4654425c9..4a31611cd 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 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; |