summaryrefslogtreecommitdiff
path: root/FS/FS/cust_refund.pm
diff options
context:
space:
mode:
authorjeff <jeff>2007-01-08 17:36:53 +0000
committerjeff <jeff>2007-01-08 17:36:53 +0000
commitb89c7f126690704c8d1558dba06d5fabd7470528 (patch)
tree7a1ce8e2d5675952f4a06472897cab9d19e01037 /FS/FS/cust_refund.pm
parent704992901b980cd3d41568d7fec0842b2a64bdf7 (diff)
refund deletion
Diffstat (limited to 'FS/FS/cust_refund.pm')
-rw-r--r--FS/FS/cust_refund.pm42
1 files changed, 40 insertions, 2 deletions
diff --git a/FS/FS/cust_refund.pm b/FS/FS/cust_refund.pm
index 3f17f9a..9cd9bf8 100644
--- a/FS/FS/cust_refund.pm
+++ b/FS/FS/cust_refund.pm
@@ -166,14 +166,52 @@ sub insert {
=item delete
-Currently unimplemented (accounting reasons).
+Unless the closed flag is set, deletes this refund and all associated
+applications (see L<FS::cust_credit_refund> and L<FS::cust_pay_refund>).
=cut
sub delete {
my $self = shift;
return "Can't delete closed refund" 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_credit_refund ( $self->cust_credit_refund ) {
+ my $error = $cust_credit_refund->delete;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return $error;
+ }
+ }
+
+ foreach my $cust_pay_refund ( $self->cust_pay_refund ) {
+ my $error = $cust_pay_refund->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