summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-04-30 06:10:11 -0700
committerIvan Kohler <ivan@freeside.biz>2015-04-30 06:10:11 -0700
commit8c974f743b0312b5dc9ef26f403b937abb5003d3 (patch)
tree3c901f81cdc378c4f28c57678f6dbe579b534590 /FS/FS
parent47cb646c89d4a798d35063f04db39c707eac4f4c (diff)
service dependencies: cust_svc_unprovision_restrict, RT#33685
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/cust_svc.pm29
-rw-r--r--FS/FS/svc_Common.pm3
2 files changed, 31 insertions, 1 deletions
diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm
index a7aeadaf1..2cf9103f4 100644
--- a/FS/FS/cust_svc.pm
+++ b/FS/FS/cust_svc.pm
@@ -456,6 +456,35 @@ sub check {
$self->SUPER::check;
}
+=item check_part_svc_link_unprovision
+
+Checks service dependency unprovision rules for this service.
+
+If there is an error, returns the error, otherwise returns false.
+
+=cut
+
+sub check_part_svc_link_unprovision {
+ my $self = shift;
+
+ foreach my $part_svc_link ( $self->part_svc_link(
+ link_type => 'cust_svc_unprovision_restrict',
+ )
+ ) {
+ return $part_svc_link->dst_svc. ' must be unprovisioned before '.
+ $part_svc_link->src_svc
+ if qsearchs({
+ 'table' => 'cust_svc',
+ 'hashref' => { 'pkgnum' => $self->pkgnum,
+ 'svcpart' => $part_svc_link->dst_svcpart,
+ },
+ 'order_by' => 'LIMIT 1',
+ });
+ }
+
+ '';
+}
+
=item part_svc_link
Returns the service dependencies (see L<FS::part_svc_link>) for the given
diff --git a/FS/FS/svc_Common.pm b/FS/FS/svc_Common.pm
index b1f9d146f..8d3b5353e 100644
--- a/FS/FS/svc_Common.pm
+++ b/FS/FS/svc_Common.pm
@@ -395,7 +395,8 @@ sub delete {
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
- my $error = $self->predelete_hook_first
+ my $error = $self->cust_svc->check_part_svc_link_unprovision
+ || $self->predelete_hook_first
|| $self->SUPER::delete
|| $self->export('delete', @$export_args)
|| $self->return_inventory