X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_pay.pm;h=839571a95bcc69f179cf441a8fdc57b7eeb1c162;hp=51c7b29e10f2a39fd9e127809d9e1bf167a57bb5;hb=69c6e80a7253f927af1780a3e0dd3fcf50110599;hpb=88d4198ff452581be05e3018b3e23db564545525 diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 51c7b29e1..839571a95 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -211,14 +211,44 @@ sub upgrade_replace { #1.3.x->1.4.x =item delete -Currently unimplemented (accounting reasons). +Deletes this payment and all associated applications (see L), +unless the closed flag is set. =cut sub delete { my $self = shift; return "Can't delete closed payment" if $self->closed =~ /^Y/i; - $self->SUPER::delete(@_); + + local $SIG{HUP} = 'IGNORE'; + local $SIG{INT} = 'IGNORE'; + local $SIG{QUIT} = 'IGNORE'; + local $SIG{TERM} = 'IGNORE'; + local $SIG{TSTP} = 'IGNORE'; + local $SIG{PIPE} = 'IGNORE'; + + my $oldAutoCommit = $FS::UID::AutoCommit; + local $FS::UID::AutoCommit = 0; + my $dbh = dbh; + + foreach my $cust_bill_pay ( $self->cust_bill_pay ) { + my $error = $cust_bill_pay->delete; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + } + + my $error = $self->SUPER::delete(@_); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return $error; + } + + $dbh->commit or die $dbh->errstr if $oldAutoCommit; + + ''; + } =item replace OLD_RECORD @@ -318,7 +348,7 @@ sub unapplied { =head1 VERSION -$Id: cust_pay.pm,v 1.15 2002-01-29 16:33:15 ivan Exp $ +$Id: cust_pay.pm,v 1.16 2002-02-07 22:29:34 ivan Exp $ =head1 BUGS