X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_main.pm;h=54f561309577c2b946491ca4712d84ca7f94a7ea;hb=3994fafc85cc15e59f3eb5dda9015e651631f624;hp=ddddb24d11e635ea97c567f22e1c517c84beddcc;hpb=0271da55f0dcec6473d65e161a8c25616f179b9f;p=freeside.git diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index ddddb24d1..54f561309 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -5761,8 +5761,11 @@ sub queueable_upgrade { FS::upgrade_journal->set_done('clear_payinfo_history'); } - # encrypt old records - if ($conf->exists('encryption') && !FS::upgrade_journal->is_done('encryption_check')) { + # fix Tokenized paycardtype and encrypt old records + if ( ! FS::upgrade_journal->is_done('paycardtype_Tokenized') + || ! FS::upgrade_journal->is_done('encryption_check') + ) + { # allow replacement of closed cust_pay/cust_refund records local $FS::payinfo_Mixin::allow_closed_replace = 1; @@ -5788,6 +5791,7 @@ sub queueable_upgrade { if (!$record->custnum && $table eq 'cust_pay_pending') { $record->set('custnum_pending',1); } + $record->paycardtype('') if $record->paycardtype eq 'Tokenized'; local($ignore_expired_card) = 1; local($ignore_banned_card) = 1; @@ -5795,11 +5799,12 @@ sub queueable_upgrade { local($import) = 1;#prevent automatic geocoding (need its own variable?) my $error = $record->replace; - die $error if $error; + die "Error replacing $table ".$record->get($record->primary_key).": $error" if $error; } } - FS::upgrade_journal->set_done('encryption_check'); + FS::upgrade_journal->set_done('paycardtype_Tokenized'); + FS::upgrade_journal->set_done('encryption_check') if $conf->exists('encryption'); } } @@ -5812,10 +5817,13 @@ sub _upgrade_next_recnum { my $recnum = shift @$recnums; return $recnum if $recnum; my $tclass = 'FS::'.$table; + my $paycardtypecheck = ($table ne 'cust_pay_pending') ? q( OR paycardtype = 'Tokenized') : ''; my $sql = 'SELECT '.$tclass->primary_key. ' FROM '.$table. ' WHERE '.$tclass->primary_key.' > '.$$lastrecnum. - ' ORDER BY '.$tclass->primary_key.' LIMIT 500';; + " AND payby IN ( 'CARD', 'DCRD', 'CHEK', 'DCHK' ) ". + " AND ( length(payinfo) < 80$paycardtypecheck ) ". + ' ORDER BY '.$tclass->primary_key.' LIMIT 500'; my $sth = $dbh->prepare($sql) or die $dbh->errstr; $sth->execute() or die $sth->errstr; my @recnums;