X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Frate.pm;h=4052807478e94b0e64db0591ac61d180a9694629;hb=13f21e01ac9faa50c07f64c20cbceae0ae50790c;hp=02d8250ebbdc79a777132c2fcbd76c553645e270;hpb=0fb307c305e4bc2c9c27dc25a3308beae3a4d33c;p=freeside.git diff --git a/FS/FS/rate.pm b/FS/FS/rate.pm index 02d8250eb..405280747 100644 --- a/FS/FS/rate.pm +++ b/FS/FS/rate.pm @@ -1,12 +1,11 @@ package FS::rate; +use base qw(FS::Record); use strict; -use vars qw( @ISA $DEBUG ); +use vars qw( $DEBUG ); use FS::Record qw( qsearch qsearchs dbh fields ); use FS::rate_detail; -@ISA = qw(FS::Record); - $DEBUG = 0; =head1 NAME @@ -308,17 +307,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; @@ -371,14 +381,6 @@ sub dest_detail { Returns all region-specific details (see L) for this rate. -=cut - -sub rate_detail { - my $self = shift; - qsearch( 'rate_detail', { 'ratenum' => $self->ratenum } ); -} - - =back =head1 SUBROUTINES @@ -387,7 +389,7 @@ sub rate_detail { =item process -Experimental job-queue processor for web interface adds/edits +Job-queue processor for web interface adds/edits =cut