diff options
author | ivan <ivan> | 2009-05-09 07:56:38 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-05-09 07:56:38 +0000 |
commit | a70e4bb88f298f93292380d1e2feb80e1baa13f8 (patch) | |
tree | 917abd2ae4c5aea9fd1651030af679b3f4c868d5 | |
parent | 39120f69d4372781aba0df58d06736be450009e1 (diff) |
add cdr-charged_party-truncate_{length,prefix} in order to trim charged_party to a certain length, RT#4081
-rw-r--r-- | FS/FS/Conf.pm | 16 | ||||
-rw-r--r-- | FS/FS/cdr.pm | 12 |
2 files changed, 25 insertions, 3 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index ebfad2c36..e86ed0d15 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -2719,9 +2719,23 @@ worry that config_items is freeside-specific and icky. }, { + 'key' => 'cdr-charged_party-truncate_prefix', + 'section' => '', + 'description' => 'If the charged_party field has this prefix, truncate it to the length in cdr-charged_party-truncate_length.', + 'type' => 'text', + }, + + { + 'key' => 'cdr-charged_party-truncate_length', + 'section' => '', + 'description' => 'If the charged_party field has the prefix in cdr-charged_party-truncate_prefix, truncate it to this length.', + 'type' => 'text', + }, + + { 'key' => 'cdr-charged_party_rewrite', 'section' => '', - 'description' => 'Do charged party rewriting in the freeside-cdrrewrited daemon; useful if CDRs are being dropped off directly in the database and require special charged_party processing such as cdr-charged_party-accountcode.', + 'description' => 'Do charged party rewriting in the freeside-cdrrewrited daemon; useful if CDRs are being dropped off directly in the database and require special charged_party processing such as cdr-charged_party-accountcode or cdr-charged_party-truncate*.', 'type' => 'checkbox', }, diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm index b640bc63e..2a235cc41 100644 --- a/FS/FS/cdr.pm +++ b/FS/FS/cdr.pm @@ -295,9 +295,9 @@ or to the dst field if it is a toll free number. sub set_charged_party { my $self = shift; - unless ( $self->charged_party ) { + my $conf = new FS::Conf; - my $conf = new FS::Conf; + unless ( $self->charged_party ) { if ( $conf->exists('cdr-charged_party-accountcode') && $self->accountcode ){ @@ -315,6 +315,14 @@ sub set_charged_party { } + my $prefix = $conf->config('cdr-charged_party-truncate_prefix'); + my $prefix_len = length($prefix); + my $trunc_len = $conf->config('cdr-charged_party-truncate_length'); + + $self->charged_party( substr($self->charged_party, 0, $trunc_len) ) + if $prefix_len && $trunc_len + && substr($self->charged_party, 0, $prefix_len) eq $prefix; + } =item set_status_and_rated_price STATUS [ RATED_PRICE ] |