summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2017-01-25 11:26:49 -0800
committerIvan Kohler <ivan@freeside.biz>2017-01-25 11:26:49 -0800
commit61bd7e302ca504d1321981a51f389fa01d5a5187 (patch)
treee4de405c1c0e84ac55df4fa016329936d6fafa16
parent4eb3eff789fa9535a1e2d37d52bfeaf9e5a7e5ca (diff)
fix encryption upgrades when a payment is refunded, then deleted. RT#74270, RT#73085
-rw-r--r--FS/FS/cust_refund.pm13
1 files changed, 13 insertions, 0 deletions
diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm
index 4affb151a..44d4d97d6 100644
--- a/FS/FS/cust_refund.pm
+++ b/FS/FS/cust_refund.pm
@@ -515,6 +515,19 @@ sub reason {
( $self->addlinfo ? ' '.$self->addlinfo : '' );
}
+sub _upgrade_schema {
+ #my ($class, %opts) = @_;
+
+ my $sql = 'UPDATE cust_refund SET source_paynum = NULL
+ WHERE source_paynum IS NOT NULL
+ AND NOT EXISTS ( SELECT 1 FROM cust_pay
+ WHERE paynum = cust_refund.source_paynum )
+ ';
+ my $sth = dbh->prepare($sql) or die dbh->errstr;
+ $sth->execute or die $sth->errstr;
+ '';
+}
+
# Used by FS::Upgrade to migrate to a new database.
sub _upgrade_data { # class method
my ($class, %opts) = @_;