summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormark <mark>2010-10-12 00:00:17 +0000
committermark <mark>2010-10-12 00:00:17 +0000
commitced232ee415f7c3d85f06a4581040c493c01f574 (patch)
tree0d2361f8205869013f759e677baf12966f683f9a
parent94d9f31448e3264c36f1590719cd9253d81ea0ae (diff)
expiration month always 2 digits, RT#10161
-rw-r--r--FS/FS/cust_main.pm15
1 files changed, 13 insertions, 2 deletions
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;
}