2 use base qw(FS::Record);
5 use FS::Record qw( qsearchs );
9 our $cache_enabled = 0;
12 my( $self, $hashref ) = @_;
13 if ( $cache_enabled && $hashref->{'svc'} ) {
14 $self->{'_svcpart'} = FS::part_svc->new($hashref);
20 FS::pkg_svc - Object methods for pkg_svc records
26 $record = new FS::pkg_svc \%hash;
27 $record = new FS::pkg_svc { 'column' => 'value' };
29 $error = $record->insert;
31 $error = $new_record->replace($old_record);
33 $error = $record->delete;
35 $error = $record->check;
37 $part_pkg = $record->part_pkg;
39 $part_svc = $record->part_svc;
43 An FS::pkg_svc record links a billing item definition (see L<FS::part_pkg>) to
44 a service definition (see L<FS::part_svc>). FS::pkg_svc inherits from
45 FS::Record. The following fields are currently supported:
49 =item pkgsvcnum - primary key
51 =item pkgpart - Billing item definition (see L<FS::part_pkg>)
53 =item svcpart - Service definition (see L<FS::part_svc>)
55 =item quantity - Quantity of this service definition that this billing item
58 =item primary_svc - primary flag, empty or 'Y'
60 =item hidden - 'Y' to hide this service on invoices, null otherwise.
62 =item provision_hold - 'Y' to release package hold when all services marked with this are provisioned
72 Create a new record. To add the record to the database, see L<"insert">.
76 sub table { 'pkg_svc'; }
80 Adds this record to the database. If there is an error, returns the error,
81 otherwise returns false.
85 Deletes this record from the database. If there is an error, returns the
86 error, otherwise returns false.
88 =item replace OLD_RECORD
90 Replaces OLD_RECORD with this one in the database. If there is an error,
91 returns the error, otherwise returns false.
96 my( $new, $old ) = ( shift, shift );
98 $old = $new->replace_old unless defined($old);
100 return "Can't change pkgpart!" if $old->pkgpart != $new->pkgpart;
101 return "Can't change svcpart!" if $old->svcpart != $new->svcpart;
103 $new->SUPER::replace($old);
108 Checks all fields to make sure this is a valid record. If there is an error,
109 returns the error, otherwise returns false. Called by the insert and replace
119 $self->ut_numbern('pkgsvcnum')
120 || $self->ut_number('pkgpart')
121 || $self->ut_number('svcpart')
122 || $self->ut_number('quantity')
123 || $self->ut_enum('hidden', [ '', 'Y' ] )
124 || $self->ut_flag('provision_hold')
126 return $error if $error;
128 return "Unknown pkgpart!" unless $self->part_pkg;
129 return "Unknown svcpart!" unless $self->part_svc;
131 if ( $self->dbdef_table->column('primary_svc') ) {
132 $error = $self->ut_enum('primary_svc', [ '', 'Y' ] );
133 return $error if $error;
141 Returns the FS::part_pkg object (see L<FS::part_pkg>).
147 qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } );
152 Returns the FS::part_svc object (see L<FS::part_svc>).
158 return $self->{_svcpart} if $self->{_svcpart};
159 qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
168 L<FS::Record>, L<FS::part_pkg>, L<FS::part_svc>, schema.html from the base