5 use FS::Record qw( qsearchs );
9 @ISA = qw( FS::Record );
13 FS::pkg_svc - Object methods for pkg_svc records
19 $record = new FS::pkg_svc \%hash;
20 $record = new FS::pkg_svc { 'column' => 'value' };
22 $error = $record->insert;
24 $error = $new_record->replace($old_record);
26 $error = $record->delete;
28 $error = $record->check;
30 $part_pkg = $record->part_pkg;
32 $part_svc = $record->part_svc;
36 An FS::pkg_svc record links a billing item definition (see L<FS::part_pkg>) to
37 a service definition (see L<FS::part_svc>). FS::pkg_svc inherits from
38 FS::Record. The following fields are currently supported:
42 =item pkgsvcnum - primary key
44 =item pkgpart - Billing item definition (see L<FS::part_pkg>)
46 =item svcpart - Service definition (see L<FS::part_svc>)
48 =item quantity - Quantity of this service definition that this billing item
51 =item primary_svc - primary flag, empty or 'Y'
53 =item hidden - 'Y' to hide this service on invoices, null otherwise.
55 =item provision_hold - 'Y' to release package hold when all services marked with this are provisioned
65 Create a new record. To add the record to the database, see L<"insert">.
69 sub table { 'pkg_svc'; }
73 Adds this record to the database. If there is an error, returns the error,
74 otherwise returns false.
78 Deletes this record from the database. If there is an error, returns the
79 error, otherwise returns false.
81 =item replace OLD_RECORD
83 Replaces OLD_RECORD with this one in the database. If there is an error,
84 returns the error, otherwise returns false.
89 my( $new, $old ) = ( shift, shift );
91 $old = $new->replace_old unless defined($old);
93 return "Can't change pkgpart!" if $old->pkgpart != $new->pkgpart;
94 return "Can't change svcpart!" if $old->svcpart != $new->svcpart;
96 $new->SUPER::replace($old);
101 Checks all fields to make sure this is a valid record. If there is an error,
102 returns the error, otherwise returns false. Called by the insert and replace
112 $self->ut_numbern('pkgsvcnum')
113 || $self->ut_number('pkgpart')
114 || $self->ut_number('svcpart')
115 || $self->ut_number('quantity')
116 || $self->ut_enum('hidden', [ '', 'Y' ] )
117 || $self->ut_flag('provision_hold')
119 return $error if $error;
121 return "Unknown pkgpart!" unless $self->part_pkg;
122 return "Unknown svcpart!" unless $self->part_svc;
124 if ( $self->dbdef_table->column('primary_svc') ) {
125 $error = $self->ut_enum('primary_svc', [ '', 'Y' ] );
126 return $error if $error;
134 Returns the FS::part_pkg object (see L<FS::part_pkg>).
140 qsearchs( 'part_pkg', { 'pkgpart' => $self->pkgpart } );
145 Returns the FS::part_svc object (see L<FS::part_svc>).
151 qsearchs( 'part_svc', { 'svcpart' => $self->svcpart } );
160 L<FS::Record>, L<FS::part_pkg>, L<FS::part_svc>, schema.html from the base