summaryrefslogtreecommitdiff
path: root/FS/FS/cust_svc.pm
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-10-01 12:30:58 -0700
committerMark Wells <mark@freeside.biz>2013-10-01 12:32:33 -0700
commit201962afb41285b50dc853028b7b1f1ef83039d2 (patch)
tree6c856792361db0ed499569985a565583a61c09cc /FS/FS/cust_svc.pm
parentce86623467df8a58fc8833a490ff69f447df4b25 (diff)
when a service is deleted, transfer its tickets to the owning customer, #25180
Diffstat (limited to 'FS/FS/cust_svc.pm')
-rw-r--r--FS/FS/cust_svc.pm14
1 files changed, 13 insertions, 1 deletions
diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm
index d6d7d4c..9582090 100644
--- a/FS/FS/cust_svc.pm
+++ b/FS/FS/cust_svc.pm
@@ -113,6 +113,10 @@ my $rt_session;
sub delete {
my $self = shift;
+
+ my $cust_pkg = $self->cust_pkg;
+ my $custnum = $cust_pkg->custnum if $cust_pkg;
+
my $error = $self->SUPER::delete;
return $error if $error;
@@ -126,7 +130,15 @@ sub delete {
$links->Limit(FIELD => 'Target',
VALUE => 'freeside://freeside/cust_svc/'.$svcnum);
while ( my $l = $links->Next ) {
- my ($val, $msg) = $l->Delete;
+ my ($val, $msg);
+ if ( $custnum ) {
+ # re-link to point to the customer instead
+ ($val, $msg) =
+ $l->SetTarget('freeside://freeside/cust_main/'.$custnum);
+ } else {
+ # unlinked service
+ ($val, $msg) = $l->Delete;
+ }
# can't do anything useful on error
warn "error unlinking ticket $svcnum: $msg\n" if !$val;
}