summaryrefslogtreecommitdiff
path: root/FS/FS/Report
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2014-05-20 09:38:38 -0700
committerMark Wells <mark@freeside.biz>2014-05-20 09:39:05 -0700
commit48ddc2a473201e09daaff99b3dd22d56ebe8f939 (patch)
tree6d3e414183c5a2556d487e20a79d3b2da75716db /FS/FS/Report
parent2aca98d97a5ac486880c677a7b518db91628a695 (diff)
option to handle credited tax date range differently, #28497
Diffstat (limited to 'FS/FS/Report')
-rw-r--r--FS/FS/Report/Tax.pm13
1 files changed, 10 insertions, 3 deletions
diff --git a/FS/FS/Report/Tax.pm b/FS/FS/Report/Tax.pm
index fbb98c6..d3322af 100644
--- a/FS/FS/Report/Tax.pm
+++ b/FS/FS/Report/Tax.pm
@@ -93,7 +93,7 @@ sub report_internal {
my $pkg_tax_exempt = "SELECT SUM(amount) AS exempt_charged, billpkgnum, taxnum ".
"FROM cust_tax_exempt_pkg EXEMPT_WHERE GROUP BY billpkgnum, taxnum";
- my $where = "WHERE _date >= $beginning AND _date <= $ending ".
+ my $where = "WHERE cust_bill._date >= $beginning AND cust_bill._date <= $ending ".
"AND COALESCE(cust_main_county.taxname,'Tax') = '$taxname' ".
"AND cust_main_county.country = '$country'";
# SELECT/GROUP clauses for first-level queries
@@ -238,9 +238,16 @@ sub report_internal {
# ($creditfrom includes join of taxable item to part_pkg if with_pkgclass
# is on)
my $creditfrom = $taxfrom .
- ' JOIN cust_credit_bill_pkg USING (billpkgtaxlocationnum)';
+ ' JOIN cust_credit_bill_pkg USING (billpkgtaxlocationnum)' .
+ ' JOIN cust_credit_bill USING (creditbillnum)';
my $creditwhere = $where .
- ' AND billpkgtaxratelocationnum IS NULL';
+ ' AND billpkgtaxratelocationnum IS NULL';
+
+ # if the credit_date option is set to application date, change
+ # $creditwhere accordingly
+ if ( $opt{credit_date} eq 'cust_credit_bill' ) {
+ $creditwhere =~ s/cust_bill._date/cust_credit_bill._date/g;
+ }
$sql{credit} = "$select SUM(cust_credit_bill_pkg.amount)
$creditfrom