add option to trim leading zeros when setting charged_party to accountcode, RT#5495
authorivan <ivan>
Wed, 15 Jul 2009 22:49:33 +0000 (22:49 +0000)
committerivan <ivan>
Wed, 15 Jul 2009 22:49:33 +0000 (22:49 +0000)
FS/FS/Conf.pm
FS/FS/cdr.pm

index 70dfa68..eb046ee 100644 (file)
@@ -2751,6 +2751,13 @@ worry that config_items is freeside-specific and icky.
     'type'        => 'checkbox',
   },
 
+  {
+    'key'         => 'cdr-charged_party-accountcode-trim_leading_0s',
+    'section'     => '',
+    'description' => 'When setting the charged_party field of CDRs to the accountcode, trim any leading zeros.',
+    'type'        => 'checkbox',
+  },
+
 #  {
 #    'key'         => 'cdr-charged_party-truncate_prefix',
 #    'section'     => '',
index 723123a..efccd4b 100644 (file)
@@ -349,7 +349,10 @@ sub set_charged_party {
 
     if ( $conf->exists('cdr-charged_party-accountcode') && $self->accountcode ){
 
-      $self->charged_party( $self->accountcode );
+      my $charged_party = $self->accountcode;
+      $charged_party =~ s/^0+//
+        if $conf->exists('cdr-charged_party-accountcode-trim_leading_0s');
+      $self->charged_party( $charged_party );
 
     } else {