diff options
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/part_pkg.pm | 12 | ||||
-rw-r--r-- | FS/FS/type_pkgs.pm | 21 |
2 files changed, 25 insertions, 8 deletions
diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm index 3308eadf4..f7c56f3dd 100644 --- a/FS/FS/part_pkg.pm +++ b/FS/FS/part_pkg.pm @@ -560,6 +560,18 @@ packages. =cut +=item type_pkgs + +Returns all FS::type_pkgs objects (see L<FS::type_pkgs>) for this package +definition. + +=cut + +sub type_pkgs { + my $self = shift; + qsearch('type_pkgs', { 'pkgpart' => $self->pkgpart } ); +} + sub pkg_svc { my $self = shift; diff --git a/FS/FS/type_pkgs.pm b/FS/FS/type_pkgs.pm index bf34e7cda..650375524 100644 --- a/FS/FS/type_pkgs.pm +++ b/FS/FS/type_pkgs.pm @@ -83,17 +83,11 @@ sub check { my $error = $self->ut_numbern('typepkgnum') - || $self->ut_number('typenum') - || $self->ut_number('pkgpart') + || $self->ut_foreign_key('typenum', 'agent_type', 'typenum' ) + || $self->ut_foreign_key('pkgpart', 'part_pkg', 'pkgpart' ) ; return $error if $error; - return "Unknown typenum" - unless qsearchs( 'agent_type', { 'typenum' => $self->typenum } ); - - return "Unknown pkgpart" - unless qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } ); - $self->SUPER::check; } @@ -108,6 +102,17 @@ sub part_pkg { qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } ); } +=item agent_type + +Returns the FS::agent_type object associated with this record. + +=cut + +sub agent_type { + my $self = shift; + qsearchs( 'agent_type', { 'typenum' => $self->typenum } ); +} + =cut =back |