default census_year to 2012 going forward, for 2010 census tracts
[freeside.git] / FS / FS / cust_main.pm
index da40824..f3f6602 100644 (file)
@@ -465,7 +465,7 @@ sub insert {
 
   $self->signupdate(time) unless $self->signupdate;
 
-  $self->censusyear($conf->config('census_year')) if $self->censustract;
+  $self->censusyear($conf->config('census_year')||'2012') if $self->censustract;
 
   $self->auto_agent_custid()
     if $conf->config('cust_main-auto_agent_custid') && ! $self->agent_custid;
@@ -1534,7 +1534,7 @@ sub replace {
 
   if ( $self->censustract ne '' and $self->censustract ne $old->censustract ) {
     # update censusyear whenever tract code changes
-    $self->censusyear($conf->config('census_year'));
+    $self->censusyear($conf->config('census_year')||'2012');
   }
 
 
@@ -5036,6 +5036,12 @@ sub process_censustract_update {
     # then it's a tract code
         $cust_main->set('censustract', $new_tract);
     $cust_main->set('censusyear',  $new_year);
+
+    local($ignore_expired_card) = 1;
+    local($ignore_illegal_zip) = 1;
+    local($ignore_banned_card) = 1;
+    local($skip_fuzzyfiles) = 1;
+    local($import) = 1; #prevent automatic geocoding (need its own variable?)
     my $error = $cust_main->replace;
     die $error if $error;
   }
@@ -5054,7 +5060,7 @@ sub _upgrade_data { #class method
     'UPDATE cust_main SET signupdate = (SELECT signupdate FROM h_cust_main WHERE signupdate IS NOT NULL AND h_cust_main.custnum = cust_main.custnum ORDER BY historynum DESC LIMIT 1) WHERE signupdate IS NULL',
   );
   # fix yyyy-m-dd formatted paydates
-  if ( driver_name =~ /^mysql$/i ) {
+  if ( driver_name =~ /^mysql/i ) {
     push @statements,
     "UPDATE cust_main SET paydate = CONCAT( SUBSTRING(paydate FROM 1 FOR 5), '0', SUBSTRING(paydate FROM 6) ) WHERE SUBSTRING(paydate FROM 7 FOR 1) = '-'";
   }
@@ -5063,6 +5069,10 @@ sub _upgrade_data { #class method
     "UPDATE cust_main SET paydate = SUBSTRING(paydate FROM 1 FOR 5) || '0' || SUBSTRING(paydate FROM 6) WHERE SUBSTRING(paydate FROM 7 FOR 1) = '-'";
   }
 
+  push @statements, #fix the weird BILL with a cc# in payinfo problem
+    #DCRD to be safe
+    "UPDATE cust_main SET payby = 'DCRD' WHERE payby = 'BILL' and length(payinfo) = 16 and payinfo ". regexp_sql. q( '^[0-9]*$' );
+
   foreach my $sql ( @statements ) {
     my $sth = dbh->prepare($sql) or die dbh->errstr;
     $sth->execute or die $sth->errstr;