summaryrefslogtreecommitdiff
path: root/httemplate/search/cust_bill_pkg.cgi
diff options
context:
space:
mode:
authorivan <ivan>2006-01-26 15:27:10 +0000
committerivan <ivan>2006-01-26 15:27:10 +0000
commitb782294eb91805f708a7776fe67f1c0863f4096b (patch)
tree3c6987f38b65a72118b8a369869719a12d8cf141 /httemplate/search/cust_bill_pkg.cgi
parentcbbd0225b07269209c674733bcf70f1c1308e84a (diff)
whew, FINALLY can fix monthly exemption columns to work correctly. also make them agent-specific. also fix package exemption columns, they were bunk too, sheesh. start adding package classes for package class tax reporting.
Diffstat (limited to 'httemplate/search/cust_bill_pkg.cgi')
-rw-r--r--httemplate/search/cust_bill_pkg.cgi32
1 files changed, 22 insertions, 10 deletions
diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi
index 082ccc893..cc0f97536 100644
--- a/httemplate/search/cust_bill_pkg.cgi
+++ b/httemplate/search/cust_bill_pkg.cgi
@@ -4,7 +4,7 @@ my($beginning, $ending) = FS::UI::Web::parse_beginning_ending($cgi);
my $join_cust = "
JOIN cust_bill USING ( invnum )
- JOIN cust_main USING ( custnum )
+ LEFT JOIN cust_main USING ( custnum )
";
my $join_pkg = "
@@ -17,6 +17,10 @@ my $where = "
AND payby != 'COMP'
";
+if ( $cgi->param('agentnum') =~ /^(\d+)$/ ) {
+ $where .= " AND agentnum = $1 ";
+}
+
if ( $cgi->param('out') ) {
$where .= "
@@ -62,19 +66,27 @@ my $count_query;
if ( $cgi->param('pkg_tax') ) {
$count_query =
- "SELECT COUNT(*), SUM( ( CASE WHEN part_pkg.setuptax = 'Y'
- THEN cust_bill_pkg.setup
- ELSE 0 )
- +
- ( CASE WHEN part_pkg.recurtax = 'Y'
- THEN cust_bill_pkg.recur
- ELSE 0 )
- )";
+ "SELECT COUNT(*), SUM(
+ ( CASE WHEN part_pkg.setuptax = 'Y'
+ THEN cust_bill_pkg.setup
+ ELSE 0
+ END
+ )
+ +
+ ( CASE WHEN part_pkg.recurtax = 'Y'
+ THEN cust_bill_pkg.recur
+ ELSE 0
+ END
+ )
+ )
+ ";
$where .= " AND (
( part_pkg.setuptax = 'Y' AND cust_bill_pkg.setup > 0 )
OR ( part_pkg.recurtax = 'Y' AND cust_bill_pkg.recur > 0 )
- )";
+ )
+ AND ( tax != 'Y' OR tax IS NULL )
+ ";
} else {