[freeside-commits] freeside/FS/FS/part_pkg voip_cdr.pm,1.68,1.69

Ivan,,, ivan at wavetail.420.am
Thu Jul 16 17:35:55 PDT 2009


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

Modified Files:
	voip_cdr.pm 
Log Message:
add single_price option so you can do one per-minute price without rate tables, RT#5495

Index: voip_cdr.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/voip_cdr.pm,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- voip_cdr.pm	17 Jul 2009 00:10:33 -0000	1.68
+++ voip_cdr.pm	17 Jul 2009 00:35:53 -0000	1.69
@@ -21,7 +21,7 @@
   'prefix' => 'Rate calls by using destination prefix to look up a region and rate according to the internal prefix and rate tables',
 #  'upstream' => 'Rate calls based on upstream data: If the call type is "1", map the upstream rate ID directly to an internal rate (rate_detail), otherwise, pass the upstream price through directly.',
   'upstream_simple' => 'Simply pass through and charge the "upstream_price" amount.',
-  'flat' => 'A single price per minute for all calls.',
+  'single_price' => 'A single price per minute for all calls.',
 ;
 
 tie my %recur_method, 'Tie::IxHash',
@@ -75,7 +75,7 @@
                          'select_options' => \%recur_method,
                        },
 
-    'rating_method' => { 'name' => 'Region rating method',
+    'rating_method' => { 'name' => 'Rating method',
                          'type' => 'radio',
                          'options' => \%rating_method,
                        },
@@ -87,6 +87,10 @@
                      'select_label' => 'ratename',
                    },
 
+    'min_charge' => { 'name' => 'Charge per minute when using "single price per minute" rating method',
+                      'type' => 'money',
+                    },
+
     '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',
                            },
@@ -440,6 +444,32 @@
                         );
         $classnum = $cdr->calltypenum;
 
+      } elsif ( $rating_method eq 'single_price' ) {
+
+        # a little false laziness w/below
+
+        my $granularity = 60;
+
+                    # length($cdr->billsec) ? $cdr->billsec : $cdr->duration;
+        my $seconds = $use_duration ? $cdr->duration : $cdr->billsec;
+
+        $seconds += $granularity - ( $seconds % $granularity )
+          if $seconds      # don't granular-ize 0 billsec calls (bills them)
+          ;#&& $granularity; # 0 is per call
+        my $minutes = sprintf("%.1f", $seconds / 60);
+        $minutes =~ s/\.0$// ;# if $granularity == 60;
+
+        $charge = sprintf('%.2f', ( $self->option('min_charge') * $minutes )
+                                  + 0.00000001 ); #so 1.005 rounds to 1.01
+
+        $charge =  
+        $charges += $charge;
+
+        @call_details = ($cdr->downstream_csv( 'format' => $output_format,
+                                               'charge' => $charge,
+                                             )
+                        );
+
       } else {
         die "don't know how to rate CDRs using method: $rating_method\n";
       }



More information about the freeside-commits mailing list