[freeside-commits] freeside/FS/FS/part_pkg voip_cdr.pm,1.45,1.46

Ivan,,, ivan at wavetail.420.am
Tue Jan 6 15:30:15 PST 2009


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

Modified Files:
	voip_cdr.pm 
Log Message:
throw a fatal error if a call is unrateable and add an ignore_unrateable flag to go back to the old skip behavior

Index: voip_cdr.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/voip_cdr.pm,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- voip_cdr.pm	6 Jan 2009 21:16:18 -0000	1.45
+++ voip_cdr.pm	6 Jan 2009 23:30:12 -0000	1.46
@@ -54,16 +54,22 @@
                                    ' of service at cancellation',
                          'type' => 'checkbox',
                        },
+
+    'rating_method' => { 'name' => 'Region rating method',
+                         'type' => 'radio',
+                         'options' => \%rating_method,
+                       },
+
     'ratenum'   => { 'name' => 'Rate plan',
                      'type' => 'select',
                      'select_table' => 'rate',
                      'select_key'   => 'ratenum',
                      'select_label' => 'ratename',
                    },
-    'rating_method' => { 'name' => 'Region rating method',
-                         'type' => 'radio',
-                         'options' => \%rating_method,
-                       },
+
+    'ignore_unrateable' => { 'name' => 'Ignore calls without a rate in the rate tables.  By default, the system will throw a fatal error upon encountering unrateable calls.',
+                             'type' => 'checkbox',
+                           },
 
     'default_prefix' => { 'name'    => 'Default prefix optionally prepended to customer DID numbers when searching for CDR records',
                           'default' => '+1',
@@ -157,7 +163,7 @@
   },
   'fieldorder' => [qw(
                        setup_fee recur_fee recur_temporality unused_credit
-                       rating_method ratenum 
+                       rating_method ratenum ignore_unrateable
                        default_prefix
                        disable_src
                        domestic_prefix international_prefix
@@ -335,12 +341,27 @@
                                               'phonenum'    => $number,
                                             });
 
-          $rate_region = $rate_detail->dest_region;
-          $regionnum = $rate_region->regionnum;
+          if ( $rate_detail ) {
 
-          warn "  found rate for regionnum $regionnum ".
-               "and rate detail $rate_detail\n"
-            if $DEBUG;
+            warn "  found rate for regionnum $regionnum ".
+                 "and rate detail $rate_detail\n"
+              if $DEBUG;
+            $rate_region = $rate_detail->dest_region;
+            $regionnum = $rate_region->regionnum;
+
+          } elsif ( $self->option('ignore_unrateable', 1) ) {
+
+            $rate_region = '';
+            $regionnum = '';
+            #code below will throw a warning & skip
+
+          } else {
+
+            die "FATAL: no rate_detail found in ".
+                $rate->ratenum. ":". $rate->rate. " rate plan for CDR ".
+                "acctid ". $cdr->acctid. " +$countrycode $number; ".
+                "add a rate or set ignore_unrateable flag on the package def\n";
+          }
 
         }
 
@@ -396,13 +417,13 @@
       ###
 
       # if $rate_detail is not found, skip this CDR... i.e. 
-      # don't add it to invoice, don't set its status to NULL,
+      # don't add it to invoice, don't set its status to done,
       # don't call downstream_csv or something on it...
       # but DO emit a warning...
       #if ( ! $rate_detail && ! scalar(@call_details) ) {}
       if ( ! $rate_detail && $charge eq '' ) {
 
-        warn "no rate_detail found for CDR.acctid:  ". $cdr->acctid.
+        warn "no rate_detail found for CDR.acctid: ". $cdr->acctid.
              "; skipping\n"
 
       } else { # there *is* a rate_detail (or call_details), proceed...



More information about the freeside-commits mailing list