fix cch tax report for more than one cust_bill_pkg_tax_rate_location per line item...
[freeside.git] / httemplate / search / report_newtax.cgi
index 6a2cbb0..7851462 100755 (executable)
@@ -123,7 +123,7 @@ foreach my $t (qsearch({ table     => 'cust_bill_pkg',
     my $taxwhere = "FROM cust_bill_pkg $addl_from $where AND payby != 'COMP' ".
       "AND ". join( ' AND ', map { "( $_ = ? OR ? = '' AND $_ IS NULL)" } @taxparam );
 
-    my $sql = "SELECT SUM(cust_bill_pkg.setup+cust_bill_pkg.recur) ".
+    my $sql = "SELECT SUM(COALESCE(amount, cust_bill_pkg.setup+cust_bill_pkg.recur)) ".
               " $taxwhere AND cust_bill_pkg.pkgnum = 0";
 
     my $x = scalar_sql($t, [ map { $_, $_ } @params ], $sql );