1 package FS::rate_detail;
5 use FS::Record qw( qsearch qsearchs );
10 @ISA = qw(FS::Record);
14 FS::rate_detail - Object methods for rate_detail records
20 $record = new FS::rate_detail \%hash;
21 $record = new FS::rate_detail { 'column' => 'value' };
23 $error = $record->insert;
25 $error = $new_record->replace($old_record);
27 $error = $record->delete;
29 $error = $record->check;
33 An FS::rate_detail object represents an call plan rate. FS::rate_detail
34 inherits from FS::Record. The following fields are currently supported:
38 =item ratedetailnum - primary key
40 =item ratenum - rate plan (see L<FS::rate>)
42 =item orig_regionnum - call origination region
44 =item dest_regionnum - call destination region
46 =item min_included - included minutes
48 =item min_charge - charge per minute
50 =item sec_granularity - granularity in seconds, i.e. 6 or 60; 0 for per-call
60 Creates a new call plan rate. To add the call plan rate to the database, see
63 Note that this stores the hash reference, not a distinct copy of the hash it
64 points to. You can ask the object for a copy with the I<hash> method.
68 # the new method can be inherited from FS::Record, if a table method is defined
70 sub table { 'rate_detail'; }
74 Adds this record to the database. If there is an error, returns the error,
75 otherwise returns false.
79 # the insert method can be inherited from FS::Record
83 Delete this record from the database.
87 # the delete method can be inherited from FS::Record
89 =item replace OLD_RECORD
91 Replaces the OLD_RECORD with this one in the database. If there is an error,
92 returns the error, otherwise returns false.
96 # the replace method can be inherited from FS::Record
100 Checks all fields to make sure this is a valid call plan rate. If there is
101 an error, returns the error, otherwise returns false. Called by the insert
106 # the check method should currently be supplied - FS::Record contains some
107 # data checking routines
113 $self->ut_numbern('ratedetailnum')
114 || $self->ut_foreign_key('ratenum', 'rate', 'ratenum')
115 || $self->ut_foreign_keyn('orig_regionnum', 'rate_region', 'regionnum' )
116 || $self->ut_foreign_key('dest_regionnum', 'rate_region', 'regionnum' )
117 || $self->ut_number('min_included')
119 #|| $self->ut_money('min_charge')
120 #good enough for now...
121 || $self->ut_float('min_charge')
123 || $self->ut_number('sec_granularity')
125 return $error if $error;
132 Returns the parent call plan (see L<FS::rate>) associated with this call plan
139 qsearchs('rate', { 'ratenum' => $self->ratenum } );
144 Returns the origination region (see L<FS::rate_region>) associated with this
151 qsearchs('rate_region', { 'regionnum' => $self->orig_regionnum } );
156 Returns the destination region (see L<FS::rate_region>) associated with this
163 qsearchs('rate_region', { 'regionnum' => $self->dest_regionnum } );
166 =item dest_regionname
168 Returns the name of the destination region (see L<FS::rate_region>) associated
169 with this call plan rate.
173 sub dest_regionname {
175 $self->dest_region->regionname;
178 =item dest_regionname
180 Returns a short list of the prefixes for the destination region
181 (see L<FS::rate_region>) associated with this call plan rate.
185 sub dest_prefixes_short {
187 $self->dest_region->prefixes_short;
199 Returns an (ordered) hash of granularity => name pairs
203 tie my %granularities, 'Tie::IxHash',
206 '30' => '30 second', # '1/2 minute',
222 L<FS::rate>, L<FS::rate_region>, L<FS::Record>,
223 schema.html from the base documentation.