[freeside-commits] freeside/FS/FS Schema.pm, 1.235, 1.236 cdr.pm, 1.63, 1.64

Mark Wells mark at wavetail.420.am
Fri Sep 24 17:56:34 PDT 2010


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

Modified Files:
	Schema.pm cdr.pm 
Log Message:
clean up call rating math to avoid premature rounding, RT#9885

Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.235
retrieving revision 1.236
diff -u -w -d -r1.235 -r1.236
--- Schema.pm	22 Sep 2010 21:22:03 -0000	1.235
+++ Schema.pm	25 Sep 2010 00:56:31 -0000	1.236
@@ -2269,12 +2269,11 @@
         'orig_regionnum',  'int', 'NULL',     '', '', '', 
         'dest_regionnum',  'int',     '',     '', '', '', 
         'min_included',    'int',     '',     '', '', '', 
-        'conn_charge',     @money_type, '0', '', #'decimal','','10,5','0','',
+        'conn_charge',     'decimal', '', '10,4', '0', '',
         'conn_sec',        'int',     '',     '', '0', '',
         'min_charge',      'decimal', '', '10,5', '', '', #@money_type, '', '', 
         'sec_granularity', 'int',     '',     '', '', '', 
         'ratetimenum',     'int', 'NULL',     '', '', '',
-        #time period (link to table of periods)?
         'classnum',        'int', 'NULL',     '', '', '', 
       ],
       'primary_key' => 'ratedetailnum',

Index: cdr.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cdr.pm,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -w -d -r1.63 -r1.64
--- cdr.pm	22 Sep 2010 19:35:18 -0000	1.63
+++ cdr.pm	25 Sep 2010 00:56:32 -0000	1.64
@@ -548,14 +548,24 @@
   my $conf = new FS::Conf;
   my $date_format = $conf->config('date_format') || '%m/%d/%Y';
 
+  # This is now smarter, and shows the call duration in the 
+  # largest units that accurately reflect the granularity.
   my $duration_sub = sub {
     my($cdr, %opt) = @_;
-    if ( $opt{minutes} ) {
-      $opt{minutes}. ( $opt{granularity} ? 'm' : ' call' );
-    } else {
-      #config if anyone really wants decimal minutes back
-      #sprintf('%.2fm', $cdr->billsec / 60 );
-      int($cdr->billsec / 60).'m '. ($cdr->billsec % 60).'s';
+    my $sec = $opt{seconds} || $cdr->billsec;
+    if ( length($opt{granularity}) && 
+         $opt{granularity} == 0 ) { #per call
+      return '1 call';
+    }
+    elsif ( $opt{granularity} == 60 ) {#full minutes
+      return sprintf("%.0fm",$sec/60);
+    }
+    elsif ( $opt{granularity} == 6 || 
+            $opt{granularity} == 30 ) {#tenths or halves
+      return sprintf("%.01fm",$sec/60);
+    }
+    else { #seconds, or unspecified
+      return sprintf("%dm %ds", $sec/60, $sec%60);
     }
   };
 



More information about the freeside-commits mailing list