summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS/Conf.pm8
-rw-r--r--FS/FS/cdr.pm18
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?