diff options
author | Mark Wells <mark@freeside.biz> | 2013-02-22 08:27:20 -0800 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2013-02-22 08:27:20 -0800 |
commit | c3b8e954dbf5ddd04930809edfb77fa106fccaee (patch) | |
tree | ca2081dd206d5e53aa259d9eaea27c7efd37e5fd /FS/FS/rate.pm | |
parent | 4d3d1f29b5cb6d01e3474d0037fc4c6c866e8311 (diff) |
exact-match rate regions, #20851
Diffstat (limited to 'FS/FS/rate.pm')
-rw-r--r-- | FS/FS/rate.pm | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/FS/FS/rate.pm b/FS/FS/rate.pm index a2511cf..49ac938 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; |