4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
6 use FS::rate_time_interval;
10 FS::rate_time - Object methods for rate_time records
16 $record = new FS::rate_time \%hash;
17 $record = new FS::rate_time { 'column' => 'value' };
19 $error = $record->insert;
21 $error = $new_record->replace($old_record);
23 $error = $record->delete;
25 $error = $record->check;
29 An FS::rate_time object represents a time period for selection of CDR billing
30 rates. FS::rate_time inherits from FS::Record. The following fields are
41 A label (like "Daytime" or "Weekend").
51 Creates a new example. To add the example to the database, see L<"insert">.
53 Note that this stores the hash reference, not a distinct copy of the hash it
54 points to. You can ask the object for a copy with the I<hash> method.
58 # the new method can be inherited from FS::Record, if a table method is defined
60 sub table { 'rate_time'; }
64 Adds this record to the database. If there is an error, returns the error,
65 otherwise returns false.
69 # the insert method can be inherited from FS::Record
73 Delete this record from the database.
77 # the delete method can be inherited from FS::Record
79 =item replace OLD_RECORD
81 Replaces the OLD_RECORD with this one in the database. If there is an error,
82 returns the error, otherwise returns false.
86 # the replace method can be inherited from FS::Record
90 Checks all fields to make sure this is a valid example. If there is
91 an error, returns the error, otherwise returns false. Called by the insert
100 $self->ut_numbern('ratetimenum')
101 || $self->ut_text('ratetimename')
103 return $error if $error;
110 Return the L<FS::rate_time_interval> objects included in this rating period.
116 return qsearch({ table => 'rate_time_interval',
117 hashref => { ratetimenum => $self->ratetimenum },
118 order_by => 'ORDER BY stime ASC',
124 Return the L<FS::rate_time_interval> object that contains the specified
125 time-of-week (in seconds from the start of Sunday). The primary use of
126 this is to test whether that time falls within this rating period.
132 my $weektime = shift;
133 return qsearchs('rate_time_interval', { ratetimenum => $self->ratetimenum,
134 stime => { op => '<=',
135 value => $weektime },
136 etime => { op => '>',
137 value => $weektime },
143 Returns a list of arrayrefs containing the starting and
144 ending times of each interval in this period, in a readable
151 return map { [ $_->description ] } $self->intervals;
163 L<FS::Record>, schema.html from the base documentation.