From: jeff Date: Tue, 13 Jul 2010 23:06:10 +0000 (+0000) Subject: without screwing up usage summaries RT#8605 X-Git-Tag: freeside_1_9_4~6 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=074a4f11382b593e091bdaa5ee33884d05cd5b7c;ds=sidebyside without screwing up usage summaries RT#8605 --- diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index de47b4508..24f9fc841 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -538,19 +538,24 @@ sub calc_usage { my $granularity = $rate_detail->sec_granularity; # length($cdr->billsec) ? $cdr->billsec : $cdr->duration; - $seconds = $use_duration ? $cdr->duration : $cdr->billsec; + my $charge_sec = $seconds = + $use_duration ? $cdr->duration : $cdr->billsec; - $seconds -= $rate_detail->conn_sec; - $seconds = 0 if $seconds < 0; + $charge_sec -= $rate_detail->conn_sec; + $charge_sec = 0 if $charge_sec < 0; - $seconds += $granularity - ( $seconds % $granularity ) - if $seconds # don't granular-ize 0 billsec calls (bills them) - && $granularity; # 0 is per call - my $minutes = sprintf("%.1f", $seconds / 60); + 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 ); + } + + my $minutes = sprintf("%.1f", $charge_sec / 60); $minutes =~ s/\.0$// if $granularity == 60; my $duration_minutes = #for invoice display purposes - sprintf("%.1f", ($seconds + $rate_detail->conn_sec)/ 60); + sprintf("%.1f", $seconds / 60); $duration_minutes =~ s/\.0$// if $granularity == 60; # per call rather than per minute