[freeside-commits] branch FREESIDE_4_BRANCH updated. 986af8a754929c55d9eabbd5493ec3c24420d06d

Christopher Burger burgerc at 420.am
Fri May 12 08:25:54 PDT 2017


The branch, FREESIDE_4_BRANCH has been updated
       via  986af8a754929c55d9eabbd5493ec3c24420d06d (commit)
      from  16df515e0e4b9a4ee977e58f1f4a1520a770e536 (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 986af8a754929c55d9eabbd5493ec3c24420d06d
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Fri May 5 12:56:12 2017 -0400

    RT# 74523 Added fusionpbx import script, updated Import.pm to handle different import scripts. updated ivr_import to use new Import.pm

diff --git a/FS/FS/cdr/Import.pm b/FS/FS/cdr/Import.pm
index 39a7772..5046caf 100644
--- a/FS/FS/cdr/Import.pm
+++ b/FS/FS/cdr/Import.pm
@@ -22,10 +22,12 @@ FS::cdr::Import - CDR importing
     'dbd'         => 'mysql', #Pg, Sybase, etc.
     'table'       => 'TABLE_NAME',
     'primary_key' => 'BILLING_ID',
+    'status_table' = > 'STATUS_TABLE_NAME', # if using a table rather than field in main table
     'column_map'  => { #freeside => remote_db
       'freeside_column' => 'remote_db_column',
       'freeside_column' => sub { my $row = shift; $row->{remote_db_column}; },
     },
+    'batch_name' => 'batch_name', # cdr_batch name -import-date gets appended.
   );
 
 =head1 DESCRIPTION
@@ -48,9 +50,16 @@ sub dbi_import {
 
   $opt{D} ||= $args{database};
 
+  #do we want to add more types? or add as we go?
+  my %dbi_connect_types = {
+    'Sybase'  => ':server',
+    'Pg'      => ':host',
+  };
+
   my $dsn = 'dbi:'. $args{dbd};
-  #$dsn .= ":host=$opt{H}"; #if $opt{H};
-  $dsn .= ":server=$opt{H}"; #if $opt{H};
+
+  my $dbi_connect_type = $dbi_connect_types{$args{'dbd'}} ? $dbi_connect_types{$args{'dbd'}} : ':host';
+  $dsn .= $dbi_connect_type . "=$opt{H}";
   $dsn .= ";database=$opt{D}" if $opt{D};
 
   my $dbi = DBI->connect($dsn, $opt{U}, $opt{P}) 
@@ -93,7 +102,7 @@ sub dbi_import {
   #MySQL-specific print "Importing ".$sth->rows." records...\n";
 
   my $cdr_batch = new FS::cdr_batch({ 
-      'cdrbatch' => 'IVR-import-'. time2str('%Y/%m/%d-%T',time),
+      'cdrbatch' => $args{batch_name} . '-import-'. time2str('%Y/%m/%d-%T',time),
     });
   my $error = $cdr_batch->insert;
   die $error if $error;
diff --git a/bin/cdr-ivr.import b/bin/cdr-fusionpbx.import
similarity index 66%
copy from bin/cdr-ivr.import
copy to bin/cdr-fusionpbx.import
index 9285b3b..7bac699 100755
--- a/bin/cdr-ivr.import
+++ b/bin/cdr-fusionpbx.import
@@ -5,22 +5,22 @@ use Date::Parse 'str2time';
 use FS::cdr::Import;
 
 FS::cdr::Import->dbi_import(
-  'dbd'          => 'Sybase',
-  'database'     => 'TEL_DATA',
-  'table'        => 'BILLING',
-  'primary_key'  => 'BILLING_ID',
-  'status_table' => 'FREESIDE_BILLING',
-  'column_map'   => { #freeside => IVR
-    'cdrid'             => 'BILLING_ID', #Primary key
+  'dbd'          => 'Pg',
+  'database'     => 'fusionpbx',
+  'table'        => 'v_xml_cdr',
+  'primary_key'  => 'uuid',
+  'status_table' => 'freeside_billing',
+  'column_map'   => { #freeside => fusionpbx
+    #'cdrid'             => 'uuid', #Primary key
     #'' => 'CALL_SESSION_ID', # Call Session Id (unique per call session – GUID)
-    'uniqueid'          => 'CALL_ID', #
+    'uniqueid'          => 'uuid', #
     #'' => 'ENTRY_TYPE', #
-    'accountcode'       => 'ACCOUNT_ID', #
+    'accountcode'       => 'accountcode', #
     #'' => 'ACCOUNT', #
     #'' => 'ACCOUNT_GROUP', #
-    'startdate'         => sub { str2time(shift->{'START_DATE_TIME'}); },
-    'answerdate'        => sub { str2time(shift->{'CONNECT_DATE_TIME'}); },
-    'enddate'           => sub { str2time(shift->{'DISCONNECT_DATE_TIME'}); },
+    'startdate'         => sub { str2time(shift->{'start_stamp'}); },
+    'answerdate'        => sub { str2time(shift->{'answer_stamp'}); },
+    'enddate'           => sub { str2time(shift->{'end_stamp'}); },
     #'' => 'PARENT_ACCOUNT_ID', #
     #'' => 'PARENT_ACCOUNT', #
     #'' => 'LOGIN_NAME', #
@@ -32,26 +32,26 @@ FS::cdr::Import->dbi_import(
     #'dst'               => sub { $_[0]->{COUNTRY_CODE}. $_[0]->{NPA}.
     #                             $_[0]->{NXX}. $_[0]->{LOCAL_NUMBER};
     #                           },
-    'description'       => 'DESCRIPTION', # or upstream_dst_regionname ?
+    #'description'       => 'DESCRIPTION', # or upstream_dst_regionname ?
     #'' => 'PER_CALL_CHARGE', #
     #'' => 'PER_MINUTE_CHARGE', #
     #'' => 'PER_CALL_SURCHARGE', #
     #'' => 'PER_MINUTE_SURCHARGE', #
-    'duration'          => 'ACTUAL_DURATION', #
-    'billsec'           => sub { int( shift->{'QUANTITY'} * 60 + .49 ); }, #
-    'upstream_price'    => 'AMOUNT', #
+    'duration'          => 'duration', #
+    'billsec'           => sub { int( shift->{'billsec'} * 60 + .49 ); }, #
+    #'upstream_price'    => 'AMOUNT', #
     #'' => 'PACKAGED_BALANCE_INDEX', #
-    'upstream_currency' => 'CURRENCY', #
+    #'upstream_currency' => 'CURRENCY', #
     #'' => 'CONVERSION_RATE', #
-    'lastapp'           => 'MODULE_NAME', #
-    'src'               => 'ANI', # 'clid' => 'ANI', #
+    'lastapp'           => 'last_app', #
+    #'src'               => 'ANI', # 'clid' => 'ANI', #
     'dst'               => sub { $_[0]->{'COUNTRY_CODE'} !~ /^1/
                                    ? "011". $_[0]->{'DETAIL'}
                                    : $_[0]->{'DETAIL'};
                                },
     #'' => 'SALES_GROUP', #
     #'' => 'TAX_GROUP', #
-    'userfield'         => 'USER_1', #
+    #'userfield'         => 'USER_1', #
     #'' => 'USER_2', #
     #'' => 'USER_3', #
     #'' => 'USER_4', #
@@ -68,6 +68,7 @@ FS::cdr::Import->dbi_import(
     #'' => 'GRACE_PERIOD', # SMALLINT Grace period associated with the call
     #'' => 'ACCOUNT_TYPE', # Account type from ACCOUNT_TYPES table
   },
+  'batch_name' => 'fusionpbx',
 );
 
-1;
+1;
\ No newline at end of file
diff --git a/bin/cdr-ivr.import b/bin/cdr-ivr.import
index 9285b3b..212482d 100755
--- a/bin/cdr-ivr.import
+++ b/bin/cdr-ivr.import
@@ -68,6 +68,7 @@ FS::cdr::Import->dbi_import(
     #'' => 'GRACE_PERIOD', # SMALLINT Grace period associated with the call
     #'' => 'ACCOUNT_TYPE', # Account type from ACCOUNT_TYPES table
   },
+  'batch_name' => 'IVR',
 );
 
 1;

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

Summary of changes:
 FS/FS/cdr/Import.pm                          |   15 +++++++--
 bin/{cdr-ivr.import => cdr-fusionpbx.import} |   43 +++++++++++++-------------
 bin/cdr-ivr.import                           |    1 +
 3 files changed, 35 insertions(+), 24 deletions(-)
 copy bin/{cdr-ivr.import => cdr-fusionpbx.import} (66%)




More information about the freeside-commits mailing list