'default' => '+1',
},
+ 'disable_src' => { 'name' => 'Disable rating of CDR records based on the "src" field in addition to "charged_party"',
+ 'type' => 'checkbox'
+ },
+
+ 'domestic_prefix' => { 'name' => 'Destination prefix for domestic CDR records',
+ 'default' => '1',
+ },
+
+# 'domestic_prefix_required' => { 'name' => 'Require explicit destination prefix for domestic CDR records',
+# 'type' => 'checkbox',
+# },
+
+ 'international_prefix' => { 'name' => 'Destination prefix for international CDR records',
+ 'default' => '011',
+ },
+
#XXX also have option for an external db??
# 'cdr_location' => { 'name' => 'CDR database location'
# 'type' => 'select',
###
my( $to_or_from, $number );
- if ( $cdr->dst =~ /^(\+?1)?8[02-8]{2}/ ) { #tollfree call
+ if ( $cdr->dst =~ /^(\+?1)?8([02-8])\1/ ) { #tollfree call
$to_or_from = 'from';
$number = $cdr->src;
} else { #regular call
# $dest =~ s/^(\w+):// and $proto = $1; #sip:
# my $siphost = '';
# $dest =~ s/\@(.*)$// and $siphost = $1; # @10.54.32.1, @sip.example.com
+
+ my $intl = $self->option('international_prefix') || '011';
#determine the country code
my $countrycode;
- if ( $number =~ /^011(((\d)(\d))(\d))(\d+)$/
+ if ( $number =~ /^$intl(((\d)(\d))(\d))(\d+)$/
|| $number =~ /^\+(((\d)(\d))(\d))(\d+)$/
)
{
}
} else {
- $countrycode = '1';
- $number =~ s/^1//;# if length($number) > 10;
+ $countrycode = $self->option('domestic_prefix') || '1';
+ $number =~ s/^$countrycode//;# if length($number) > 10;
}
warn "rating call $to_or_from +$countrycode $number\n" if $DEBUG;
my $granularity = $rate_detail->sec_granularity;
my $seconds = $cdr->billsec; # |ength($cdr->billsec) ? $cdr->billsec : $cdr->duration;
- $seconds += $granularity - ( $seconds % $granularity );
+ $seconds += $granularity - ( $seconds % $granularity )
+ if $granularity; # 0 is per call
my $minutes = sprintf("%.1f", $seconds / 60);
$minutes =~ s/\.0$// if $granularity == 60;
+
+ # per call rather than per minute
+ $minutes = 1 unless $granularity;
$included_min{$regionnum} -= $minutes;
@call_details = (
#time2str("%Y %b %d - %r", $cdr->calldate_unix ),
time2str("%c", $cdr->calldate_unix), #XXX this should probably be a config option dropdown so they can select US vs- rest of world dates or whatnot
- $minutes.'m',
+ $granularity ? $minutes.'m' : $minutes.' call',
'$'.$charge,
$pretty_destnum,
$rate_region->regionname,