X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Frate.pm;h=49ac938fd568b441169ad4fcb5b5c9acabbad614;hb=c3b8e954dbf5ddd04930809edfb77fa106fccaee;hp=02d8250ebbdc79a777132c2fcbd76c553645e270;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;p=freeside.git diff --git a/FS/FS/rate.pm b/FS/FS/rate.pm index 02d8250eb..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; @@ -387,7 +398,7 @@ sub rate_detail { =item process -Experimental job-queue processor for web interface adds/edits +Job-queue processor for web interface adds/edits =cut