X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Frate_detail.pm;h=66c5c9740ed16fd8bea7ea473b5501a7e28b2e87;hb=a0e00fa0547e99893c735ab3dbdacdb2bb054f5a;hp=f6cdedf6e07da9e41f6b941c024499b55ae5b2f6;hpb=624b2d44625f69d71175c3348cae635d580c890b;p=freeside.git diff --git a/FS/FS/rate_detail.pm b/FS/FS/rate_detail.pm index f6cdedf6e..66c5c9740 100644 --- a/FS/FS/rate_detail.pm +++ b/FS/FS/rate_detail.pm @@ -1,13 +1,13 @@ package FS::rate_detail; +use base qw(FS::Record); use strict; -use vars qw( @ISA $DEBUG $me ); +use vars qw( $DEBUG $me ); +use Tie::IxHash; use FS::Record qw( qsearch qsearchs dbh ); use FS::rate; use FS::rate_region; -use Tie::IxHash; - -@ISA = qw(FS::Record); +use FS::rate_time; $DEBUG = 0; $me = '[FS::rate_detail]'; @@ -54,6 +54,12 @@ inherits from FS::Record. The following fields are currently supported: =item classnum - usage class (see L) if any for this rate +=item ratetimenum - rating time period (see L) if any for this rate + +=item region_group - Group in region group for rate plan + =back =head1 METHODS @@ -128,6 +134,7 @@ sub check { || $self->ut_number('sec_granularity') || $self->ut_foreign_keyn('classnum', 'usage_class', 'classnum' ) + || $self->ut_enum('region_group', [ '', 'Y' ]) ; return $error if $error; @@ -139,13 +146,6 @@ sub check { Returns the parent call plan (see L) associated with this call plan rate. -=cut - -sub rate { - my $self = shift; - qsearchs('rate', { 'ratenum' => $self->ratenum } ); -} - =item orig_region Returns the origination region (see L) associated with this @@ -194,6 +194,30 @@ sub dest_prefixes_short { $self->dest_region->prefixes_short; } +=item rate_time + +Returns the L object associated with this call +plan rate, if there is one. + +=cut + +sub rate_time { + my $self = shift; + $self->ratetimenum ? FS::rate_time->by_key($self->ratetimenum) : (); +} + +=item rate_time_name + +Returns the I field of the L object +associated with this rate plan. + +=cut + +sub rate_time_name { + my $self = shift; + $self->ratetimenum ? $self->rate_time->ratetimename : '(default)'; +} + =item classname Returns the name of the usage class (see L) associated with @@ -207,6 +231,20 @@ sub classname { $usage_class ? $usage_class->classname : ''; } +=item cdrtypename + +Returns the name of the CDR type (see Lcdrtypenum or return ''; + my $cdr_type = qsearchs('cdr_type', { cdrtypenum => $cdrtypenum }); + return $cdr_type ? $cdr_type->cdrtypename : $cdrtypenum; +} =back