[freeside-commits] branch master updated. 1d41419b8faaf6ffb0fc51ba4fbea15bd452e30e

Ivan ivan at 420.am
Mon Aug 12 22:51:32 PDT 2013


The branch, master has been updated
       via  1d41419b8faaf6ffb0fc51ba4fbea15bd452e30e (commit)
       via  c4dc941c6da4b6216d5f8c77ddca10961a112578 (commit)
      from  b8fdc26451c2ed4149d667c835f80add626dd4e1 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1d41419b8faaf6ffb0fc51ba4fbea15bd452e30e
Merge: c4dc941 b8fdc26
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Aug 12 22:51:28 2013 -0700

    Merge branch 'master' of git.freeside.biz:/home/git/freeside


commit c4dc941c6da4b6216d5f8c77ddca10961a112578
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Mon Aug 12 22:51:21 2013 -0700

    credit card search, RT#24428

diff --git a/FS/FS/cust_main/Search.pm b/FS/FS/cust_main/Search.pm
index e0c7080..6c79315 100644
--- a/FS/FS/cust_main/Search.pm
+++ b/FS/FS/cust_main/Search.pm
@@ -9,6 +9,7 @@ use FS::Record qw( qsearch );
 use FS::cust_main;
 use FS::cust_main_invoice;
 use FS::svc_acct;
+use FS::payinfo_Mixin;
 
 @EXPORT_OK = qw( smart_search );
 
@@ -50,8 +51,12 @@ FS::cust_main::Search - Customer searching
 
 Accepts the following options: I<search>, the string to search for.  The string
 will be searched for as a customer number, phone number, name or company name,
-as an exact, or, in some cases, a substring or fuzzy match (see the source code
-for the exact heuristics used); I<no_fuzzy_on_exact>, causes smart_search to
+address (if address1-search is on), invoicing email address, or credit card
+number.
+
+Searches match as an exact, or, in some cases, a substring or fuzzy match (see
+the source code for the exact heuristics used); I<no_fuzzy_on_exact>, causes
+smart_search to
 skip fuzzy matching when an exact match is found.
 
 Any additional options are treated as an additional qualifier on the search
@@ -109,12 +114,10 @@ sub smart_search {
 
     }
 
-  # custnum search (also try agent_custid), with some tweaking options if your
-  # legacy cust "numbers" have letters
   } 
   
   
-  if ( $search =~ /@/ ) {
+  if ( $search =~ /@/ ) { #invoicing email address
       push @cust_main,
 	  map $_->cust_main,
 	      qsearch( {
@@ -122,6 +125,9 @@ sub smart_search {
 			 'hashref'   => { 'dest' => $search },
 		       }
 		     );
+
+  # custnum search (also try agent_custid), with some tweaking options if your
+  # legacy cust "numbers" have letters
   } elsif ( $search =~ /^\s*(\d+)\s*$/
          || ( $conf->config('cust_main-agent_custid-format') eq 'ww?d+'
               && $search =~ /^\s*(\w\w?\d+)\s*$/
@@ -364,6 +370,28 @@ sub smart_search {
 
   }
 
+  ( my $nospace_search = $search ) =~ s/\s//g;
+  ( my $card_search = $nospace_search ) =~ s/\-//g;
+  $card_search =~ s/[x\*\.\_]/x/gi;
+  
+  if ( $nospace_search =~ /^[\dx]{16}$/i ) { #credit card search
+
+    ( my $like_search = $card_search ) =~ s/x/_/g;
+    my $mask_search = FS::payinfo_Mixin->mask_payinfo('CARD', $card_search);
+
+    push @cust_main, qsearch({
+      'table'     => 'cust_main',
+      'hashref'   => {},
+      'extra_sql' => " WHERE (    payinfo LIKE '$like_search'
+                               OR paymask =    '$mask_search'
+                             ) ".
+                     " AND payby IN ('CARD','DCRD') ".
+                     " AND $agentnums_sql", #agent virtulization
+    });
+
+  }
+  
+
   #eliminate duplicates
   my %saw = ();
   @cust_main = grep { !$saw{$_->custnum}++ } @cust_main;
diff --git a/FS/FS/payinfo_Mixin.pm b/FS/FS/payinfo_Mixin.pm
index 8263252..5c4acf7 100644
--- a/FS/FS/payinfo_Mixin.pm
+++ b/FS/FS/payinfo_Mixin.pm
@@ -127,7 +127,7 @@ sub mask_payinfo {
   my $payinfo = scalar(@_) ? shift : $self->payinfo;
 
   # Check to see if it's encrypted...
-  if ( $self->is_encrypted($payinfo) ) {
+  if ( ref($self) && $self->is_encrypted($payinfo) ) {
     return 'N/A';
   } elsif ( $payinfo =~ /^99\d{14}$/ || $payinfo eq 'N/A' ) { #token
     return 'N/A (tokenized)'; #?

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cust_main/Search.pm |   38 +++++++++++++++++++++++++++++++++-----
 FS/FS/payinfo_Mixin.pm    |    2 +-
 2 files changed, 34 insertions(+), 6 deletions(-)




More information about the freeside-commits mailing list