From 47cb646c89d4a798d35063f04db39c707eac4f4c Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Thu, 30 Apr 2015 05:34:17 -0700 Subject: service dependencies: cust_svc_provision_restrict, RT#33685 --- FS/FS/cust_svc.pm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'FS/FS/cust_svc.pm') 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) 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 -- cgit v1.1