X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pay_pending.pm;h=dfb07b84d50cef0d27e4be72efffa1649c179e0a;hb=5c1f29673647a123c6ccb0e999676f286ce0b9f6;hp=f5de73dbed90b9e18a4c5b504d2bcc61b5f4df26;hpb=32072dbf59a054529f5304574c0f56f9567d14d0;p=freeside.git diff --git a/FS/FS/cust_pay_pending.pm b/FS/FS/cust_pay_pending.pm index f5de73dbe..dfb07b84d 100644 --- a/FS/FS/cust_pay_pending.pm +++ b/FS/FS/cust_pay_pending.pm @@ -135,6 +135,10 @@ L id. Payment number (L) of the completed payment. +=item void_paynum + +Payment number of the payment if it's been voided. + =item invnum Invoice number (L) to try to apply this payment to. @@ -224,6 +228,7 @@ sub check { || $self->ut_foreign_keyn('paynum', 'cust_pay', 'paynum' ) || $self->ut_foreign_keyn('pkgnum', 'cust_pkg', 'pkgnum') || $self->ut_foreign_keyn('invnum', 'cust_bill', 'invnum') + || $self->ut_foreign_keyn('void_paynum', 'cust_pay_void', 'paynum' ) || $self->ut_flag('manual') || $self->ut_numbern('discount_term') || $self->payinfo_check() #payby/payinfo/paymask/paydate @@ -388,6 +393,8 @@ sub approve { warn $e; return $e; } + + $self->set('jobnum',''); } if ( $opt{'paynum_ref'} ) { @@ -463,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