[freeside-commits] freeside/FS/FS/part_pkg voip_cdr.pm, 1.119, 1.120

Erik Levinson levinse at wavetail.420.am
Wed Jun 8 19:14:47 PDT 2011


Update of /home/cvs/cvsroot/freeside/FS/FS/part_pkg
In directory wavetail.420.am:/tmp/cvs-serv2936/FS/FS/part_pkg

Modified Files:
	voip_cdr.pm 
Log Message:
inter/intra-state phone billing and custom rate import script, RT13112

Index: voip_cdr.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/voip_cdr.pm,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -w -d -r1.119 -r1.120
--- voip_cdr.pm	5 Jun 2011 06:05:12 -0000	1.119
+++ voip_cdr.pm	9 Jun 2011 02:14:45 -0000	1.120
@@ -89,6 +89,15 @@
                      '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,7 +261,8 @@
                        recur_method cutoff_day
                        add_full_period
                        cdr_svc_method
-                       rating_method ratenum min_charge min_included
+                       rating_method ratenum intrastate_ratenum 
+                       min_charge min_included
 		       sec_granularity
                        ignore_unrateable
                        default_prefix
@@ -495,6 +505,30 @@
           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!";



More information about the freeside-commits mailing list