X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pay_pending.pm;h=dfb07b84d50cef0d27e4be72efffa1649c179e0a;hb=d22baa4e71bfa9e153c1fe1152ff4c748f1d935c;hp=572a2ade2c288eae9bbc6a52a4610dd06d820d37;hpb=8cc50a2ad12ec3d5bd3f31db741290664064ef06;p=freeside.git diff --git a/FS/FS/cust_pay_pending.pm b/FS/FS/cust_pay_pending.pm index 572a2ade2..dfb07b84d 100644 --- a/FS/FS/cust_pay_pending.pm +++ b/FS/FS/cust_pay_pending.pm @@ -1,16 +1,11 @@ package FS::cust_pay_pending; +use base qw( FS::payinfo_transaction_Mixin FS::cust_main_Mixin FS::Record ); use strict; -use vars qw( @ISA @encrypted_fields ); -use FS::Record qw( qsearch qsearchs dbh ); #dbh for _upgrade_data -use FS::payinfo_transaction_Mixin; -use FS::cust_main_Mixin; -use FS::cust_main; -use FS::cust_pkg; +use vars qw( @encrypted_fields ); +use FS::Record qw( qsearchs dbh ); #dbh for _upgrade_data use FS::cust_pay; -@ISA = qw( FS::payinfo_transaction_Mixin FS::cust_main_Mixin FS::Record ); - @encrypted_fields = ('payinfo'); sub nohistory_fields { ('payinfo'); } @@ -140,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. @@ -229,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 @@ -260,12 +260,6 @@ Returns the associated L record if any. Otherwise returns false. =cut -sub cust_main { - my $self = shift; - qsearchs('cust_main', { custnum => $self->custnum } ); -} - - #these two are kind-of false laziness w/cust_main::realtime_bop #(currently only used when resolving pending payments manually) @@ -399,6 +393,8 @@ sub approve { warn $e; return $e; } + + $self->set('jobnum',''); } if ( $opt{'paynum_ref'} ) { @@ -474,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