RT# 82992 - added documentation to thinq cdr import
[freeside.git] / FS / FS / cdr / thinq.pm
1 package FS::cdr::thinq;
2
3 use strict;
4 use vars qw( @ISA %info $tmp_mon $tmp_mday $tmp_year );
5 use base qw( FS::cdr );
6 use Time::Local;
7 use Date::Parse;
8
9 @ISA = qw(FS::cdr);
10
11 %info = (
12   'name'          => 'ThinQ',
13   'weight'        => 13,
14   'type'          => 'csv',
15   'header'        => 1,
16   'disabled'      => 0,     #0 default, set to 1 to disable
17
18
19   'import_fields' => [
20
21     # Date (YYYY-MM-DD)
22     sub { my($cdr, $date) = @_;
23           $date =~ /^(\d\d(\d\d)?)\-(\d{1,2})\-(\d{1,2})$/
24             or die "unparsable date: $date"; #maybe we shouldn't die...
25           ($tmp_mday, $tmp_mon, $tmp_year) = ( $4, $3-1, $1 );
26         },
27
28     # Time (HH:MM:SS )
29     sub { my($cdr, $time) = @_;
30           $time =~ /^(\d{1,2}):(\d{1,2}):(\d{1,2})$/
31             or die "unparsable time: $time"; #maybe we shouldn't die...
32           $cdr->startdate(
33             timelocal($3, $2, $1 ,$tmp_mday, $tmp_mon, $tmp_year)
34           );
35         },
36
37     'carrierid',         # carrier_id
38     'src',               # from_ani
39      skip(5),            # from_lrn
40                                      # from_lata
41                                      # from_ocn
42                                      # from_state
43                                      # from_rc
44     'dst',               # to_did
45     'channel',           # thing_tier
46     'userfield',         # callid
47     'accountcode',       # account_id
48      skip(2),            # tf_profile
49                                      # dest_type
50     'dst_ip_addr',       # dest
51      skip(1),              # rate
52     'billsec',           # billsec
53      skip(1),              #total_charge
54   ],  ## end import
55
56 );      ## end info
57
58 sub skip { map { undef } (1..$_[0]) }
59
60 1;
61
62 =head1 NAME
63
64 FS::cdr::thinq - ThinQ cdr import.
65
66 =head1 DESCRIPTION
67
68 https://support.thinq.com/hc/en-us/articles/229251907-Defining-the-CDR-for-LCR
69
70 https://support.thinq.com/hc/en-us/articles/229251987-Defining-the-CDR-for-Origination
71
72 File format is csv, fields below.
73
74 01  date         - YYYY-MM-DD  2019-03-04
75 02  time         - HH:MM:SS  19:40:31
76 03  carrier_id   - thinq id number for each carrier  4
77 04  from_ani     - number dialed from  14055343879
78 05  from_lrn     - 10 digit number to identify CO switch port  14056269999
79 06  from_lata    - originating LATA  536
80 07  from_ocn     - operating company number assigned by NECA  6534
81 08  from_state   - originating state (US)  OK
82 09  from_rc      - originating rate center  "OKLA CITY"
83 10  to_did       - called number  17312018150
84 11  thinq_tier   - tier of thinq provider (1,2,3)  1
85 12  callid       - unique idenitifer for a call  960773443_66972652@206.147.84.26
86 13  account_id   - thinq account identifier  13840
87 14  tf_profile   - TFLCR profile used for inbound TF traffic  <null>
88 15  dest_type    - IP, PSN, ?  IP
89 16  dest         - pbx IP address for IP routed calls  192.151.131.17
90 17  rate         - charge per minute  0.00250000
91 18  billsec      - billable seconds  6
92 19  total_charge - charge for this call  0.00025000
93
94 ThinQ cdr field definitions
95
96 01  from_ani     - The number dialed from
97 02  to_did       - The number dialed to
98 03  lrn          - 10-digit number that identifies a switch port for a central office
99 04  prefix_match - extension number to rate international calls
100 05  country      - country call was terminated to
101 06  callid       - The unique idenitifer for a call
102 07  time         - time when the call was placed in GMT/UTC format
103 08  account_id   - Your account Identifier
104 09  Profile_id   - The profile identifier the call was sent though
105 10  src_ip       - The source IP address
106 11  carrier_id   - Our ID number for each carrier
107 12  rate         - The current rate of charge per minute
108 13  total        - total price of the call
109 14  from_state   - orginating state from USA
110 15  to_state     - terminationg state of the USA
111 16  rc           - Rate Center = geographical area used by a Local Exchange Carrier (LEC) to determine the boundaries
112                    for local calling, billing and assigning phone numbers
113 17  from_rc      - originating rc
114 18  to_rc        - terminating rc
115 19  lata         - area that is covered by local exchange carriers (LECs)
116 20  from_lata    - originating lata
117 21  to_lata      - terminating lata
118 22  ocn          - Operating Company Number is a 4 character ID for North American phone companies assigned by NECA and used to identify companies
119 23  from_ocn     - originating ocn
120 24  to_ocn       - terminating ocn
121 25  bill_sec     - billable seconds
122 26  jurisdiction - how we rate the call for International, Intrastate, Interstate
123
124 =cut