[freeside-commits] freeside/FS/FS cust_main.pm,1.558,1.559

Mark Wells mark at wavetail.420.am
Mon Oct 11 17:00:19 PDT 2010


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv22148/FS/FS

Modified Files:
	cust_main.pm 
Log Message:
expiration month always 2 digits, RT#10161

Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.558
retrieving revision 1.559
diff -u -w -d -r1.558 -r1.559
--- cust_main.pm	11 Oct 2010 19:00:32 -0000	1.558
+++ cust_main.pm	12 Oct 2010 00:00:17 -0000	1.559
@@ -4516,10 +4516,21 @@
 sub _upgrade_data { #class method
   my ($class, %opts) = @_;
 
-  foreach my $sql (
+  my @statements = (
     'UPDATE h_cust_main SET paycvv = NULL WHERE paycvv IS NOT NULL',
     '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 ) {
+    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) = '-'";
+  }
+  else { # the SQL standard
+    push @statements, 
+    "UPDATE cust_main SET paydate = SUBSTRING(paydate FROM 1 FOR 5) || '0' || SUBSTRING(paydate FROM 6) WHERE SUBSTRING(paydate FROM 7 FOR 1) = '-'";
+  }
+
+  foreach my $sql ( @statements ) {
     my $sth = dbh->prepare($sql) or die dbh->errstr;
     $sth->execute or die $sth->errstr;
   }



More information about the freeside-commits mailing list