- my $charge = sprintf('%.2f', ( $self->option('min_charge') * $minutes )
- + 0.00000001 ); #so 1.00005 rounds to 1.0001
- 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,
- $seconds,
- '', #regionname, not set for inbound calls
- ];
+
+ my $charge_min = $minutes;
+ my $charge = 0;
+
+ $included_min -= $minutes;
+ if ( $included_min > 0 ) {
+ $charge_min = 0;
+ }
+ else {
+ $charge_min = 0 - $included_min;
+ $included_min = 0;
+ }
+
+ $charge = sprintf('%.2f', ( $self->option('min_charge') * $charge_min )
+ + 0.00000001 ); #so 1.00005 rounds to 1.0001
+
+ if ( $charge > 0 ) {
+ $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,
+ $seconds,
+ '', #regionname, not set for inbound calls
+ ];
+ }