From 2e1d2a91264e8441bc31583be7352ae1b3c31bb8 Mon Sep 17 00:00:00 2001 From: jeff Date: Wed, 19 Aug 2009 06:15:14 +0000 Subject: option to count subpackages outside packages in sales report #5588 --- FS/FS/Report/Table/Monthly.pm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'FS') diff --git a/FS/FS/Report/Table/Monthly.pm b/FS/FS/Report/Table/Monthly.pm index d75f0be79..d015f9116 100644 --- a/FS/FS/Report/Table/Monthly.pm +++ b/FS/FS/Report/Table/Monthly.pm @@ -311,11 +311,21 @@ sub cust_bill_pkg { my( $self, $speriod, $eperiod, $agentnum, %opt ) = @_; my $where = ''; + my $comparison = ''; if ( $opt{'classnum'} =~ /^(\d+)$/ ) { if ( $1 == 0 ) { - $where = "classnum IS NULL"; + $comparison = "IS NULL"; } else { - $where = "classnum = $1"; + $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"; } } @@ -328,6 +338,7 @@ sub cust_bill_pkg { LEFT JOIN cust_main USING ( custnum ) LEFT JOIN cust_pkg USING ( pkgnum ) LEFT JOIN part_pkg USING ( pkgpart ) + LEFT JOIN part_pkg AS override ON pkgpart_override = override.pkgpart WHERE pkgnum != 0 AND $where AND ". $self->in_time_period_and_agent($speriod, $eperiod, $agentnum) -- cgit v1.2.1