X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pay_pending.pm;h=dfb07b84d50cef0d27e4be72efffa1649c179e0a;hb=3cbdd85a96348a287623e3b97c937c7749e99392;hp=63274b18462629dd33a2b888a0685b3f76f0a4be;hpb=beff2bed3d06a91072427a15efef08b24c7cc8df;p=freeside.git diff --git a/FS/FS/cust_pay_pending.pm b/FS/FS/cust_pay_pending.pm index 63274b184..dfb07b84d 100644 --- a/FS/FS/cust_pay_pending.pm +++ b/FS/FS/cust_pay_pending.pm @@ -393,6 +393,8 @@ sub approve { warn $e; return $e; } + + $self->set('jobnum',''); } if ( $opt{'paynum_ref'} ) { @@ -468,6 +470,19 @@ sub _upgrade_data { #class method } +sub _upgrade_schema { + my ($class, %opts) = @_; + + # fix records where jobnum points to a nonexistent queue job + my $sql = 'UPDATE cust_pay_pending SET jobnum = NULL + WHERE NOT EXISTS ( + SELECT 1 FROM queue WHERE queue.jobnum = cust_pay_pending.jobnum + )'; + my $sth = dbh->prepare($sql) or die dbh->errstr; + $sth->execute or die $sth->errstr; + ''; +} + =back =head1 BUGS