Merge branch 'master' of git.freeside.biz:/home/git/freeside
authorIvan Kohler <ivan@freeside.biz>
Tue, 14 Feb 2017 16:33:21 +0000 (08:33 -0800)
committerIvan Kohler <ivan@freeside.biz>
Tue, 14 Feb 2017 16:33:21 +0000 (08:33 -0800)
FS/FS/Schema.pm
FS/FS/cust_main/Billing_Realtime.pm
FS/FS/cust_payby.pm
FS/FS/payinfo_Mixin.pm

index 1630f02..b6d0f07 100644 (file)
@@ -1620,6 +1620,8 @@ sub tables_hashref {
         'ship_mobile',   'varchar', 'NULL', 12, '', '', 
         'currency',         'char', 'NULL',  3, '', '',
 
+        'is_tokenized', 'char', 'NULL', '1', '', '',
+
         'geocode',  'varchar', 'NULL', 20,  '', '',
         'censustract', 'varchar', 'NULL', 20,  '', '', # 7 to save space?
         'censusyear', 'char', 'NULL', 4, '', '',
@@ -1666,6 +1668,7 @@ sub tables_hashref {
                           [ 'archived' ],
                           [ 'ship_locationnum' ],
                           [ 'bill_locationnum' ],
+                          [ 'is_tokenized' ],
                         ],
       'foreign_keys' => [
                           { columns    => [ 'agentnum' ],
@@ -1718,10 +1721,11 @@ sub tables_hashref {
         'paytype',     'varchar', 'NULL',   $char_d, '', '', 
         'payip',       'varchar', 'NULL',        15, '', '', 
         'locationnum',     'int', 'NULL',        '', '', '',
+        'is_tokenized',   'char', 'NULL',         1, '', '', 
       ],
       'primary_key'  => 'custpaybynum',
       'unique'       => [],
-      'index'        => [ [ 'custnum' ] ],
+      'index'        => [ [ 'custnum' ], [ 'is_tokenized' ] ],
       'foreign_keys' => [
                           { columns    => [ 'custnum' ],
                             table      => 'cust_main',
@@ -2415,11 +2419,13 @@ sub tables_hashref {
         'manual',       'char',    'NULL',   1, '', '',
         'discount_term','int',     'NULL',  '', '', '',
         'failure_status','varchar','NULL',  16, '', '',
+        'is_tokenized',   'char', 'NULL',    1, '', '', 
       ],
       'primary_key'  => 'paypendingnum',
       'unique'       => [ [ 'payunique' ] ],
       'index'        => [ [ 'custnum' ], [ 'status' ],
                           ['paynum'], ['void_paynum'], ['jobnum'], ['invnum'],
+                          [ 'is_tokenized' ],
                         ],
       'foreign_keys' => [
                           { columns    => [ 'custnum' ],
@@ -2466,7 +2472,8 @@ sub tables_hashref {
         'closed',         'char', 'NULL',       1, '', '', 
         'pkgnum', 'int', 'NULL', '', '', '', #desired pkgnum for pkg-balances
         'no_auto_apply',  'char', 'NULL',       1, '', '', 
-
+        'is_tokenized',   'char', 'NULL',       1, '', '', 
+          
         # cash/check deposit info fields
         'bank',        'varchar', 'NULL', $char_d, '', '',
         'depositor',   'varchar', 'NULL', $char_d, '', '',
@@ -2484,7 +2491,7 @@ sub tables_hashref {
       'primary_key'  => 'paynum',
       #i guess not now, with cust_pay_pending, if we actually make it here, we _do_ want to record it# 'unique' => [ [ 'payunique' ] ],
       'index'        => [ ['custnum'], ['paybatch'], ['payby'], ['_date'],
-                          ['usernum'],
+                          ['usernum'], ['is_tokenized'], 
                         ],
       'foreign_keys' => [
                           { columns    => [ 'custnum' ],
@@ -2522,6 +2529,7 @@ sub tables_hashref {
         'paybatch',    'varchar', 'NULL', $char_d, '', '', #for auditing purposes.
         'closed',        'char',  'NULL',       1, '', '', 
         'pkgnum', 'int',   'NULL', '', '', '', #desired pkgnum for pkg-balances
+        'is_tokenized',   'char', 'NULL',       1, '', '', 
 
         # cash/check deposit info fields
         'bank',       'varchar', 'NULL', $char_d, '', '',
@@ -2544,7 +2552,9 @@ sub tables_hashref {
       ],
       'primary_key'  => 'paynum',
       'unique'       => [],
-      'index'        => [ ['custnum'], ['usernum'], ['void_usernum'] ],
+      'index'        => [ ['custnum'], ['usernum'], ['void_usernum'],
+                          ['is_tokenized'],
+                        ],
       'foreign_keys' => [
                           { columns    => [ 'custnum' ],
                             table      => 'cust_main',
@@ -3086,10 +3096,11 @@ sub tables_hashref {
         'processor',  'varchar', 'NULL', $char_d, '', '', # module name
         'auth',       'varchar','NULL',16, '', '', # CC auth number
         'order_number', 'varchar','NULL',$char_d, '', '', # transaction number
+        'is_tokenized',   'char', 'NULL',    1, '', '', 
       ],
       'primary_key'  => 'refundnum',
       'unique'       => [],
-      'index'        => [ ['custnum'], ['_date'], [ 'usernum' ], ],
+      'index'        => [ ['custnum'], ['_date'], [ 'usernum' ], ['is_tokenized'] ],
       'foreign_keys' => [
                           { columns    => [ 'custnum' ],
                             table      => 'cust_main',
index c2cb2e3..0623fbb 100644 (file)
@@ -2718,6 +2718,7 @@ sub _token_check_next_recnum {
   my $sth = $dbh->prepare(
     'SELECT '.$tclass->primary_key.
     ' FROM '.$table.
+    " WHERE ( is_tokenized IS NULL OR is_tokenized = '' ) ".
     ' ORDER BY '.$tclass->primary_key.
     ' LIMIT '.$step.
     ' OFFSET '.$$offset
index 136acf1..7e4a465 100644 (file)
@@ -359,6 +359,7 @@ sub check {
     # see parallel checks in check_payinfo_cardtype & payinfo_Mixin::payinfo_check
     my $cardtype = $self->paycardtype;
     if ( $self->tokenized ) {
+      $self->('is_tokenized', 'Y'); #so we don't try to do it again
       if ( $self->paymask =~ /^\d+x/ ) {
         $cardtype = cardtype($self->paymask);
       } else {
@@ -559,6 +560,7 @@ sub check_payinfo_cardtype {
 
   # see parallel checks in cust_payby::check & payinfo_Mixin::payinfo_check
   if ( $self->tokenized($payinfo) ) {
+    $self->set('is_tokenized', 'Y'); #so we don't try to do it again
     if ( $self->paymask =~ /^\d+x/ ) {
       $self->set('paycardtype', cardtype($self->paymask));
     } else {
index 84759cc..c79729a 100644 (file)
@@ -199,6 +199,7 @@ sub payinfo_check {
 
     # see parallel checks in cust_payby::check & cust_payby::check_payinfo_cardtype
     if ( $self->tokenized ) {
+      $self->('is_tokenized', 'Y'); #so we don't try to do it again
       if ( $self->paymask =~ /^\d+x/ ) {
         $self->set('paycardtype', cardtype($self->paymask));
       } else {