From: Mark Wells Date: Thu, 10 Oct 2013 16:43:11 +0000 (-0700) Subject: U4 CDR import: place phone numbers in the correct fields, #25308 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=e19de946a48c91ed05a9267b4425ff5dd98da1e5 U4 CDR import: place phone numbers in the correct fields, #25308 --- diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index f3f77236c..b6f3cf3ee 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -3502,6 +3502,10 @@ sub tables_hashref { 'src_ip_addr', 'varchar', 'NULL', 15, '', '', 'dst_ip_addr', 'varchar', 'NULL', 15, '', '', + #currently only u4: + # terminating number (as opposed to dialed destination) + 'dst_term', 'varchar', '', $char_d, \"''", '', + #these don't seem to be logged by most of the SQL cdr_* modules #except tds under sql-illegal names, so; # ... don't rely on them for rating? @@ -3611,7 +3615,7 @@ sub tables_hashref { [ 'sessionnum' ], [ 'subscriber' ], [ 'freesidestatus' ], [ 'freesiderewritestatus' ], [ 'cdrbatch' ], [ 'cdrbatchnum' ], - [ 'src_ip_addr' ], [ 'dst_ip_addr' ], + [ 'src_ip_addr' ], [ 'dst_ip_addr' ], [ 'dst_term' ], ], }, diff --git a/FS/FS/cdr.pm b/FS/FS/cdr.pm index 9d72c39e4..b16cb8648 100644 --- a/FS/FS/cdr.pm +++ b/FS/FS/cdr.pm @@ -92,6 +92,8 @@ following fields are currently supported: =item dst_ip_addr - Destination IP address (same) +=item dst_term - Terminating destination number (if different from dst) + =item startdate - Start of call (UNIX-style integer timestamp) =item answerdate - Answer time of call (UNIX-style integer timestamp) @@ -194,6 +196,7 @@ sub table_info { #'lastdata' => '', 'src_ip_addr' => 'Source IP', 'dst_ip_addr' => 'Dest. IP', + 'dst_term' => 'Termination dest.', 'startdate' => 'Start date', 'answerdate' => 'Answer date', 'enddate' => 'End date', diff --git a/FS/FS/cdr/u4.pm b/FS/FS/cdr/u4.pm index 1b7a660e7..bf5e18225 100644 --- a/FS/FS/cdr/u4.pm +++ b/FS/FS/cdr/u4.pm @@ -6,6 +6,25 @@ use FS::cdr qw(_cdr_date_parser_maker); @ISA = qw(FS::cdr); +# About the ANI/DNIS/*Number columns: +# For inbound calls, ANI appears to be the true source number. +# Usually ANI = TermNumber in that case. (Case 1a.) +# In a few inbound CDRs, ANI = OrigNumber, the BillToNumber is also +# the DialedNumber and DNIS (and always an 800 number), and the TermNumber +# is a different number. (Case 2; rare.) +# +# For outbound calls, DNIS is always empty. The TermNumber appears to +# be the true destination. The DialedNumber may be empty (Case 1b), or +# equal the TermNumber (Case 3), or be a different number (Case 4; this +# probably shows routing to a different destination). +# +# How we are handling them: +# Case 1a (inbound): src = ANI, dst = BillToNumber +# Case 1b (outbound): src = BillToNumber, dst = ANI +# Case 2: src = ANI, dst = DialedNumber, dst_term = TermNumber +# Case 3: src = BillToNumber, dst = DialedNumber +# Case 4: src = BillToNumber, dst = DialedNumber, dst_term = TermNumber + %info = ( 'name' => 'U4', 'weight' => 490, @@ -81,19 +100,37 @@ use FS::cdr qw(_cdr_date_parser_maker); '', #CallIndicator #calltype? '', #ReportIndicator sub { #ANI - # it appears that it's the "other" number, not necessarily ANI. + # For inbound calls, this is the source. + # For outbound calls it's sometimes the destination but TermNumber + # is more reliable. my ($cdr, $number) = @_; - if ( $cdr->direction eq 'O' ) { - $cdr->set('dst', $number); - } elsif ( $cdr->direction eq 'I' ) { + if ( $cdr->direction eq 'I' ) { $cdr->set('src', $number); } }, '', #DNIS '', #PIN '', #OrigNumber - '', #TermNumber - '', #DialedNumber + sub { #TermNumber + # For outbound calls, this is the terminal destination (after call + # routing). It's sometimes also the dialed destination (Case 1b and 3). + my ($cdr, $number) = @_; + if ( $cdr->direction eq 'O' ) { + $cdr->set('dst_term', $number); + $cdr->set('dst', $number); # change this later if Case 4 + } + }, + sub { #DialedNumber + my ($cdr, $number) = @_; + # For outbound calls, this is the destination before any call routing, + # and should be used for billing. Except when it's null; then use + # the TermNumber. + if ( $cdr->direction eq 'O' and $number =~ /\d/ ) { + # Case 4 + $cdr->set('dst', $number); + } + }, + '', #DisplayNumber '', #RecordSource '', #LECInfoDigits @@ -101,4 +138,10 @@ use FS::cdr qw(_cdr_date_parser_maker); ], ); +# Case 1a (inbound): src = ANI, dst = BillToNumber +# Case 1b (outbound): src = BillToNumber, dst = TermNumber +# Case 2: src = ANI, dst = DialedNumber, dst_term = TermNumber +# Case 3: src = BillToNumber, dst = TermNumber +# Case 4: src = BillToNumber, dst = DialedNumber, dst_term = TermNumber + 1;