summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2016-06-07 13:57:12 -0700
committerMark Wells <mark@freeside.biz>2016-06-07 19:13:07 -0700
commit0de4928e4afae5542b310eeb1ef0cff4750cb038 (patch)
tree22a8653ac2c029d9557b2983ac3495d6f720c3ab
parent47d5558991d119d7b8fbd9e8256a78776af5d585 (diff)
partially unwrap cust_main->cancel_pkgs
-rw-r--r--FS/FS/cust_main.pm22
1 files changed, 11 insertions, 11 deletions
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 9ba1129e5..ecd30702f 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -2174,7 +2174,10 @@ reason and reason_otaker arguments will be taken from those objects.
sub cancel_pkgs {
my( $self, %opt ) = @_;
- my $oldAutoCommit = $FS::UID::AutoCommit;
+ # we're going to cancel services, which is not reversible
+ die "cancel_pkgs cannot be run inside a transaction"
+ if $FS::UID::AutoCommit == 0;
+
local $FS::UID::AutoCommit = 0;
return ( 'access denied' )
@@ -2193,7 +2196,7 @@ sub cancel_pkgs {
my $ban = new FS::banned_pay $cust_payby->_new_banned_pay_hashref;
my $error = $ban->insert;
if ($error) {
- dbh->rollback if $oldAutoCommit;
+ dbh->rollback;
return ( $error );
}
@@ -2213,13 +2216,16 @@ sub cancel_pkgs {
'time' => $cancel_time );
if ($error) {
warn "Error billing during cancel, custnum ". $self->custnum. ": $error";
- dbh->rollback if $oldAutoCommit;
+ dbh->rollback;
return ( "Error billing during cancellation: $error" );
}
}
+ dbh->commit;
+ $FS::UID::AutoCommit = 1;
my @errors;
- # now cancel all services, the same way we would for individual packages
+ # now cancel all services, the same way we would for individual packages.
+ # if any of them fail, cancel the rest anyway.
my @cust_svc = map { $_->cust_svc } @pkgs;
my @sorted_cust_svc =
map { $_->[0] }
@@ -2236,7 +2242,6 @@ sub cancel_pkgs {
push @errors, $error if $error;
}
if (@errors) {
- dbh->rollback if $oldAutoCommit;
return @errors;
}
@@ -2259,12 +2264,7 @@ sub cancel_pkgs {
push @errors, 'pkgnum '.$_->pkgnum.': '.$error if $error;
}
- if (@errors) {
- dbh->rollback if $oldAutoCommit;
- return @errors;
- }
-
- return;
+ return @errors;
}
sub _banned_pay_hashref {