[freeside-commits] branch FREESIDE_3_BRANCH updated. be9dbfbbe6e23b5edec6da2d9413b29a15da82b3

Mark Wells mark at 420.am
Thu Oct 10 09:46:09 PDT 2013


The branch, FREESIDE_3_BRANCH has been updated
       via  be9dbfbbe6e23b5edec6da2d9413b29a15da82b3 (commit)
      from  368a5e5e75b2072003641c1938fcb1423a9fb30c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit be9dbfbbe6e23b5edec6da2d9413b29a15da82b3
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Oct 10 09:44:00 2013 -0700

    U4 CDR import: place phone numbers in the correct fields, #25308

diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index bf4723e..0c1e063 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -3406,6 +3406,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?
@@ -3515,7 +3519,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 9d72c39..b16cb86 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 1b7a660..bf5e182 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;

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Schema.pm |    6 +++++-
 FS/FS/cdr.pm    |    3 +++
 FS/FS/cdr/u4.pm |   55 +++++++++++++++++++++++++++++++++++++++++++++++++------
 3 files changed, 57 insertions(+), 7 deletions(-)




More information about the freeside-commits mailing list