From: jeff Date: Wed, 14 Jul 2010 00:17:51 +0000 (+0000) Subject: third time's a charm - fix a small bug and make more analogous to HEAD - RT#8605 X-Git-Tag: freeside_1_9_4~5 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=f2d1ae9c366257a6308a4120f190b416b514b1f3 third time's a charm - fix a small bug and make more analogous to HEAD - RT#8605 --- 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;