[freeside-commits] freeside/FS/FS/Report/Table Monthly.pm, 1.19, 1.20
Mark Wells
mark at wavetail.420.am
Wed Apr 7 18:15:28 PDT 2010
Update of /home/cvs/cvsroot/freeside/FS/FS/Report/Table
In directory wavetail.420.am:/tmp/cvs-serv3406/FS/FS/Report/Table
Modified Files:
Monthly.pm
Log Message:
RT#1382: beginning of package cost report
Index: Monthly.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Report/Table/Monthly.pm,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -w -d -r1.19 -r1.20
--- Monthly.pm 6 Feb 2010 02:54:10 -0000 1.19
+++ Monthly.pm 8 Apr 2010 01:15:25 -0000 1.20
@@ -307,6 +307,64 @@
timelocal($sec,$min,$hour,$mday,$mon,$year);
}
+sub cust_pkg_setup_cost {
+ my( $self, $speriod, $eperiod, $agentnum, %opt ) = @_;
+ my $where = '';
+ my $comparison = '';
+ if ( $opt{'classnum'} =~ /^(\d+)$/ ) {
+ if ( $1 == 0 ) {
+ $comparison = 'IS NULL';
+ }
+ else {
+ $comparison = "= $1";
+ }
+ $where = "AND part_pkg.classnum $comparison";
+ }
+ $agentnum ||= $opt{'agentnum'};
+
+ my $total_sql = " SELECT SUM(part_pkg.setup_cost) ";
+ $total_sql .= " FROM cust_pkg
+ LEFT JOIN cust_main USING ( custnum )
+ LEFT JOIN part_pkg USING ( pkgpart )
+ WHERE pkgnum != 0
+ $where
+ AND ".$self->in_time_period_and_agent(
+ $speriod, $eperiod, $agentnum, 'cust_pkg.setup');
+ return $self->scalar_sql($total_sql);
+}
+
+sub cust_pkg_recur_cost {
+ my( $self, $speriod, $eperiod, $agentnum, %opt ) = @_;
+ my $where = '';
+ my $comparison = '';
+ if ( $opt{'classnum'} =~ /^(\d+)$/ ) {
+ if ( $1 == 0 ) {
+ $comparison = 'IS NULL';
+ }
+ else {
+ $comparison = "= $1";
+ }
+ $where = " AND part_pkg.classnum $comparison";
+ }
+ $agentnum ||= $opt{'agentnum'};
+ # duplication of in_time_period_and_agent
+ # because we do it a little differently here
+ $where .= " AND cust_main.agentnum = $agentnum" if $agentnum;
+ $where .= " AND ".
+ $FS::CurrentUser::CurrentUser->agentnums_sql('table' => 'cust_main');
+
+ my $total_sql = " SELECT SUM(part_pkg.recur_cost) ";
+ $total_sql .= " FROM cust_pkg
+ LEFT JOIN cust_main USING ( custnum )
+ LEFT JOIN part_pkg USING ( pkgpart )
+ WHERE pkgnum != 0
+ $where
+ AND cust_pkg.setup < $eperiod
+ AND (cust_pkg.cancel > $speriod OR cust_pkg.cancel IS NULL)
+ ";
+ return $self->scalar_sql($total_sql);
+}
+
sub cust_bill_pkg {
my( $self, $speriod, $eperiod, $agentnum, %opt ) = @_;
More information about the freeside-commits
mailing list