[freeside-commits] freeside/FS/FS cust_event.pm, 1.7, 1.8 cust_main_Mixin.pm, 1.6, 1.7

Ivan,,, ivan at wavetail.420.am
Fri Oct 30 16:29:20 PDT 2009


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

Modified Files:
	cust_event.pm cust_main_Mixin.pm 
Log Message:
more reporting options for failed billing events, RT#6447

Index: cust_main_Mixin.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main_Mixin.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cust_main_Mixin.pm	15 Sep 2009 20:44:00 -0000	1.6
+++ cust_main_Mixin.pm	30 Oct 2009 23:29:18 -0000	1.7
@@ -1,11 +1,12 @@
 package FS::cust_main_Mixin;
 
 use strict;
-use vars qw( $DEBUG );
+use vars qw( $DEBUG $me );
 use FS::UID qw(dbh);
 use FS::cust_main;
 
 $DEBUG = 0;
+$me = '[FS::cust_main_Mixin]';
 
 =head1 NAME
 
@@ -273,6 +274,60 @@
   die $@ if $@;
 }
 
+=item cust_search_sql
+
+Returns a list of SQL WHERE fragments to search for parameters specified
+in HASHREF.  Valid parameters are:
+
+=over 4
+
+=item agentnum
+
+=item status
+
+=item payby
+
+=back
+
+=cut
+
+sub cust_search_sql {
+  my($class, $param) = @_;
+
+  if ( $DEBUG ) {
+    warn "$me cust_search_sql called with params: \n".
+         join("\n", map { "  $_: ". $param->{$_} } keys %$param ). "\n";
+  }
+
+  my @search = ();
+
+  if ( $param->{'agentnum'} && $param->{'agentnum'} =~ /^(\d+)$/ ) {
+    push @search, "cust_main.agentnum = $1";
+  }
+
+  #status (prospect active inactive suspended cancelled)
+  if ( grep { $param->{'status'} eq $_ } FS::cust_main->statuses() ) {
+    my $method = $param->{'status'}. '_sql';
+    push @search, $class->$method();
+  }
+
+  #payby
+  my @payby = ref($param->{'payby'})
+                ? @{ $param->{'payby'} }
+                : split(',', $param->{'payby'});
+  @payby = grep /^([A-Z]{4})$/, @payby;
+  if ( @payby ) {
+    push @search, 'cust_main.payby IN ('. join(',', map "'$_'", @payby). ')';
+  }
+
+  #here is the agent virtualization
+  push @search,
+    $FS::CurrentUser::CurrentUser->agentnums_sql( 'table' => 'cust_main' );
+  
+  return @search;
+
+}
+
 =back
 
 =head1 BUGS

Index: cust_event.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_event.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cust_event.pm	25 Jul 2009 21:33:08 -0000	1.7
+++ cust_event.pm	30 Oct 2009 23:29:18 -0000	1.8
@@ -322,9 +322,23 @@
 
 =over 4
 
-=item
+=item agentnum
 
-=item
+=item custnum
+
+=item invnum
+
+=item pkgnum
+
+=item failed
+
+=item beginning
+
+=item ending
+
+=item payby
+
+=item 
 
 =back
 
@@ -340,12 +354,15 @@
          join("\n", map { "  $_: ". $param->{$_} } keys %$param ). "\n";
   }
 
-  my @search = ();
+  my @search = $class->cust_search_sql($param);
 
-  if ( $param->{'agentnum'} && $param->{'agentnum'} =~ /^(\d+)$/ ) {
-    push @search, "cust_main.agentnum = $1";
-    #my $agent = qsearchs('agent', { 'agentnum' => $1 } );
-    #die "unknown agentnum $1" unless $agent;
+  #eventpart
+  my @eventpart = ref($param->{'eventpart'})
+                    ? @{ $param->{'eventpart'} }
+                    : split(',', $param->{'eventpart'});
+  @eventpart = grep /^(\d+)$/, @eventpart;
+  if ( @eventpart ) {
+    push @search, 'eventpart IN ('. join(',', @eventpart). ')';
   }
 
   if ( $param->{'beginning'} =~ /^(\d+)$/ ) {
@@ -361,10 +378,6 @@
                   "statustext != 'N/A'";
   }
 
-  #if ( $param->{'part_event.payby'} =~ /^(\w+)$/ ) {
-  #  push @search, "part_event.payby = '$1'";
-  #}
-
   if ( $param->{'custnum'} =~ /^(\d+)$/ ) {
     push @search, "cust_main.custnum = '$1'";
   }
@@ -379,13 +392,8 @@
                   "tablenum = '$1'";
   }
 
-  #here is the agent virtualization
-  push @search,
-    $FS::CurrentUser::CurrentUser->agentnums_sql( 'table' => 'cust_main' );
-
   my $where = 'WHERE '. join(' AND ', @search );
 
-
   join(' AND ', @search );
 
 }



More information about the freeside-commits mailing list