summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2015-09-01 23:11:05 -0500
committerJonathan Prykop <jonathan@freeside.biz>2015-09-02 21:49:38 -0500
commit29a5430518ba80f1431277b5dbb28da524eedcbb (patch)
treeb53217fdcd5f3cef35c8beac517e56f6c11b44f3 /FS
parent6776904eea418b12bec7f1aa0296e9384981d07a (diff)
RT#32892: Monthly Sales Tax Report
Diffstat (limited to 'FS')
-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 4b1ad05d6..4b22b60b8 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