[freeside-commits] branch master updated. 98460903530ead429f608ba6fce4eac1a8ee3cf3

Ivan ivan at 420.am
Tue Oct 9 12:32:44 PDT 2012


The branch, master has been updated
       via  98460903530ead429f608ba6fce4eac1a8ee3cf3 (commit)
       via  0f3189c19c3cb41f7daafbc102d692a8426cb427 (commit)
      from  a977d27ac2e9d8f8e1adbbdcfc3547bc378dde63 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 98460903530ead429f608ba6fce4eac1a8ee3cf3
Merge: 0f3189c a977d27
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Oct 9 12:32:39 2012 -0700

    Merge branch 'master' of git.freeside.biz:/home/git/freeside


commit 0f3189c19c3cb41f7daafbc102d692a8426cb427
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Oct 9 12:32:33 2012 -0700

    resolve connection charges getting charged before (group) included minutes, RT#19756

diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm
index 05179f2..fdec921 100644
--- a/FS/FS/cdr.pm
+++ b/FS/FS/cdr.pm
@@ -773,11 +773,16 @@ sub rate_prefix {
   my $seconds_left = $part_pkg->option_cacheable('use_duration')
                        ? $self->duration
                        : $self->billsec;
-  # charge for the first (conn_sec) seconds
-  my $seconds = min($seconds_left, $rate_detail->conn_sec);
-  $seconds_left -= $seconds; 
-  $weektime     += $seconds;
-  my $charge = $rate_detail->conn_charge; 
+
+  #no, do this later so it respects (group) included minutes
+  #  # charge for the first (conn_sec) seconds
+  #  my $seconds = min($seconds_left, $rate_detail->conn_sec);
+  #  $seconds_left -= $seconds; 
+  #  $weektime     += $seconds;
+  #  my $charge = $rate_detail->conn_charge; 
+  my $seconds = 0;
+  my $charge = 0;
+  my $connection_charged = 0;
 
   my $etime;
   while($seconds_left) {
@@ -840,6 +845,7 @@ sub rate_prefix {
 
     $seconds += $charge_sec;
 
+
     my $region_group = ($part_pkg->option_cacheable('min_included') || 0) > 0;
 
     ${$opt{region_group_included_min}} -= $minutes 
@@ -853,10 +859,21 @@ sub rate_prefix {
             )
        )
     {
+
+      #NOW do connection charges here... right?
+      #my $conn_seconds = min($seconds_left, $rate_detail->conn_sec);
+      my $conn_seconds = 0;
+      unless ( $connection_charged++ ) { #only one connection charge
+        $conn_seconds = min($charge_sec, $rate_detail->conn_sec);
+        $seconds_left -= $conn_seconds; 
+        $weektime     += $conn_seconds;
+        $charge += $rate_detail->conn_charge; 
+      }
+
                            #should preserve (display?) this
-      my $charge_min = 0 - $included_min->{$regionnum}{$ratetimenum};
+      my $charge_min = 0 - $included_min->{$regionnum}{$ratetimenum} - ( $conn_seconds / 60 );
       $included_min->{$regionnum}{$ratetimenum} = 0;
-      $charge += ($rate_detail->min_charge * $charge_min); #still not rounded
+      $charge += ($rate_detail->min_charge * $charge_min) if $charge_min > 0; #still not rounded
 
     } elsif ( ${$opt{region_group_included_min}} > 0
               && $region_group

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/cdr.pm |   31 ++++++++++++++++++++++++-------
 1 files changed, 24 insertions(+), 7 deletions(-)




More information about the freeside-commits mailing list