X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FReport%2FTable%2FMonthly.pm;h=6daa02637a0751957c88b1a4f0b60b1ebbc943d0;hb=8e21a8c2ce7617a64ec962b3933c77a868682b94;hp=33fdfd80c02cfb28b63023a4ad28b71fe29f6026;hpb=5e05724a635a22776f1b973f5d7e77989da4e048;p=freeside.git diff --git a/FS/FS/Report/Table/Monthly.pm b/FS/FS/Report/Table/Monthly.pm index 33fdfd80c..6daa02637 100644 --- a/FS/FS/Report/Table/Monthly.pm +++ b/FS/FS/Report/Table/Monthly.pm @@ -228,6 +228,21 @@ sub credits { ); } +sub netcredits { + my( $self, $speriod, $eperiod, $agentnum ) = @_; + $self->scalar_sql(" + SELECT SUM(cust_credit_bill.amount) + FROM cust_credit_bill + LEFT JOIN cust_bill USING ( invnum ) + LEFT JOIN cust_main USING ( custnum ) + WHERE ". $self->in_time_period_and_agent( $speriod, + $eperiod, + $agentnum, + 'cust_bill._date' + ) + ); +} + #these should be auto-generated or $AUTOLOADed or something sub invoiced_12mo { my( $self, $speriod, $eperiod, $agentnum ) = @_; @@ -259,6 +274,12 @@ sub credits_12mo { $self->credits($speriod, $eperiod, $agentnum); } +sub netcredits_12mo { + my( $self, $speriod, $eperiod, $agentnum ) = @_; + $speriod = $self->_subtract_11mo($speriod); + $self->netcredits($speriod, $eperiod, $agentnum); +} + #not being too bad with the false laziness use Time::Local qw(timelocal); sub _subtract_11mo {