X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_svc.pm;h=612c59013c3d7b04d51e44e8fae6d230fb3145c1;hb=4d2467d2b8c2134f8cab6907c675a9c4f56472ed;hp=518e847a2bf75590eee0baf6cd52f4aa29edbe32;hpb=b429c39e5d748f9410143d51c79717ac95a5ff30;p=freeside.git diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm index 518e847a2..612c59013 100644 --- a/FS/FS/part_svc.pm +++ b/FS/FS/part_svc.pm @@ -12,6 +12,11 @@ use FS::export_svc; use FS::cust_svc; use FS::part_svc_class; +FS::UID->install_callback(sub { + # preload the cache and make sure all modules load + my $svc_defs = FS::part_svc->_svc_defs; +}); + $DEBUG = 0; =head1 NAME @@ -560,6 +565,9 @@ is specified as B<0>, returns the number of unlinked customer services. sub num_cust_svc { my $self = shift; + return $self->{Hash}{num_cust_svc} + if !@_ && exists($self->{Hash}{num_cust_svc}); + my @param = ( $self->svcpart ); my( $join, $and ) = ( '', '' ); @@ -649,9 +657,17 @@ sub _svc_defs { next; } $info{$mod} = $info; + + # all svc_* modules are required to have h_svc_* modules for invoice + # display. check for them as early as possible. + eval "use FS::h_$mod;"; + if ( $@ ) { + die "couldn't load history record module h_$mod: $@\n"; + } } } + tie my %svc_defs, 'Tie::IxHash', map { $_ => $info{$_}->{'fields'} } sort { $info{$a}->{'display_weight'} <=> $info{$b}->{'display_weight'} }