summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Schema.pm3
-rw-r--r--FS/FS/part_pkg/voip_cdr.pm40
-rw-r--r--FS/FS/rate_prefix.pm3
3 files changed, 43 insertions, 3 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index eebcfecd2..ab4752f4b 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -2593,6 +2593,9 @@ sub tables_hashref {
'countrycode', 'varchar', '', 3, '', '',
'npa', 'varchar', 'NULL', 10, '', '', #actually the whole prefix
'nxx', 'varchar', 'NULL', 3, '', '', #actually not used
+ 'latanum', 'int', 'NULL', '', '', '',
+ 'state', 'char', 'NULL', 2, '', '',
+ 'ocn', 'char', 'NULL', 4, '', '',
],
'primary_key' => 'prefixnum',
'unique' => [],
diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index ad7589b2b..25b8d7801 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -88,6 +88,15 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
'select_key' => 'ratenum',
'select_label' => 'ratename',
},
+
+ 'intrastate_ratenum' => { 'name' => 'Optional alternate intrastate rate plan',
+ 'type' => 'select',
+ 'select_table' => 'rate',
+ 'select_key' => 'ratenum',
+ 'select_label' => 'ratename',
+ 'disable_empty' => 0,
+ 'empty_label' => '',
+ },
'min_included' => { 'name' => 'Minutes included when using the "single price per minute" rating method or when using the "prefix" rating method ("region group" billing)',
},
@@ -252,8 +261,9 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
recur_method cutoff_day
add_full_period
cdr_svc_method
- rating_method ratenum min_charge min_included
- sec_granularity
+ rating_method ratenum intrastate_ratenum
+ min_charge min_included
+ sec_granularity
ignore_unrateable
default_prefix
disable_src
@@ -273,7 +283,7 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
411_rewrite
output_format usage_mandate summarize_usage usage_section
bill_every_call bill_inactive_svcs
- count_available_phones suspend_bill
+ count_available_phones suspend_bill
)
],
'weight' => 40,
@@ -495,6 +505,30 @@ sub calc_usage {
my $eff_ratenum = $cdr->is_tollfree('accountcode')
? $cust_pkg->part_pkg->option('accountcode_tollfree_ratenum')
: '';
+
+ my $intrastate_ratenum = $cust_pkg->part_pkg->option('accountcode_tollfree_ratenum');
+ if ( $intrastate_ratenum && !$cdr->is_tollfree ) {
+ # this is relatively easy only because:
+ # -assume all numbers are valid NANP numbers NOT in a fully-qualified format
+ # -disregard toll-free
+ # -disregard private or unknown numbers
+ # -there is exactly one record in rate_prefix for a given NPANXX
+ # -default to interstate if we can't find one or both of the prefixes
+ my $dstprefix = $cdr->dst;
+ $dstprefix =~ /^(\d{6})/;
+ $dstprefix = qsearchs('rate_prefix', { 'countrycode' => '1',
+ 'npa' => $1,
+ }) || '';
+ my $srcprefix = $cdr->src;
+ $srcprefix =~ /^(\d{6})/;
+ $srcprefix = qsearchs('rate_prefix', { 'countrycode' => '1',
+ 'npa' => $1,
+ }) || '';
+ $eff_ratenum = $intrastate_ratenum if ($srcprefix && $dstprefix
+ && $srcprefix->state && $dstprefix->state
+ && $srcprefix->state eq $dstprefix->state);
+ }
+
$eff_ratenum ||= $ratenum;
$rate = qsearchs('rate', { 'ratenum' => $eff_ratenum })
or die "ratenum $eff_ratenum not found!";
diff --git a/FS/FS/rate_prefix.pm b/FS/FS/rate_prefix.pm
index ce780fefe..585802add 100644
--- a/FS/FS/rate_prefix.pm
+++ b/FS/FS/rate_prefix.pm
@@ -108,6 +108,9 @@ sub check {
|| $self->ut_number('countrycode')
|| $self->ut_numbern('npa')
|| $self->ut_numbern('nxx')
+ || $self->ut_foreign_keyn('latanum', 'lata', 'latanum')
+ || $self->ut_textn('state')
+ || $self->ut_textn('ocn')
;
return $error if $error;