add a netcredits_12mo sub so that 12mo checkbox works again... sure do need these...
[freeside.git] / FS / FS / Report / Table / Monthly.pm
index 33fdfd8..6daa026 100644 (file)
@@ -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 {