From f2d1ae9c366257a6308a4120f190b416b514b1f3 Mon Sep 17 00:00:00 2001 From: jeff Date: Wed, 14 Jul 2010 00:17:51 +0000 Subject: [PATCH] third time's a charm - fix a small bug and make more analogous to HEAD - RT#8605 --- FS/FS/part_pkg/voip_cdr.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index 24f9fc841..e2408a3d1 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -538,18 +538,18 @@ sub calc_usage { my $granularity = $rate_detail->sec_granularity; # length($cdr->billsec) ? $cdr->billsec : $cdr->duration; - my $charge_sec = $seconds = - $use_duration ? $cdr->duration : $cdr->billsec; + my $charge_sec = $use_duration ? $cdr->duration : $cdr->billsec; + $seconds = ( $charge_sec <= $rate_detail->conn_sec ) # min() + ? $charge_sec + : $rate_detail->conn_sec; $charge_sec -= $rate_detail->conn_sec; $charge_sec = 0 if $charge_sec < 0; - if ( $seconds && $granularity ) { - # don't granular-ize 0 billsec calls (bills them) - # 0 granularity is per call - $seconds += $granularity - ( $seconds % $granularity ); - $charge_sec += $granularity - ( $charge_sec % $granularity ); - } + $charge_sec += $granularity - ( $charge_sec % $granularity ) + if $charge_sec # don't granular-ize 0 billsec calls (bills them) + && $granularity; # 0 is per call + $seconds += $charge_sec; my $minutes = sprintf("%.1f", $charge_sec / 60); $minutes =~ s/\.0$// if $granularity == 60; -- 2.11.0