+ # now do something with that
+ if ( @exempt_where ) {
+
+ push @where, 'item_exempt.billpkgnum IS NOT NULL';
+ push @select, 'item_exempt.exempt_amount';
+ push @peritem, 'exempt_amount';
+ push @peritem_desc, 'Exempt';
+ push @total, 'SUM(exempt_amount)';
+ push @total_desc, "$money_char%.2f tax-exempt";
+
+ } elsif ( @tax_where or $cgi->param('taxable') ) {
+
+ my $taxable = 'cust_bill_pkg.setup + cust_bill_pkg.recur '.
+ '- COALESCE(item_exempt.exempt_amount, 0) '.
+ '- COALESCE(item_credit.credit_amount, 0)';
+
+ push @where, "(item_tax.billpkgnum IS NOT NULL OR item_exempt.billpkgnum IS NOT NULL)";
+ push @select, "($taxable) AS taxable_amount";
+ push @peritem, 'taxable_amount';
+ push @peritem_desc, 'Taxable';
+
+ if ( $cgi->param('taxable') ) {
+ push @where, "($taxable) > 0";
+ } else {
+ push @total, 'SUM('.
+ 'cust_bill_pkg.setup + cust_bill_pkg.recur '.
+ '- COALESCE(item_credit.credit_amount, 0) )';
+ push @total_desc, "$money_char%.2f net sales";
+ }
+
+ push @total, "SUM($taxable)";
+ push @total_desc, "$money_char%.2f taxable";
+ }