From 074a4f11382b593e091bdaa5ee33884d05cd5b7c Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 13 Jul 2010 23:06:10 +0000 Subject: [PATCH] without screwing up usage summaries RT#8605 --- FS/FS/part_pkg/voip_cdr.pm | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) 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 -- 2.11.0