summaryrefslogtreecommitdiff
path: root/FS/FS/Report
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-09-01 23:11:05 -0500
committerJonathan Prykop <jonathan@freeside.biz>2015-09-01 23:11:05 -0500
commite0e76b55a2f83c19e4114eefe4dabcab092808b4 (patch)
tree4eb846ded44e360140b370281adec65aa3c8b979 /FS/FS/Report
parent6163b943f45e083a87cc03344eb775a9edd553ce (diff)
RT#32892: Monthly Sales Tax Report
Diffstat (limited to 'FS/FS/Report')
-rw-r--r--FS/FS/Report/Table.pm27
1 files changed, 27 insertions, 0 deletions
diff --git a/FS/FS/Report/Table.pm b/FS/FS/Report/Table.pm
index 4b1ad05..4b22b60 100644
--- a/FS/FS/Report/Table.pm
+++ b/FS/FS/Report/Table.pm
@@ -753,6 +753,33 @@ sub cust_bill_pkg_taxes {
$self->scalar_sql($total_sql);
}
+#all credits applied to matching pkg line items (ie not taxes or fees)
+
+sub cust_bill_pkg_credits {
+ my $self = shift;
+ my ($speriod, $eperiod, $agentnum, %opt) = @_;
+
+ $agentnum ||= $opt{'agentnum'};
+
+ my @where = (
+ '(cust_bill_pkg.pkgnum != 0 OR feepart IS NOT NULL)',
+ $self->with_classnum($opt{'classnum'}, $opt{'use_override'}),
+ $self->with_report_option(%opt),
+ $self->in_time_period_and_agent($speriod, $eperiod, $agentnum),
+ $self->with_refnum(%opt),
+ $self->with_cust_classnum(%opt)
+ );
+
+ my $total_sql = "SELECT COALESCE(SUM(cust_credit_bill_pkg.amount),0)
+ FROM cust_bill_pkg
+ $cust_bill_pkg_join
+ LEFT JOIN cust_credit_bill_pkg
+ USING ( billpkgnum )
+ WHERE " . join(' AND ', grep $_, @where);
+
+ $self->scalar_sql($total_sql);
+}
+
##### package churn report #####
=item active_pkg: The number of packages that were active at the start of