diff options
author | Mark Wells <mark@freeside.biz> | 2013-01-12 12:03:16 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2013-01-12 12:07:06 -0800 |
commit | b70b0d8c6f571a68ffb60c5ca728a230926abee4 (patch) | |
tree | 27e6d37c746c8eb5a4a9e257297d98d569bd5a1b /FS/FS/part_pkg_link.pm | |
parent | dd825e780ad1e7d520f5c2d7f99c0f67fe892781 (diff) |
supplemental packages, #20689
Diffstat (limited to 'FS/FS/part_pkg_link.pm')
-rw-r--r-- | FS/FS/part_pkg_link.pm | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/FS/FS/part_pkg_link.pm b/FS/FS/part_pkg_link.pm index fb7a8d3..9ce8e6a 100644 --- a/FS/FS/part_pkg_link.pm +++ b/FS/FS/part_pkg_link.pm @@ -49,12 +49,13 @@ Destination package (see L<FS::part_pkg>) =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' +line item when set to 'Y'. Not allowed for "supp" links. =back @@ -119,11 +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_enum('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; } |