X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fsearch%2Fcust_bill_pkg.cgi;h=b9743049ded29065d6b1132b9c2056aa03eb219b;hb=5c0d47bfe554a35c8906d97b9fabd9999be4f67e;hp=8b6b0cebd081d75b81bbf4aeef59528b6ec0015b;hpb=033709735189caa804476fc17e9946809516fcf7;p=freeside.git diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi index 8b6b0cebd..b9743049d 100644 --- a/httemplate/search/cust_bill_pkg.cgi +++ b/httemplate/search/cust_bill_pkg.cgi @@ -81,7 +81,7 @@ $use_usage eq 'usage' ? 'usage' : 'recur' ), - ( $undearned ? ('sdate', 'edate') : () ), + ( $unearned ? ('sdate', 'edate') : () ), 'invnum', '_date', ], @@ -463,7 +463,8 @@ if ( $cgi->param('pkg_tax') ) { } else { - $count_query = "SELECT COUNT(*), "; + #$count_query = "SELECT COUNT(*), "; + $count_query = "SELECT COUNT(DISTINCT billpkgnum), "; if ( $use_usage eq 'recurring' ) { $count_query .= "SUM(setup + recur - usage)"; @@ -472,7 +473,12 @@ if ( $cgi->param('pkg_tax') ) { } elsif ( $unearned ) { $count_query .= "SUM(cust_bill_pkg.recur)"; } else { - $count_query .= "SUM(cust_bill_pkg.setup + cust_bill_pkg.recur)"; + if ( scalar( grep( /locationtaxid/, $cgi->param ) ) || + $cgi->param('iscredit') eq 'rate') { + $count_query .= "SUM( COALESCE(amount, cust_bill_pkg.setup + cust_bill_pkg.recur))"; + } else { + $count_query .= "SUM(cust_bill_pkg.setup + cust_bill_pkg.recur)"; + } } if ( $unearned ) {