2 use base qw(FS::Record);
5 use FS::Record qw( qsearchs );
8 our $cache_enabled = 0;
11 my( $self, $hashref ) = @_;
12 if ( $cache_enabled && $hashref->{'svc'} ) {
13 $self->{'_svcpart'} = FS::part_svc->new($hashref);
19 FS::pkg_svc - Object methods for pkg_svc records
25 $record = new FS::pkg_svc \%hash;
26 $record = new FS::pkg_svc { 'column' => 'value' };
28 $error = $record->insert;
30 $error = $new_record->replace($old_record);
32 $error = $record->delete;
34 $error = $record->check;
36 $part_pkg = $record->part_pkg;
38 $part_svc = $record->part_svc;
42 An FS::pkg_svc record links a billing item definition (see L<FS::part_pkg>) to
43 a service definition (see L<FS::part_svc>). FS::pkg_svc inherits from
44 FS::Record. The following fields are currently supported:
48 =item pkgsvcnum - primary key
50 =item pkgpart - Billing item definition (see L<FS::part_pkg>)
52 =item svcpart - Service definition (see L<FS::part_svc>)
54 =item quantity - Quantity of this service definition that this billing item
57 =item primary_svc - primary flag, empty or 'Y'
59 =item hidden - 'Y' to hide this service on invoices, null otherwise.
61 =item provision_hold - 'Y' to release package hold when all services marked with this are provisioned
71 Create a new record. To add the record to the database, see L<"insert">.
75 sub table { 'pkg_svc'; }
79 Adds this record to the database. If there is an error, returns the error,
80 otherwise returns false.
84 Deletes this record from the database. If there is an error, returns the
85 error, otherwise returns false.
87 =item replace OLD_RECORD
89 Replaces OLD_RECORD with this one in the database. If there is an error,
90 returns the error, otherwise returns false.
95 my( $new, $old ) = ( shift, shift );
97 $old = $new->replace_old unless defined($old);
99 return "Can't change pkgpart!" if $old->pkgpart != $new->pkgpart;
100 return "Can't change svcpart!" if $old->svcpart != $new->svcpart;
102 $new->SUPER::replace($old);
107 Checks all fields to make sure this is a valid record. If there is an error,
108 returns the error, otherwise returns false. Called by the insert and replace
118 $self->ut_numbern('pkgsvcnum')
119 || $self->ut_number('pkgpart')
120 || $self->ut_number('svcpart')
121 || $self->ut_number('quantity')
122 || $self->ut_enum('hidden', [ '', 'Y' ] )
123 || $self->ut_flag('provision_hold')
125 return $error if $error;
127 return "Unknown pkgpart!" unless $self->part_pkg;
128 return "Unknown svcpart!" unless $self->part_svc;
130 if ( $self->dbdef_table->column('primary_svc') ) {
131 $error = $self->ut_enum('primary_svc', [ '', 'Y' ] );
132 return $error if $error;
140 Returns the FS::part_pkg object (see L<FS::part_pkg>).
144 Returns the FS::part_svc object (see L<FS::part_svc>).
150 return $self->{_svcpart} if $self->{_svcpart};
151 qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
160 L<FS::Record>, L<FS::part_pkg>, L<FS::part_svc>, schema.html from the base