Merge branch 'master' of git.freeside.biz:/home/git/freeside
authorIvan Kohler <ivan@freeside.biz>
Wed, 4 Sep 2013 05:52:26 +0000 (22:52 -0700)
committerIvan Kohler <ivan@freeside.biz>
Wed, 4 Sep 2013 05:52:26 +0000 (22:52 -0700)
1  2 
FS/FS/cdr.pm

diff --combined FS/FS/cdr.pm
@@@ -932,8 -932,12 +932,12 @@@ sub rate_prefix 
        }
  
                             #should preserve (display?) this
-       my $charge_min = ( $charge_sec - $conn_seconds ) / 60;
-       $charge += ($rate_detail->min_charge * $charge_min) if $charge_min > 0; #still not rounded
+       if ( $granularity == 0 ) { # per call rate
+         $charge += $rate_detail->min_charge;
+       } else {
+         my $charge_min = ( $charge_sec - $conn_seconds ) / 60;
+         $charge += ($rate_detail->min_charge * $charge_min) if $charge_min > 0; #still not rounded
+       }
  
      }
  
    # this is why we need regionnum/rate_region....
    warn "  (rate region $rate_region)\n" if $DEBUG;
  
 +  # NOW round it.
 +  my $rounding = $part_pkg->option_cacheable('rounding') || 2;
 +  my $sprintformat = '%.'. $rounding. 'f';
 +  my $roundup = 10**(-3-$rounding);
 +  my $price = sprintf($sprintformat, $charge + $roundup);
 +
    $self->set_status_and_rated_price(
      'rated',
 -    sprintf('%.2f', $charge + 0.000001), # NOW round it.
 +    $price,
      $opt{'svcnum'},
      'rated_pretty_dst'    => $pretty_dst,
      'rated_regionname'    => $rate_region->regionname,