summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2014-03-06 20:40:39 -0800
committerMark Wells <mark@freeside.biz>2014-03-06 20:40:39 -0800
commitdbd79d059c9353da8d521fce4ee2ce8cc3349a54 (patch)
tree96c27f661cfd3fb48d0ac15865958a0fcf06a843 /httemplate
parent144670c57ac321235202003682550fb2990873e3 (diff)
fix vendor tax report in light of non-package fees and cust_payby refactoring, #27964
Diffstat (limited to 'httemplate')
-rw-r--r--httemplate/search/cust_bill_pkg.cgi33
1 files changed, 15 insertions, 18 deletions
diff --git a/httemplate/search/cust_bill_pkg.cgi b/httemplate/search/cust_bill_pkg.cgi
index 440ab150c..fe16f3aa5 100644
--- a/httemplate/search/cust_bill_pkg.cgi
+++ b/httemplate/search/cust_bill_pkg.cgi
@@ -23,10 +23,7 @@
? $_[0]->get('pkgpart')
: ''
},
- sub { $_[0]->pkgnum > 0
- ? $_[0]->get('pkg')
- : $_[0]->get('itemdesc')
- },
+ 'itemdesc', # is part_pkg.pkg if applicable
@post_desc,
#strikethrough or "N/A ($amount)" or something these when
# they're not applicable to pkg_tax search
@@ -246,6 +243,9 @@ if ( $conf->exists('enable_taxclasses') ) {
$post_desc_align .= 'l';
}
+# used in several places
+my $itemdesc = 'COALESCE(part_fee.itemdesc, part_pkg.pkg, cust_bill_pkg.itemdesc)';
+
# valid in both the tax and non-tax cases
my $join_cust =
" LEFT JOIN cust_bill ON (cust_bill_pkg.invnum = cust_bill.invnum)".
@@ -326,7 +326,7 @@ push @select, "COALESCE($part_pkg.taxclass, part_fee.taxclass) AS taxclass"
# the non-tax case
if ( $cgi->param('nottax') ) {
- push @select, "part_fee.itemdesc";
+ push @select, $itemdesc;
push @where,
'(cust_bill_pkg.pkgnum > 0 OR cust_bill_pkg.feepart IS NOT NULL)';
@@ -509,14 +509,16 @@ if ( $cgi->param('nottax') ) {
push @where, 'cust_bill_pkg.pkgnum = 0';
# tax location when using tax_rate_location
- if ( scalar( grep( /locationtaxid/, $cgi->param ) ) ) {
+ if ( $cgi->param('vendortax') ) {
$join_pkg .= ' LEFT JOIN cust_bill_pkg_tax_rate_location USING ( billpkgnum ) '.
' LEFT JOIN tax_rate_location USING ( taxratelocationnum )';
- push @where, FS::tax_rate_location->location_sql(
- map { $_ => (scalar($cgi->param($_)) || '') }
- qw( district city county state locationtaxid )
- );
+ foreach (qw( state county city locationtaxid)) {
+ if ( scalar($cgi->param($_)) ) {
+ my $place = dbh->quote( $cgi->param($_) );
+ push @where, "tax_rate_location.$_ = $place";
+ }
+ }
$total[1] = 'SUM(
COALESCE(cust_bill_pkg_tax_rate_location.amount,
@@ -575,17 +577,12 @@ if ( $cgi->param('nottax') ) {
dbh->quote($cgi->param('taxname'));
}
- # specific taxnums
- if ( $cgi->param('taxnum') =~ /^([\d,]+)$/) {
- push @where, "cust_main_county.taxnum IN ($1)";
- }
-
- # itemdesc, for some reason
+ # itemdesc, for breakdown from the vendor tax report
if ( $cgi->param('itemdesc') ) {
if ( $cgi->param('itemdesc') eq 'Tax' ) {
- push @where, "(itemdesc='Tax' OR itemdesc is null)";
+ push @where, "($itemdesc = 'Tax' OR $itemdesc is null)";
} else {
- push @where, 'itemdesc='. dbh->quote($cgi->param('itemdesc'));
+ push @where, "$itemdesc = ". dbh->quote($cgi->param('itemdesc'));
}
}