summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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