From 43bd4c723d9da8dbf2ed0428620aade17e44bac9 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 1 Dec 2008 07:53:12 +0000 Subject: [PATCH] set charged_party to accoutncode for vedeye, RT#4342 --- FS/FS/Conf.pm | 8 ++++++++ FS/FS/cdr.pm | 18 +++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index e1fb8427b..eba04d426 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -2584,6 +2584,14 @@ worry that config_items is freeside-specific and icky. 'type' => 'text', }, + { + 'key' => 'cdr-charged_party-accountcode', + 'section' => '', + 'description' => 'Set the charged_party field of CDRs to the accountcode.', + 'type' => 'checkbox', + }, + + ); 1; diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm index 20c3dbc93..ba3e49252 100644 --- a/FS/FS/cdr.pm +++ b/FS/FS/cdr.pm @@ -233,12 +233,24 @@ sub check { $self->calldate( $self->startdate_sql ) if !$self->calldate && $self->startdate; + my $conf = new FS::Conf; + unless ( $self->charged_party ) { - if ( $self->dst =~ /^(\+?1)?8[02-8]{2}/ ) { - $self->charged_party($self->dst); + + if ( $conf->exists('cdr-charged_party-accountcode') && $self->accountcode ){ + + $self->charged_party( $self->accountcode ); + } else { - $self->charged_party($self->src); + + if ( $self->dst =~ /^(\+?1)?8[02-8]{2}/ ) { + $self->charged_party($self->dst); + } else { + $self->charged_party($self->src); + } + } + } #check the foreign keys even? -- 2.11.0