diff options
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Schema.pm | 1 | ||||
-rw-r--r-- | FS/FS/rate.pm | 29 | ||||
-rw-r--r-- | FS/FS/rate_region.pm | 6 |
3 files changed, 26 insertions, 10 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 6c7453d1c..774dcd239 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -3056,6 +3056,7 @@ sub tables_hashref { 'columns' => [ 'regionnum', 'serial', '', '', '', '', 'regionname', 'varchar', '', $char_d, '', '', + 'exact_match', 'char', 'NULL', 1, '', '', ], 'primary_key' => 'regionnum', 'unique' => [], diff --git a/FS/FS/rate.pm b/FS/FS/rate.pm index a2511cf99..49ac938fd 100644 --- a/FS/FS/rate.pm +++ b/FS/FS/rate.pm @@ -308,17 +308,28 @@ sub dest_detail { #find a rate prefix, first look at most specific, then fewer digits, # finally trying the country code only my $rate_prefix = ''; - for my $len ( reverse(1..10) ) { - $rate_prefix = qsearchs('rate_prefix', { + $rate_prefix = qsearchs({ + 'table' => 'rate_prefix', + 'addl_from' => ' JOIN rate_region USING (regionnum)', + 'hashref' => { + 'countrycode' => $countrycode, + 'npa' => $phonenum, + }, + 'extra_sql' => ' AND exact_match = \'Y\'' + }); + if (!$rate_prefix) { + for my $len ( reverse(1..10) ) { + $rate_prefix = qsearchs('rate_prefix', { + 'countrycode' => $countrycode, + #'npa' => { op=> 'LIKE', value=> substr($number, 0, $len) } + 'npa' => substr($phonenum, 0, $len), + } ) and last; + } + $rate_prefix ||= qsearchs('rate_prefix', { 'countrycode' => $countrycode, - #'npa' => { op=> 'LIKE', value=> substr($number, 0, $len) } - 'npa' => substr($phonenum, 0, $len), - } ) and last; + 'npa' => '', + }); } - $rate_prefix ||= qsearchs('rate_prefix', { - 'countrycode' => $countrycode, - 'npa' => '', - }); return '' unless $rate_prefix; diff --git a/FS/FS/rate_region.pm b/FS/FS/rate_region.pm index f4a0ab196..d42fdb41e 100644 --- a/FS/FS/rate_region.pm +++ b/FS/FS/rate_region.pm @@ -36,7 +36,10 @@ inherits from FS::Record. The following fields are currently supported: =item regionnum - primary key -=item regionname +=item regionname - name of the region + +=item exact_match - 'Y' if "prefixes" in this region really represent +complete phone numbers. Null if they represent prefixes (the usual case). =back @@ -233,6 +236,7 @@ sub check { my $error = $self->ut_numbern('regionnum') || $self->ut_text('regionname') + || $self->ut_flag('exact_match') ; return $error if $error; |