From 2e430537fc5a43118b14b9a54381943fd7b51a6b Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Tue, 3 Sep 2019 10:01:11 -0700 Subject: [PATCH] CDR efficiency --- FS/FS/Conf.pm | 16 ++++++++-------- FS/FS/cdr.pm | 23 +++++++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 070b56b4a..e606cf5bd 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -5138,7 +5138,7 @@ and customer address. Include units.', { 'key' => 'cdr-charged_party-field', 'section' => 'telephony', - 'description' => 'Set the charged_party field of CDRs to this field.', + 'description' => 'Set the charged_party field of CDRs to this field. Restart Apache and Freeside daemons after changing.', 'type' => 'select-sub', 'options_sub' => sub { my $fields = FS::cdr->table_info->{'fields'}; map { $_ => $fields->{$_}||$_ } @@ -5154,14 +5154,14 @@ and customer address. Include units.', { 'key' => 'cdr-charged_party-accountcode', 'section' => 'telephony', - 'description' => 'Set the charged_party field of CDRs to the accountcode.', + 'description' => 'Set the charged_party field of CDRs to the accountcode. Restart Apache and Freeside daemons after changing.', 'type' => 'checkbox', }, { 'key' => 'cdr-charged_party-accountcode-trim_leading_0s', 'section' => 'telephony', - 'description' => 'When setting the charged_party field of CDRs to the accountcode, trim any leading zeros.', + 'description' => 'When setting the charged_party field of CDRs to the accountcode, trim any leading zeros. Restart Apache and Freeside daemons after changing.', 'type' => 'checkbox', }, @@ -5259,7 +5259,7 @@ and customer address. Include units.', { 'key' => 'cdr-max_duration', 'section' => 'telephony', - 'description' => 'If set, defines a global maximum billsec/duration for (prefix-based) call rating, in seconds. Used with questionable/dirty CDR data that may contain bad records with long billsecs/durations.', + 'description' => 'If set, defines a global maximum billsec/duration for (prefix-based) call rating, in seconds. Used with questionable/dirty CDR data that may contain bad records with long billsecs/durations. Restart Apache and Freeside daemons after changing.', 'type' => 'text', }, @@ -5787,14 +5787,14 @@ and customer address. Include units.', { 'key' => 'cdr-prerate', 'section' => 'telephony', - 'description' => 'Experimental feature to rate CDRs immediately, rather than waiting until invoice generation time. Can reduce invoice generation time when processing lots of CDRs. Currently works with "VoIP/telco CDR rating (standard)" price plans using "Phone numbers (svc_phone.phonenum)" CDR service matching, without any included minutes.', + 'description' => 'Experimental feature to rate CDRs immediately, rather than waiting until invoice generation time. Can reduce invoice generation time when processing lots of CDRs. Currently works with "VoIP/telco CDR rating (standard)" price plans using "Phone numbers (svc_phone.phonenum)" CDR service matching, without any included minutes. Restart Apache and Freeside daemons after changing.', 'type' => 'checkbox', }, { 'key' => 'cdr-prerate-cdrtypenums', 'section' => 'telephony', - 'description' => 'When using cdr-prerate to rate CDRs immediately, limit processing to these CDR types.', + 'description' => 'When using cdr-prerate to rate CDRs immediately, limit processing to these CDR types. Restart Apache and Freeside daemons after changing.', 'type' => 'select-sub', 'multiple' => 1, 'options_sub' => sub { require FS::Record; @@ -5828,7 +5828,7 @@ and customer address. Include units.', { 'key' => 'cdr-lrn_lookup', 'section' => 'telephony', - 'description' => 'Look up LRNs of destination numbers for exact matching to the terminating carrier. This feature requires a Freeside support contract for paid access to the central NPAC database; see support-key.', + 'description' => 'Look up LRNs of destination numbers for exact matching to the terminating carrier. This feature requires a Freeside support contract for paid access to the central NPAC database; see support-key. Restart Apache and Freeside daemons after changing.', 'type' => 'checkbox', }, @@ -6028,7 +6028,7 @@ and customer address. Include units.', { 'key' => 'tollfree-country', 'section' => 'telephony', - 'description' => 'Country / region for toll-free recognition', + 'description' => 'Country / region for toll-free recognition. Restart Apache and Freeside daemons after changing.', 'type' => 'select', 'select_hash' => [ '' => 'NANPA (US/Canada)', 'AU' => 'Australia', diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm index aa1c4067f..85fccac69 100644 --- a/FS/FS/cdr.pm +++ b/FS/FS/cdr.pm @@ -4,6 +4,8 @@ use strict; use vars qw( @ISA @EXPORT_OK $DEBUG $me $conf $cdr_prerate %cdr_prerate_cdrtypenums $use_lrn $support_key $max_duration + $cp_accountcode $cp_accountcode_trim0s $cp_field + $tollfree_country ); use Exporter; use List::Util qw(first min); @@ -52,6 +54,13 @@ FS::UID->install_callback( sub { $max_duration = $conf->config('cdr-max_duration') || 0; + $cp_accountcode = $conf->exists('cdr-charged_party-accountcode'); + $cp_accountcode_trim0s = $conf->exists('cdr-charged_party-accountcode-trim_leading_0s'); + + $cp_field = $conf->config('cdr-charged_party-field'); + + $tollfree_country = $conf->config('tollfree-country') || ''; + }); =head1 NAME @@ -388,10 +397,9 @@ to inspect other field. sub is_tollfree { my $self = shift; my $field = scalar(@_) ? shift : 'dst'; - my $country = $conf->config('tollfree-country') || ''; - if ( $country eq 'AU' ) { + if ( $tollfree_country eq 'AU' ) { ( $self->$field() =~ /^(\+?61)?(1800|1300)/ ) ? 1 : 0; - } elsif ( $country eq 'NZ' ) { + } elsif ( $tollfree_country eq 'NZ' ) { ( $self->$field() =~ /^(\+?64)?(800|508)/ ) ? 1 : 0; } else { #NANPA (US/Canaada) ( $self->$field() =~ /^(\+?1)?8(8|([02-7])\3)/ ) ? 1 : 0; @@ -417,17 +425,16 @@ sub set_charged_party { unless ( $self->charged_party ) { - if ( $conf->exists('cdr-charged_party-accountcode') && $self->accountcode ){ + if ( $cp_accountcode && $self->accountcode ) { my $charged_party = $self->accountcode; $charged_party =~ s/^0+// - if $conf->exists('cdr-charged_party-accountcode-trim_leading_0s'); + if $cp_accountcode_trim0s; $self->charged_party( $charged_party ); - } elsif ( $conf->exists('cdr-charged_party-field') ) { + } elsif ( $cp_field ) { - my $field = $conf->config('cdr-charged_party-field'); - $self->charged_party( $self->$field() ); + $self->charged_party( $self->$cp_field() ); } else { -- 2.11.0