X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fcust_pay_pending.pm;h=b61635d2f10aef4be89c362a6409de6311291b79;hb=47d3ba763306e281c0c4b736877ac8c5d4e9e4a1;hp=8e29f08b670e77006eeb510ffaffadb9cdb5f222;hpb=c9d51796516657eebb115d6295ba3c0e2e08f697;p=freeside.git diff --git a/FS/FS/cust_pay_pending.pm b/FS/FS/cust_pay_pending.pm index 8e29f08b6..b61635d2f 100644 --- a/FS/FS/cust_pay_pending.pm +++ b/FS/FS/cust_pay_pending.pm @@ -12,6 +12,7 @@ use FS::cust_pay; @ISA = qw( FS::payinfo_transaction_Mixin FS::cust_main_Mixin FS::Record ); @encrypted_fields = ('payinfo'); +sub nohistory_fields { ('payinfo'); } =head1 NAME @@ -132,6 +133,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. @@ -220,6 +225,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 @@ -458,6 +464,20 @@ sub _upgrade_data { #class method my $sth = dbh->prepare($sql) or die dbh->errstr; $sth->execute or die $sth->errstr; + # For cust_pay_pending records linked to voided payments, move the paynum + # to void_paynum. + $sql = + "UPDATE cust_pay_pending SET void_paynum = paynum, paynum = NULL + WHERE paynum IS NOT NULL AND void_paynum IS NULL AND EXISTS( + SELECT 1 FROM cust_pay_void + WHERE cust_pay_void.paynum = cust_pay_pending.paynum + ) AND NOT EXISTS( + SELECT 1 FROM cust_pay + WHERE cust_pay.paynum = cust_pay_pending.paynum + )"; + $sth = dbh->prepare($sql) or die dbh->errstr; + $sth->execute or die $sth->errstr; + } =back