YA otaker upgrade kludge for old datasets: cust_pay.payby COMP
[freeside.git] / FS / FS / cust_main.pm
index 8764c88..007d6e4 100644 (file)
@@ -8,7 +8,8 @@ use base qw( FS::cust_main::Billing FS::cust_main::Billing_Realtime
            );
 use vars qw( $DEBUG $me $conf
              @encrypted_fields
-             $import $ignore_expired_card
+             $import
+             $ignore_expired_card $ignore_illegal_zip $ignore_banned_card
              $skip_fuzzyfiles @fuzzyfields
              @paytypes
            );
@@ -75,6 +76,8 @@ $me = '[FS::cust_main]';
 
 $import = 0;
 $ignore_expired_card = 0;
+$ignore_illegal_zip = 0;
+$ignore_banned_card = 0;
 
 $skip_fuzzyfiles = 0;
 @fuzzyfields = ( 'first', 'last', 'company', 'address1' );
@@ -1800,10 +1803,14 @@ sub check {
     $self->ut_phonen('daytime', $self->country)
     || $self->ut_phonen('night', $self->country)
     || $self->ut_phonen('fax', $self->country)
-    || $self->ut_zip('zip', $self->country)
   ;
   return $error if $error;
 
+  unless ( $ignore_illegal_zip ) {
+    $error = $self->ut_zip('zip', $self->country);
+    return $error if $error;
+  }
+
   if ( $conf->exists('cust_main-require_phone')
        && ! length($self->daytime) && ! length($self->night)
      ) {
@@ -1856,10 +1863,13 @@ sub check {
       $self->ut_phonen('ship_daytime', $self->ship_country)
       || $self->ut_phonen('ship_night', $self->ship_country)
       || $self->ut_phonen('ship_fax', $self->ship_country)
-      || $self->ut_zip('ship_zip', $self->ship_country)
     ;
     return $error if $error;
 
+    unless ( $ignore_illegal_zip ) {
+      $error = $self->ut_zip('ship_zip', $self->ship_country);
+      return $error if $error;
+    }
     return "Unit # is required."
       if $self->ship_address2 =~ /^\s*$/
       && $conf->exists('cust_main-require_address2');
@@ -1914,12 +1924,14 @@ sub check {
       if $self->payinfo !~ /^99\d{14}$/ #token
       && cardtype($self->payinfo) eq "Unknown";
 
-    my $ban = qsearchs('banned_pay', $self->_banned_pay_hashref);
-    if ( $ban ) {
-      return 'Banned credit card: banned on '.
-             time2str('%a %h %o at %r', $ban->_date).
-             ' by '. $ban->otaker.
-             ' (ban# '. $ban->bannum. ')';
+    unless ( $ignore_banned_card ) {
+      my $ban = qsearchs('banned_pay', $self->_banned_pay_hashref);
+      if ( $ban ) {
+        return 'Banned credit card: banned on '.
+               time2str('%a %h %o at %r', $ban->_date).
+               ' by '. $ban->otaker.
+               ' (ban# '. $ban->bannum. ')';
+      }
     }
 
     if (length($self->paycvv) && !$self->is_encrypted($self->paycvv)) {
@@ -5537,7 +5549,9 @@ sub _upgrade_data { #class method
   $sth->execute or die $sth->errstr;
 
   local($ignore_expired_card) = 1;
-  local($skip_fuzzyfiles) = 1;
+  local($ignore_illegal_zip) = 1;
+  local($ignore_illegal_zip) = 1;
+  local($ignore_banned_card) = 1;
   $class->_upgrade_otaker(%opts);
 
 }