diff options
author | ivan <ivan> | 2009-03-02 04:58:09 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-03-02 04:58:09 +0000 |
commit | caf4bbf142bc25fa583e258ac3e1724a9eee8d5b (patch) | |
tree | 6323c7e33b2523d238e0a183bb2c3d07da365df4 /FS/FS | |
parent | bd73a121f43bea3bf2ea576be109a680827676b9 (diff) |
option to do charged_party rewriting in the cdrrewrited daemon, RT#4342
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/Conf.pm | 14 | ||||
-rw-r--r-- | FS/FS/cdr.pm | 57 |
2 files changed, 52 insertions, 19 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 8c5b296e0..b86930255 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -2647,6 +2647,13 @@ worry that config_items is freeside-specific and icky. }, { + '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.', + 'type' => 'checkbox', + }, + + { 'key' => 'cdr-taqua-da_rewrite', 'section' => '', 'description' => 'For the Taqua CDR format, a comma-separated list of directory assistance 800 numbers. Any CDRs with these numbers as "BilledNumber" will be rewritten to the "CallingPartyNumber" (and CallType "12") on import.', @@ -2660,6 +2667,13 @@ worry that config_items is freeside-specific and icky. 'type' => 'checkbox', }, + { + 'key' => 'cdr-asterisk_forward_rewrite', + 'section' => '', + 'description' => 'Enable special processing for CDRs representing forwarded calls: For CDRs that have a dcontext that starts with "Local/" but does not match dst, set charged_party to dst, parse a new dst from dstchannel, and set amaflags to "2" ("BILL"/"BILLING").', + 'type' => 'checkbox', + }, + ); 1; diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm index 8307b287e..67c5c1c2a 100644 --- a/FS/FS/cdr.pm +++ b/FS/FS/cdr.pm @@ -246,25 +246,7 @@ sub check { $self->billsec( $self->enddate - $self->answerdate ); } - my $conf = new FS::Conf; - - unless ( $self->charged_party ) { - - if ( $conf->exists('cdr-charged_party-accountcode') && $self->accountcode ){ - - $self->charged_party( $self->accountcode ); - - } else { - - if ( $self->dst =~ /^(\+?1)?8[02-8]{2}/ ) { - $self->charged_party($self->dst); - } else { - $self->charged_party($self->src); - } - - } - - } + $self->set_charged_party; #check the foreign keys even? #do we want to outright *reject* the CDR? @@ -287,6 +269,43 @@ sub check { $self->SUPER::check; } +=item set_charged_party + +If the charged_party field is already set, does nothing. Otherwise: + +If the cdr-charged_party-accountcode config option is enabled, sets the +charged_party to the accountcode. + +Otherwise sets the charged_party normally: to the src field in most cases, +or to the dst field if it is a toll free number. + +=cut + +sub set_charged_party { + my $self = shift; + + unless ( $self->charged_party ) { + + my $conf = new FS::Conf; + + if ( $conf->exists('cdr-charged_party-accountcode') && $self->accountcode ){ + + $self->charged_party( $self->accountcode ); + + } else { + + if ( $self->dst =~ /^(\+?1)?8[02-8]{2}/ ) { + $self->charged_party($self->dst); + } else { + $self->charged_party($self->src); + } + + } + + } + +} + =item set_status_and_rated_price STATUS [ RATED_PRICE ] Sets the status to the provided string. If there is an error, returns the |