- next if !$charge;
- $charges += $charge;
- my @call_details = ($cdr->downstream_csv( 'format' => $output_format,
- 'charge' => $charge,
- 'minutes' => $minutes,
- 'granularity' => $granularity,
- )
- );
- push @$details,
- [ 'C',
- $call_details[0],
- $charge,
- $cdr->calltypenum, #classnum
- $self->phonenum,
- $cdr->accountcode,
- $seconds,
- '', #regionname, not set for inbound calls
- ];
-
- my $error = $cdr->set_status_and_rated_price( 'done',
+
+ if ( $charge > 0 ) {
+ $charges += $charge;
+ my @call_details = (
+ $cdr->downstream_csv( 'format' => $output_format,
+ 'charge' => $charge,
+ 'seconds' => ($use_duration
+ ? $cdr->duration
+ : $cdr->billsec
+ ),
+ 'granularity' => $granularity,
+ )
+ );
+ push @$details,
+ [ 'C',
+ $call_details[0],
+ $charge,
+ $cdr->calltypenum, #classnum
+ '', #phonenum,
+ $cdr->accountcode,
+ $cdr->startdate,
+ $seconds,
+ '', #regionname, not set for inbound calls
+ ];
+ }
+
+ my $error = $cdr->set_status_and_rated_price( 'done',