X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=FS%2FFS%2Fcust_refund.pm;h=2d5b3aaae1ff770fd3d5818e304702b8acffb147;hb=3653b9063c8114a1977234bd0957593009c5d577;hp=4d2baa51486f09c6bfb4240f6234b5ca61c7f77c;hpb=c22d84e565ab16db142395dce2e8621624eff140;p=freeside.git diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm index 4d2baa514..2d5b3aaae 100644 --- a/FS/FS/cust_refund.pm +++ b/FS/FS/cust_refund.pm @@ -289,7 +289,8 @@ otherwise returns false. sub replace { my $self = shift; - return "Can't modify closed refund" if $self->closed =~ /^Y/i; + return "Can't modify closed refund" + if $self->closed =~ /^Y/i && !$FS::payinfo_Mixin::allow_closed_replace; $self->SUPER::replace(@_); } @@ -471,6 +472,19 @@ sub unapplied_sql { } +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) = @_;