X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=FS%2FFS%2Fpart_pkg%2Fvoip_cdr.pm;h=ea160315b17f127147208117d2c16bcdccf45988;hb=9464e3517fcae6a735c14b3fb15b91f3886a884a;hp=2341fd020aa31b4cbeb284a4a592b52b984aa35b;hpb=9509e5bfb7f9331303153cac24d7bfecbe2ea9f1;p=freeside.git diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index 2341fd020..ea160315b 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -26,7 +26,7 @@ tie my %rating_method, 'Tie::IxHash', #; %info = ( - 'name' => 'VoIP rating by plan of CDR records in an internal (or external?) SQL table', + 'name' => 'VoIP rating by plan of CDR records in an internal (or external) SQL table', 'fields' => { 'setup_fee' => { 'name' => 'Setup fee for this package', 'default' => 0, @@ -45,15 +45,31 @@ tie my %rating_method, 'Tie::IxHash', 'select_label' => 'ratename', }, 'rating_method' => { 'name' => 'Region rating method', - 'type' => 'select', - 'select_options' => \%rating_method, + 'type' => 'radio', + 'options' => \%rating_method, }, 'default_prefix' => { 'name' => 'Default prefix optionally prepended to customer DID numbers when searching for CDR records', 'default' => '+1', }, - #XXX also have option for an external db?? + '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', # 'select_options' => \%cdr_location, @@ -77,7 +93,7 @@ tie my %rating_method, 'Tie::IxHash', # }, }, - 'fieldorder' => [qw( setup_fee recur_flat unused_credit ratenum rating_method default_prefix )], + 'fieldorder' => [qw( setup_fee recur_flat unused_credit ratenum rating_method default_prefix disable_src domestic_prefix international_prefix )], 'weight' => 40, ); @@ -144,10 +160,12 @@ sub calc_recur { # $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+)$/ ) { @@ -166,8 +184,8 @@ sub calc_recur { } } 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; @@ -261,9 +279,13 @@ sub calc_recur { 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; @@ -280,7 +302,7 @@ sub calc_recur { @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,