[freeside-commits] freeside/FS/FS/part_pkg voip_tiered.pm,1.1,1.2

Ivan,,, ivan at wavetail.420.am
Thu Nov 17 16:09:52 PST 2011


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

Modified Files:
	voip_tiered.pm 
Log Message:
reduce memory usage of voip_tiered, RT#14903

Index: voip_tiered.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/voip_tiered.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- voip_tiered.pm	14 Nov 2011 04:27:57 -0000	1.1
+++ voip_tiered.pm	18 Nov 2011 00:09:50 -0000	1.2
@@ -107,7 +107,6 @@
   # pass one: find the total minutes/calls and store the CDRs
   ###
   my $total = 0;
-  my @cdrs = ();
 
   my @cust_svc;
   if( $self->option('bill_inactive_svcs',1) ) {
@@ -161,11 +160,16 @@
            $included_min = 0;
         }
 
-        $cdr->tmp_inout( $pass );
-        $cdr->tmp_rated_seconds( $seconds );
-        $cdr->tmp_rated_minutes( $charge_min );
-        $cdr->tmp_svcnum( $cust_svc->svcnum );
-        push @cdrs, $cdr;
+        my $error = $cdr->set_status_and_rated_price(
+          'processing-tiered',
+          '', #charge,
+          $cust_svc->svcnum,
+          'inbound'       => ($pass eq 'inbound'),
+          'rated_minutes' => $charge_min,
+          'rated_seconds' => $seconds,
+        );
+        die $error if $error;
+
         $total += $charge_min;
 
       } # $cdr
@@ -191,14 +195,35 @@
   my $charges = 0;
   my @invoice_details_sort;
 
-  foreach my $cdr (@cdrs) {
+  $options{'status'} = 'processing-tiered';
 
-    my $charge_min = $cdr->tmp_rated_minutes;
+  foreach my $cust_svc (@cust_svc) {
+
+    my $svc_x;
+    if( $self->option('bill_inactive_svcs',1) ) {
+      $svc_x = $cust_svc->h_svc_x($$sdate, $last_bill);
+    }
+    else {
+      $svc_x = $cust_svc->svc_x;
+    }
+
+    foreach my $pass (split('_', $cdr_inout)) {
+
+      $options{'inbound'} = ( $pass eq 'inbound' );
+
+      foreach my $cdr (
+        $svc_x->get_cdrs( %options )
+      ) {
+
+        my $object = $options{'inbound'}
+                       ? $cdr->cdr_termination( 1 ) #1: inbound
+                       : $cdr;
+
+        my $charge_min = $object->rated_minutes;
 
     my $charge = sprintf('%.4f', ( $min_charge * $charge_min )
                                  + 0.0000000001 ); #so 1.00005 rounds to 1.0001
 
-
     if ( $charge > 0 ) {
       $charges += $charge;
 
@@ -219,7 +244,7 @@
           #phonenum    => $phonenum, #XXX need this to sort on them
           accountcode => $cdr->accountcode,
           startdate   => $cdr->startdate,
-          duration    => $cdr->tmp_rated_seconds,
+              duration    => $object->rated_seconds,
         };
 
        #warn "  adding details on charge to invoice: [ ".
@@ -231,15 +256,18 @@
     my $error = $cdr->set_status_and_rated_price(
       'done',
       $charge,
-      $cdr->tmp_svcnum,
-      'inbound'       => ($cdr->tmp_inout eq 'inbound'),
+          $cust_svc->svcnum,
+          'inbound'       => $options{'inbound'},
       'rated_minutes' => $charge_min,
-      'rated_seconds' => $cdr->tmp_rated_seconds,
+          'rated_seconds' => $object->rated_seconds,
     );
     die $error if $error;
 
+      } # $cdr
 
-  }
+    } # $pass
+
+  } # $cust_svc
 
   my @sorted_invoice_details = sort { ${$a}[1] <=> ${$b}[1] } @invoice_details_sort;
   foreach my $sorted_call_detail ( @sorted_invoice_details ) {



More information about the freeside-commits mailing list