set charged_party to accoutncode for vedeye, RT#4342
authorivan <ivan>
Mon, 1 Dec 2008 07:53:12 +0000 (07:53 +0000)
committerivan <ivan>
Mon, 1 Dec 2008 07:53:12 +0000 (07:53 +0000)
FS/FS/Conf.pm
FS/FS/cdr.pm

index e1fb842..eba04d4 100644 (file)
@@ -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;
index 20c3dbc..ba3e492 100644 (file)
@@ -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?