[freeside-commits] branch master updated. c3b8e954dbf5ddd04930809edfb77fa106fccaee
Mark Wells
mark at 420.am
Fri Feb 22 08:28:11 PST 2013
The branch, master has been updated
via c3b8e954dbf5ddd04930809edfb77fa106fccaee (commit)
from 4d3d1f29b5cb6d01e3474d0037fc4c6c866e8311 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit c3b8e954dbf5ddd04930809edfb77fa106fccaee
Author: Mark Wells <mark at freeside.biz>
Date: Fri Feb 22 08:27:20 2013 -0800
exact-match rate regions, #20851
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 6c7453d..774dcd2 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 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;
diff --git a/FS/FS/rate_region.pm b/FS/FS/rate_region.pm
index f4a0ab1..d42fdb4 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;
diff --git a/httemplate/browse/rate_region.html b/httemplate/browse/rate_region.html
index b958894..b0ce467 100644
--- a/httemplate/browse/rate_region.html
+++ b/httemplate/browse/rate_region.html
@@ -62,8 +62,14 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+my $sub_prefixes = sub {
+ my $region = shift;
+ $region->prefixes .
+ ($region->exact_match ? ' <I>(exact match only)</I>' : '');
+};
+
my @header = ( '#', 'Region', 'Country code', 'Prefixes' );
-my @fields = ( 'regionnum', 'regionname', 'ccode', 'prefixes' );
+my @fields = ( 'regionnum', 'regionname', 'ccode', $sub_prefixes );
my @links = ( ($link) x 4 );
my @align = ( 'right', 'left', 'right', 'left' );
my @xls_format = ( ({ locked=>1, bg_color=>22 }) x 4 );
diff --git a/httemplate/edit/rate_region.cgi b/httemplate/edit/rate_region.cgi
index 367bbaf..a1c1bcb 100644
--- a/httemplate/edit/rate_region.cgi
+++ b/httemplate/edit/rate_region.cgi
@@ -33,6 +33,14 @@
</TD>
</TR>
+ <& /elements/tr-checkbox.html,
+ label => 'Exact match',
+ field => 'exact_match',
+ cell_style => 'font-weight: bold',
+ value => 'Y',
+ curr_value => $rate_region->exact_match
+ &>
+
</TABLE>
<BR>
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Schema.pm | 1 +
FS/FS/rate.pm | 29 ++++++++++++++++++++---------
FS/FS/rate_region.pm | 6 +++++-
httemplate/browse/rate_region.html | 8 +++++++-
httemplate/edit/rate_region.cgi | 8 ++++++++
5 files changed, 41 insertions(+), 11 deletions(-)
More information about the freeside-commits
mailing list