2 use base qw(FS::Record);
8 FS::pkg_svc - Object methods for pkg_svc records
14 $record = new FS::pkg_svc \%hash;
15 $record = new FS::pkg_svc { 'column' => 'value' };
17 $error = $record->insert;
19 $error = $new_record->replace($old_record);
21 $error = $record->delete;
23 $error = $record->check;
25 $part_pkg = $record->part_pkg;
27 $part_svc = $record->part_svc;
31 An FS::pkg_svc record links a billing item definition (see L<FS::part_pkg>) to
32 a service definition (see L<FS::part_svc>). FS::pkg_svc inherits from
33 FS::Record. The following fields are currently supported:
37 =item pkgsvcnum - primary key
39 =item pkgpart - Billing item definition (see L<FS::part_pkg>)
41 =item svcpart - Service definition (see L<FS::part_svc>)
43 =item quantity - Quantity of this service definition that this billing item
46 =item primary_svc - primary flag, empty or 'Y'
48 =item hidden - 'Y' to hide this service on invoices, null otherwise.
58 Create a new record. To add the record to the database, see L<"insert">.
62 sub table { 'pkg_svc'; }
66 Adds this record to the database. If there is an error, returns the error,
67 otherwise returns false.
71 Deletes this record from the database. If there is an error, returns the
72 error, otherwise returns false.
74 =item replace OLD_RECORD
76 Replaces OLD_RECORD with this one in the database. If there is an error,
77 returns the error, otherwise returns false.
82 my( $new, $old ) = ( shift, shift );
84 $old = $new->replace_old unless defined($old);
86 return "Can't change pkgpart!" if $old->pkgpart != $new->pkgpart;
87 return "Can't change svcpart!" if $old->svcpart != $new->svcpart;
89 $new->SUPER::replace($old);
94 Checks all fields to make sure this is a valid record. If there is an error,
95 returns the error, otherwise returns false. Called by the insert and replace
105 $self->ut_numbern('pkgsvcnum')
106 || $self->ut_number('pkgpart')
107 || $self->ut_number('svcpart')
108 || $self->ut_number('quantity')
109 || $self->ut_enum('hidden', [ '', 'Y' ] )
111 return $error if $error;
113 return "Unknown pkgpart!" unless $self->part_pkg;
114 return "Unknown svcpart!" unless $self->part_svc;
116 if ( $self->dbdef_table->column('primary_svc') ) {
117 $error = $self->ut_enum('primary_svc', [ '', 'Y' ] );
118 return $error if $error;
126 Returns the FS::part_pkg object (see L<FS::part_pkg>).
130 Returns the FS::part_svc object (see L<FS::part_svc>).
138 L<FS::Record>, L<FS::part_pkg>, L<FS::part_svc>, schema.html from the base