summaryrefslogtreecommitdiff
path: root/FS/FS/Report/Table
diff options
context:
space:
mode:
authorivan <ivan>2010-02-06 02:57:12 +0000
committerivan <ivan>2010-02-06 02:57:12 +0000
commit942c8b05b17b119a3dad84d7035c76b481dc5b99 (patch)
treeafa91e2825c0c289bfab329a36c274b393c91248 /FS/FS/Report/Table
parent50aae8bb98effd9b9cc4736aa6d3333245d349d8 (diff)
discount reporting, RT#6679
Diffstat (limited to 'FS/FS/Report/Table')
-rw-r--r--FS/FS/Report/Table/Monthly.pm47
1 files changed, 47 insertions, 0 deletions
diff --git a/FS/FS/Report/Table/Monthly.pm b/FS/FS/Report/Table/Monthly.pm
index fa9949d..9e7a288 100644
--- a/FS/FS/Report/Table/Monthly.pm
+++ b/FS/FS/Report/Table/Monthly.pm
@@ -417,6 +417,53 @@ sub cust_bill_pkg_detail {
}
+sub cust_bill_pkg_discount {
+ my( $self, $speriod, $eperiod, $agentnum, %opt ) = @_;
+
+ #my $where = '';
+ #my $comparison = '';
+ #if ( $opt{'classnum'} =~ /^(\d+)$/ ) {
+ # if ( $1 == 0 ) {
+ # $comparison = "IS NULL";
+ # } else {
+ # $comparison = "= $1";
+ # }
+ #
+ # if ( $opt{'use_override'} ) {
+ # $where = "(
+ # part_pkg.classnum $comparison AND pkgpart_override IS NULL OR
+ # override.classnum $comparison AND pkgpart_override IS NOT NULL
+ # )";
+ # } else {
+ # $where = "part_pkg.classnum $comparison";
+ # }
+ #}
+
+ $agentnum ||= $opt{'agentnum'};
+
+ my $total_sql =
+ " SELECT COALESCE( SUM( cust_bill_pkg_discount.amount ), 0 ) ";
+
+ #$total_sql .=
+ # " / CASE COUNT(cust_pkg.*) WHEN 0 THEN 1 ELSE COUNT(cust_pkg.*) END "
+ # if $opt{average_per_cust_pkg};
+
+ $total_sql .=
+ " FROM cust_bill_pkg_discount
+ LEFT JOIN cust_bill_pkg USING ( billpkgnum )
+ LEFT JOIN cust_bill USING ( invnum )
+ LEFT JOIN cust_main USING ( custnum )
+ WHERE ". $self->in_time_period_and_agent($speriod, $eperiod, $agentnum);
+ # LEFT JOIN cust_pkg_discount USING ( pkgdiscountnum )
+ # LEFT JOIN discount USING ( discountnum )
+ # LEFT JOIN cust_pkg USING ( pkgnum )
+ # LEFT JOIN part_pkg USING ( pkgpart )
+ # LEFT JOIN part_pkg AS override ON pkgpart_override = override.pkgpart
+
+ return $self->scalar_sql($total_sql);
+
+}
+
sub setup_pkg { shift->pkg_field( @_, 'setup' ); }
sub susp_pkg { shift->pkg_field( @_, 'susp' ); }
sub cancel_pkg { shift->pkg_field( @_, 'cancel'); }