summaryrefslogtreecommitdiff
path: root/FS/FS/cust_svc.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2015-04-30 05:34:17 -0700
committerIvan Kohler <ivan@freeside.biz>2015-04-30 05:34:17 -0700
commit47cb646c89d4a798d35063f04db39c707eac4f4c (patch)
treeebab27226a79381141eb0fec4b81b3b032190cb1 /FS/FS/cust_svc.pm
parent3ef3c5061e6de2dd885987e844ea3122aafc4df6 (diff)
service dependencies: cust_svc_provision_restrict, RT#33685
Diffstat (limited to 'FS/FS/cust_svc.pm')
-rw-r--r--FS/FS/cust_svc.pm37
1 files changed, 37 insertions, 0 deletions
diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm
index 96409c3..a7aeada 100644
--- a/FS/FS/cust_svc.pm
+++ b/FS/FS/cust_svc.pm
@@ -11,6 +11,7 @@ use FS::Record qw( qsearch qsearchs dbh str2time_sql str2time_sql_closing );
use FS::part_pkg;
use FS::part_svc;
use FS::pkg_svc;
+use FS::part_svc_link;
use FS::domain_record;
use FS::part_export;
use FS::cdr;
@@ -431,11 +432,47 @@ sub check {
" services for pkgnum ". $self->pkgnum
if $num_avail <= 0;
+ #part_svc_link rules (only make sense in pkgpart context, and
+ # skipping this when ignore_quantity is set DTRT when we're "forcing"
+ # an implicit change here (location change triggered pkgpart change,
+ # ->overlimit, bulk customer service changes)
+ foreach my $part_svc_link ( $self->part_svc_link(
+ link_type => 'cust_svc_provision_restrict',
+ )
+ ) {
+ return $part_svc_link->dst_svc. ' must be provisioned before '.
+ $part_svc_link->src_svc
+ unless qsearchs({
+ 'table' => 'cust_svc',
+ 'hashref' => { 'pkgnum' => $self->pkgnum,
+ 'svcpart' => $part_svc_link->dst_svcpart,
+ },
+ 'order_by' => 'LIMIT 1',
+ });
+ }
+
}
$self->SUPER::check;
}
+=item part_svc_link
+
+Returns the service dependencies (see L<FS::part_svc_link>) for the given
+search options, taking into account this service definition as source and
+this customer's agent.
+
+Available options are any field in part_svc_link. Typically used options are
+link_type.
+
+=cut
+
+sub part_svc_link {
+ my $self = shift;
+ my $agentnum = $self->pkgnum ? $self->cust_pkg->cust_main->agentnum : '';
+ FS::part_svc_link->by_agentnum($agentnum, src_svcpart=>$self->svcpart, @_);
+}
+
=item display_svcnum
Returns the displayed service number for this service: agent_svcid if it has a