X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=httemplate%2Fsearch%2Fcust_bill_pkg.cgi;h=975a307137cf0ca69534a6bc5b3f415fdef6183c;hb=64fcb43c61c196766260319cd9219eb70ea27767;hp=52f59de1ec96992ea60e2e557239c06bfbbc25a7;hpb=08ab7010467cf25578acdf8d9a9a068a87f1c49f;p=freeside.git diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi index 52f59de1e..975a30713 100644 --- a/httemplate/search/cust_bill_pkg.cgi +++ b/httemplate/search/cust_bill_pkg.cgi @@ -404,8 +404,6 @@ if ( $cgi->param('pkg_tax') ) { } -my $where = ' WHERE '. join(' AND ', @where); - my $join_cust = ' JOIN cust_bill USING ( invnum ) LEFT JOIN cust_main USING ( custnum ) '; @@ -427,14 +425,28 @@ if ( $cgi->param('nottax') ) { $join_pkg .= ' LEFT JOIN cust_bill_pkg_tax_location USING ( billpkgnum ) LEFT JOIN cust_location USING ( locationnum ) '; - #quelle kludge, false laziness w/report_tax.cgi - $where =~ s/cust_pkg\.locationnum/cust_bill_pkg_tax_location.locationnum/g; - } elsif ( scalar( grep( /locationtaxid/, $cgi->param ) ) ) { + #quelle kludge, somewhat false laziness w/report_tax.cgi + s/cust_pkg\.locationnum/cust_bill_pkg_tax_location.locationnum/g for @where; + } elsif ( scalar( grep( /locationtaxid/, $cgi->param ) ) || + $cgi->param('iscredit') eq 'rate') { $join_pkg .= ' LEFT JOIN cust_bill_pkg_tax_rate_location USING ( billpkgnum ) '. ' LEFT JOIN tax_rate_location USING ( taxratelocationnum ) '; } + if ( $cgi->param('iscredit') ) { + $join_pkg .= ' JOIN cust_credit_bill_pkg USING ( billpkgnum'; + if ( $conf->exists('tax-pkg_address') ) { + $join_pkg .= ', billpkgtaxlocationnum )'; + push @where, "billpkgtaxratelocationnum IS NULL"; + } elsif ( $cgi->param('iscredit') eq 'rate' ) { + $join_pkg .= ', billpkgtaxratelocationnum )'; + } else { + $join_pkg .= ' )'; + push @where, "billpkgtaxratelocationnum IS NULL"; + } + } + } else { #die? @@ -445,6 +457,8 @@ if ( $cgi->param('nottax') ) { } +my $where = ' WHERE '. join(' AND ', @where); + if ($use_usage) { $count_query .= " FROM (SELECT cust_bill_pkg.setup, cust_bill_pkg.recur,