[freeside-commits] freeside/FS/FS/Report/Table Monthly.pm, 1.18, 1.19

Ivan,,, ivan at wavetail.420.am
Fri Feb 5 18:54:12 PST 2010


Update of /home/cvs/cvsroot/freeside/FS/FS/Report/Table
In directory wavetail.420.am:/tmp/cvs-serv1107/FS/FS/Report/Table

Modified Files:
	Monthly.pm 
Log Message:
discount reporting, RT#6679

Index: Monthly.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Report/Table/Monthly.pm,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- Monthly.pm	3 Dec 2009 19:06:51 -0000	1.18
+++ Monthly.pm	6 Feb 2010 02:54:10 -0000	1.19
@@ -417,6 +417,53 @@
   
 }
 
+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'); }



More information about the freeside-commits mailing list