diff options
| author | ivan <ivan> | 2008-03-15 21:14:31 +0000 | 
|---|---|---|
| committer | ivan <ivan> | 2008-03-15 21:14:31 +0000 | 
| commit | 58949250a661e60a5d5108f270db4c8f8c2bcad4 (patch) | |
| tree | 048ab95a24ef1cc531e84dc1e142da1ec22a6771 | |
| parent | 8bd2ad71aef6e393425ddf8f959f02e69aec4a61 (diff) | |
configurable disable_src, domestic_prefix and international_prefix options for voip price plan
| -rw-r--r-- | FS/FS/cust_svc.pm | 36 | ||||
| -rw-r--r-- | FS/FS/part_pkg/voip_cdr.pm | 24 | 
2 files changed, 34 insertions, 26 deletions
| diff --git a/FS/FS/cust_svc.pm b/FS/FS/cust_svc.pm index 51fc18688..f16856779 100644 --- a/FS/FS/cust_svc.pm +++ b/FS/FS/cust_svc.pm @@ -642,6 +642,17 @@ CDRs are associated with svc_phone services via svc_phone.phonenum  sub get_cdrs_for_update {    my($self, %options) = @_; +  my @cdrs = $self->get_cdrs_fromfield('charged_party', %options); + +  push @cdrs, $self->get_cdrs_fromfield('src', %options) +    unless $options{'disable_src'}; + +  @cdrs; +} + +sub get_cdrs_fromfield { +  my($self, $field, %options) = @_; +    my $default_prefix = $options{'default_prefix'};    #CDRs are now associated with svc_phone services via svc_phone.phonenum @@ -653,7 +664,7 @@ sub get_cdrs_for_update {      qsearch( {        'table'      => 'cdr',        'hashref'    => { 'freesidestatus' => '', -                        'charged_party'  => $number +                        $field           => $number                        },        'extra_sql'  => 'FOR UPDATE',      } ); @@ -663,33 +674,12 @@ sub get_cdrs_for_update {        qsearch( {          'table'      => 'cdr',          'hashref'    => { 'freesidestatus' => '', -                          'charged_party'  => "$default_prefix$number", +                          $field           => "$default_prefix$number",                          },          'extra_sql'  => 'FOR UPDATE',        } );    } -  #astricon hack?  config option? -  push @cdrs, -    qsearch( { -      'table'        => 'cdr', -      'hashref'      => { 'freesidestatus' => '', -                          'src'            => $number, -			}, -      'extra_sql'    => 'FOR UPDATE', -     } ); - -  if ( length($default_prefix) ) { -    push @cdrs, -      qsearch( { -        'table'        => 'cdr', -        'hashref'      => { 'freesidestatus' => '', -                            'src'            => "$default_prefix$number", -  			}, -        'extra_sql'    => 'FOR UPDATE', -       } ); -  } -    @cdrs;  } diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index 7cf177972..09b670eaa 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -53,6 +53,22 @@ tie my %rating_method, 'Tie::IxHash',                            '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', @@ -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; | 
