[freeside-commits] freeside/FS/FS cdr.pm, 1.39, 1.40 Conf.pm, 1.282, 1.283

Ivan,,, ivan at wavetail.420.am
Sat May 9 00:56:40 PDT 2009


Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv25003

Modified Files:
	cdr.pm Conf.pm 
Log Message:
add cdr-charged_party-truncate_{length,prefix} in order to trim charged_party to a certain length, RT#4081

Index: Conf.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Conf.pm,v
retrieving revision 1.282
retrieving revision 1.283
diff -u -d -r1.282 -r1.283
--- Conf.pm	5 May 2009 22:02:28 -0000	1.282
+++ Conf.pm	9 May 2009 07:56:38 -0000	1.283
@@ -2719,9 +2719,23 @@
   },
 
   {
+    'key'         => 'cdr-charged_party-truncate_prefix',
+    'section'     => '',
+    'description' => 'If the charged_party field has this prefix, truncate it to the length in cdr-charged_party-truncate_length.',
+    'type'        => 'text',
+  },
+
+  {
+    'key'         => 'cdr-charged_party-truncate_length',
+    'section'     => '',
+    'description' => 'If the charged_party field has the prefix in cdr-charged_party-truncate_prefix, truncate it to this length.',
+    'type'        => 'text',
+  },
+
+  {
     '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.',
+    '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 or cdr-charged_party-truncate*.',
     'type'        => 'checkbox',
   },
 

Index: cdr.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cdr.pm,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- cdr.pm	7 Apr 2009 20:45:14 -0000	1.39
+++ cdr.pm	9 May 2009 07:56:38 -0000	1.40
@@ -295,9 +295,9 @@
 sub set_charged_party {
   my $self = shift;
 
-  unless ( $self->charged_party ) {
+  my $conf = new FS::Conf;
 
-    my $conf = new FS::Conf;
+  unless ( $self->charged_party ) {
 
     if ( $conf->exists('cdr-charged_party-accountcode') && $self->accountcode ){
 
@@ -315,6 +315,14 @@
 
   }
 
+  my $prefix = $conf->config('cdr-charged_party-truncate_prefix');
+  my $prefix_len = length($prefix);
+  my $trunc_len = $conf->config('cdr-charged_party-truncate_length');
+
+  $self->charged_party( substr($self->charged_party, 0, $trunc_len) )
+    if $prefix_len && $trunc_len
+    && substr($self->charged_party, 0, $prefix_len) eq $prefix;
+
 }
 
 =item set_status_and_rated_price STATUS [ RATED_PRICE ]



More information about the freeside-commits mailing list