fix 'Can't call method "setup" on an undefined value' error when using into rates...
[freeside.git] / FS / FS / torrus_srvderive_component.pm
1 package FS::torrus_srvderive_component;
2
3 use strict;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6 use FS::torrus_srvderive;
7
8 =head1 NAME
9
10 FS::torrus_srvderive_component - Object methods for torrus_srvderive_component records
11
12 =head1 SYNOPSIS
13
14   use FS::torrus_srvderive_component;
15
16   $record = new FS::torrus_srvderive_component \%hash;
17   $record = new FS::torrus_srvderive_component { 'column' => 'value' };
18
19   $error = $record->insert;
20
21   $error = $new_record->replace($old_record);
22
23   $error = $record->delete;
24
25   $error = $record->check;
26
27 =head1 DESCRIPTION
28
29 An FS::torrus_srvderive_component object represents a component of a Torrus
30 virtual service ID.  FS::torrus_srvderive_component inherits from FS::Record.
31 The following fields are currently supported:
32
33 =over 4
34
35 =item componentnum
36
37 primary key
38
39 =item derivenum
40
41 derivenum
42
43 =item serviceid
44
45 serviceid
46
47
48 =back
49
50 =head1 METHODS
51
52 =over 4
53
54 =item new HASHREF
55
56 Creates a new record.  To add the record to the database, see L<"insert">.
57
58 Note that this stores the hash reference, not a distinct copy of the hash it
59 points to.  You can ask the object for a copy with the I<hash> method.
60
61 =cut
62
63 # the new method can be inherited from FS::Record, if a table method is defined
64
65 sub table { 'torrus_srvderive_component'; }
66
67 =item insert
68
69 Adds this record to the database.  If there is an error, returns the error,
70 otherwise returns false.
71
72 =cut
73
74 # the insert method can be inherited from FS::Record
75
76 =item delete
77
78 Delete this record from the database.
79
80 =cut
81
82 # the delete method can be inherited from FS::Record
83
84 =item replace OLD_RECORD
85
86 Replaces the OLD_RECORD with this one in the database.  If there is an error,
87 returns the error, otherwise returns false.
88
89 =cut
90
91 # the replace method can be inherited from FS::Record
92
93 =item check
94
95 Checks all fields to make sure this is a valid record.  If there is
96 an error, returns the error, otherwise returns false.  Called by the insert
97 and replace methods.
98
99 =cut
100
101 # the check method should currently be supplied - FS::Record contains some
102 # data checking routines
103
104 sub check {
105   my $self = shift;
106
107   my $error = 
108     $self->ut_numbern('componentnum')
109     || $self->ut_number('derivenum')
110     || $self->ut_text('serviceid')
111   ;
112   return $error if $error;
113
114   $self->SUPER::check;
115 }
116
117 sub torrus_srvderive {
118   my $self = shift;
119   qsearchs('torrus_srvderive', { 'derivenum' => $self->derivenum } );
120 }
121
122 =back
123
124 =head1 BUGS
125
126 =head1 SEE ALSO
127
128 L<FS::Record>, schema.html from the base documentation.
129
130 =cut
131
132 1;
133