diff options
author | Mark Wells <mark@freeside.biz> | 2015-10-23 12:03:24 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2015-10-23 12:03:44 -0700 |
commit | 275239995f6b9888e470e4128287fba4d56df790 (patch) | |
tree | e6a3829999913b97d9e7d9cc992429c6d242ca0d /FS/FS | |
parent | 05959a9336936ec1d6e0ad8641a47d2f8dd515cf (diff) |
allow a default rate detail for each CDR type, #38633
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/rate.pm | 35 | ||||
-rw-r--r-- | FS/FS/rate_detail.pm | 5 |
2 files changed, 32 insertions, 8 deletions
diff --git a/FS/FS/rate.pm b/FS/FS/rate.pm index 50657ce5f..bdf689a10 100644 --- a/FS/FS/rate.pm +++ b/FS/FS/rate.pm @@ -55,6 +55,8 @@ it may still be processed under a different pricing addon package), or be marked as 'skipped', or throw a fatal error, depending on the setting of the 'ignore_unrateable' package option. +Deprecated; we now find the default detail by its lack of regionnum. + =item =back @@ -348,7 +350,11 @@ sub dest_detail { }); } - return $self->default_detail unless $rate_prefix; + if ( !$rate_prefix ) { + # then this call doesn't match any known region; just return the + # appropriate anywhere rate + return $self->default_detail($cdrtypenum) || $self->default_detail(''); + } $regionnum = $rate_prefix->regionnum; @@ -366,7 +372,14 @@ sub dest_detail { %hash, 'cdrtypenum' => $cdrtypenum }); - # find all rates maching ratenum, regionnum and null cdrtypenum + # failing that, return the global default for this plan with the correct + # cdrtypenum (skips weektime processing) + if ( !@details and $cdrtypenum ) { + my $detail = $self->default_detail($cdrtypenum); + return $detail if $detail; + } + # failing that, find all rates maching ratenum, regionnum and null cdrtypenum + # (these can have weektime stuff) if ( !@details and $cdrtypenum ) { @details = qsearch( 'rate_detail', { %hash, @@ -392,7 +405,7 @@ sub dest_detail { return $_ if $_->ratetimenum eq ''; } # if still nothing, return the global default rate for this plan - return $self->default_detail; + return $self->default_detail(''); } =item rate_detail @@ -419,16 +432,24 @@ sub agent { =back -=item default_detail +=item default_detail [ CDRTYPENUM ] -Returns the default rate detail, if there is one. +Returns the default rate detail for CDRTYPENUM (or for null CDR type, if not +specified). =cut sub default_detail { my $self = shift; - $self->default_detailnum ? - FS::rate_detail->by_key($self->default_detailnum) : '' + my $cdrtypenum = shift || ''; +# $self->default_detailnum ? +# FS::rate_detail->by_key($self->default_detailnum) : '' + qsearchs( 'rate_detail', { + ratenum => $self->ratenum, + cdrtypenum => $cdrtypenum, + dest_regionnum => '', + orig_regionnum => '', + }) || ''; } =head1 SUBROUTINES diff --git a/FS/FS/rate_detail.pm b/FS/FS/rate_detail.pm index f77796560..4f1c9622e 100644 --- a/FS/FS/rate_detail.pm +++ b/FS/FS/rate_detail.pm @@ -133,6 +133,7 @@ sub check { || $self->ut_foreign_key('ratenum', 'rate', 'ratenum') || $self->ut_foreign_keyn('orig_regionnum', 'rate_region', 'regionnum' ) || $self->ut_foreign_keyn('dest_regionnum', 'rate_region', 'regionnum' ) + || $self->ut_foreign_keyn('cdrtypenum', 'cdr_type', 'cdrtypenum' ) || $self->ut_number('min_included') #|| $self->ut_money('min_charge') @@ -202,6 +203,8 @@ sub dest_regionname { my $self = shift; my $dest_region = $self->dest_region; $dest_region ? $dest_region->regionname : 'Global default'; + # should be 'Anywhere' or something, to indicate that it's the + # cross-region default } =item dest_prefixes_short @@ -238,7 +241,7 @@ associated with this rate plan. sub rate_time_name { my $self = shift; - $self->ratetimenum ? $self->rate_time->ratetimename : '(default)'; + $self->ratetimenum ? $self->rate_time->ratetimename : '(any time)'; } =item classname |