From: mark Date: Tue, 12 Oct 2010 00:00:17 +0000 (+0000) Subject: expiration month always 2 digits, RT#10161 X-Git-Tag: TORRUS_1_0_9~227 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=ced232ee415f7c3d85f06a4581040c493c01f574 expiration month always 2 digits, RT#10161 --- diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 1f9e3cdaa..7cfdd896b 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -4516,10 +4516,21 @@ sub process_bill_and_collect { 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; }