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