summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2009-05-29 23:17:24 +0000
committerivan <ivan>2009-05-29 23:17:24 +0000
commitdeba223d89f516851d24d535d785cc2b39b7784c (patch)
tree55b78240ddfd3039f85f7954eb7d55c646cfabd0
parentea34c834e4d9915a97730113d78b1b43ccd7684d (diff)
fixup pivot code handling in netcentrex CDR handling, RT#4081
-rw-r--r--FS/FS/Conf.pm26
-rw-r--r--FS/FS/cdr.pm14
-rw-r--r--FS/FS/cdr/netcentrex.pm43
3 files changed, 40 insertions, 43 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index b1bc97ab6..cf7e49fe5 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -2736,19 +2736,19 @@ worry that config_items is freeside-specific and icky.
'type' => 'checkbox',
},
- {
- '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-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',
diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm
index 2a235cc41..421fd2bb8 100644
--- a/FS/FS/cdr.pm
+++ b/FS/FS/cdr.pm
@@ -315,13 +315,13 @@ sub set_charged_party {
}
- 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;
+# 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;
}
diff --git a/FS/FS/cdr/netcentrex.pm b/FS/FS/cdr/netcentrex.pm
index 7ccc3df83..0cd5c7b34 100644
--- a/FS/FS/cdr/netcentrex.pm
+++ b/FS/FS/cdr/netcentrex.pm
@@ -29,8 +29,8 @@ use FS::cdr qw(_cdr_date_parser_maker);
_cdr_date_parser_maker('startdate'), #05 Authorize timestamp
_cdr_date_parser_maker('answerdate'), #06 Start timestamp
'billsec', #'duration', #07 Duration
- _e164_parser_maker('src'), #08 Caller
- _e164_parser_maker('dst'), #09 Callee
+ _e164_parser_maker('src', 'charged_party'), #08 Caller
+ _e164_parser_maker('dcontext', 'dst', 'norewrite_pivotonly'=>1) ,#09 Callee
'channel', #10 Source IP
'dstchannel', #11 Destination IP
'userfield', #12 selector Tag
@@ -80,43 +80,40 @@ use FS::cdr qw(_cdr_date_parser_maker);
);
sub _e164_parser_maker {
- my $field = shift;
+ my( $field, $pivot_field, %opt ) = @_;
return sub {
my( $cdr, $e164 ) = @_;
- eval { $cdr->$field( _e164_parse($e164) ); };
- die "error parsing e164 for $field from $e164: $@\n" if $@;
+ my( $pivot, $number ) = _e164_parse($e164);
+ if ( $opt{'norewrite_pivotonly'} && ! $pivot ) {
+ $cdr->$pivot_field( $number );
+ } else {
+ $cdr->$field( $number );
+ $cdr->$pivot_field( $pivot );
+ }
};
}
-my %e164_types = (
- '000000' => '',
- '100005' => '',
- '100009' => '',
- '100012' => '',
- '100014' => '',
- '100015' => '',
- '100016' => '',
- '300000' => '',
-);
-
sub _e164_parse {
my $e164 = shift;
$e164 =~ s/^e164://;
- my ($type, $number);
+ my ($pivot, $number);
if ( $e164 =~ /^O(\d+)$/ ) {
- $type = ''; #?
+ $pivot = ''; #?
$number = $1;
- } elsif ( $e164 =~ /^(\d{6})(\d+)$/ ) {
- $type = $1;
+ } elsif ( $e164 =~ /^000000(\d+)$/ ) {
+ $pivot = '';
+ $number = $1;
+ } elsif ( $e164 =~ /^(1\d{5})(\d+)$/ ) {
+ $pivot = $1;
$number = $2;
} else {
- $type = '';
+ $pivot = '';
$number = $e164; #unparsable...
}
- #$type...?
- $number;
+
+ ( $pivot, $number );
}
1;