X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg_link.pm;h=9ce8e6a76a5c97e365f0082229fc61ff27e612e3;hb=7b5a266236857fbb4bbf8d4ac3031c3fec75cac2;hp=f51736055f6923cb5925a032fe1c8e004b114084;hpb=b286503a0445e77d67b323785a73d4339c1145a9;p=freeside.git diff --git a/FS/FS/part_pkg_link.pm b/FS/FS/part_pkg_link.pm index f51736055..9ce8e6a76 100644 --- a/FS/FS/part_pkg_link.pm +++ b/FS/FS/part_pkg_link.pm @@ -49,7 +49,13 @@ Destination package (see L) =item link_type Link type - currently, "bill" (source package bills a line item from target -package), or "svc" (source package includes services from target package). +package), or "svc" (source package includes services from target package), +or "supp" (ordering source package creates a target package). + +=item hidden + +Flag indicating that this subpackage should be felt, but not seen as an invoice +line item when set to 'Y'. Not allowed for "supp" links. =back @@ -114,10 +120,26 @@ sub check { $self->ut_numbern('pkglinknum') || $self->ut_foreign_key('src_pkgpart', 'part_pkg', 'pkgpart') || $self->ut_foreign_key('dst_pkgpart', 'part_pkg', 'pkgpart') - || $self->ut_text('link_type', [ 'bill', 'svc' ] ) + || $self->ut_enum('link_type', [ 'bill', 'svc', 'supp' ] ) + || $self->ut_enum('hidden', [ '', 'Y' ] ) ; return $error if $error; + if ( $self->link_type eq 'supp' ) { + # some sanity checking + my $src_pkg = $self->src_pkg; + my $dst_pkg = $self->dst_pkg; + if ( $src_pkg->freq eq '0' and $dst_pkg->freq ne '0' ) { + return "One-time charges can't have supplemental packages." + } elsif ( $dst_pkg->freq ne '0' ) { + my $ratio = $dst_pkg->freq / $src_pkg->freq; + if ($ratio != int($ratio)) { + return "Supplemental package period (pkgpart ".$dst_pkg->pkgpart. + ") must be an integer multiple of main package period."; + } + } + } + $self->SUPER::check; }