+
+ 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);
+ }
+