quick option to allow importing gmt cdrs
[freeside.git] / FS / FS / cdr / taqua.pm
1 package FS::cdr::taqua;
2
3 use strict;
4 use vars qw(@ISA %info $da_rewrite);
5 use FS::cdr qw(_cdr_date_parser_maker);
6
7 @ISA = qw(FS::cdr);
8
9 %info = (
10   'name'          => 'Taqua',
11   'weight'        => 130,
12   'header'        => 1,
13   'import_fields' => [  #some of these are kind arbitrary...
14
15     #0
16     #RecordType
17     sub {
18       my($cdr, $field, $conf, $hashref) = @_;
19       $hashref->{skiprow} = 1 unless ($field == 0 && $cdr->disposition == 100);
20       $cdr->cdrtypenum($field);
21     },
22
23     sub { my($cdr, $field) = @_; },             #all10#RecordVersion
24     sub { my($cdr, $field) = @_; },       #OrigShelfNumber
25     sub { my($cdr, $field) = @_; },       #OrigCardNumber
26     sub { my($cdr, $field) = @_; },       #OrigCircuit
27     sub { my($cdr, $field) = @_; },       #OrigCircuitType
28     'uniqueid',                           #SequenceNumber
29     'accountcode',                        #SessionNumber
30     'src',                                #CallingPartyNumber
31     #'dst',                                #CalledPartyNumber
32     #CalledPartyNumber
33     sub {
34       my( $cdr, $field, $conf ) = @_;
35       if ( $cdr->calltypenum == 6 && $cdr->cdrtypenum == 0 ) {
36         $cdr->dst("+$field");
37       } else {
38         $cdr->dst($field);
39       }
40     },
41
42     #10
43     _cdr_date_parser_maker('startdate', 'gmt' => 1),  #CallArrivalTime
44     _cdr_date_parser_maker('enddate', 'gmt' => 1),    #CallCompletionTime
45
46     #Disposition
47     #sub { my($cdr, $d ) = @_; $cdr->disposition( $disposition{$d}): },
48     'disposition',
49                                           #  -1 => '',
50                                           #   0 => '',
51                                           # 100 => '',
52                                           # 101 => '',
53                                           # 102 => '',
54                                           # 103 => '',
55                                           # 104 => '',
56                                           # 105 => '',
57                                           # 201 => '',
58                                           # 203 => '',
59
60     _cdr_date_parser_maker('answerdate', 'gmt' => 1), #DispositionTime
61     sub { my($cdr, $field) = @_; },       #TCAP
62     sub { my($cdr, $field) = @_; },       #OutboundCarrierConnectTime
63     sub { my($cdr, $field) = @_; },       #OutboundCarrierDisconnectTime
64
65     #TermTrunkGroup
66     #it appears channels are actually part of trunk groups, but this data
67     #is interesting and we need a source and destination place to put it
68     'dstchannel',                         #TermTrunkGroup
69
70
71     sub { my($cdr, $field) = @_; },       #TermShelfNumber
72     sub { my($cdr, $field) = @_; },       #TermCardNumber
73
74     #20
75     sub { my($cdr, $field) = @_; },       #TermCircuit
76     sub { my($cdr, $field) = @_; },       #TermCircuitType
77     'carrierid',                          #OutboundCarrierId
78
79     #BillingNumber
80     #'charged_party',                      
81     sub {
82       my( $cdr, $field, $conf ) = @_;
83
84       #could be more efficient for the no config case, if anyone ever needs that
85       $da_rewrite ||= $conf->config('cdr-taqua-da_rewrite');
86
87       if ( $da_rewrite && $field =~ /\d/ ) {
88         my $rewrite = $da_rewrite;
89         $rewrite =~ s/\s//g;
90         my @rewrite = split(',', $conf->config('cdr-taqua-da_rewrite') );
91         if ( grep { $field eq $_ } @rewrite ) {
92           $cdr->charged_party( $cdr->src() );
93           $cdr->calltypenum(12);
94           return;
95         }
96       }
97       '';
98     },
99
100     sub { my($cdr, $field) = @_; },       #SubscriberNumber
101     'lastapp',                            #ServiceName
102     sub { my($cdr, $field) = @_; },       #some weirdness #ChargeTime
103     'lastdata',                           #ServiceInformation
104     sub { my($cdr, $field) = @_; },       #FacilityInfo
105     sub { my($cdr, $field) = @_; },             #all 1900-01-01 0#CallTraceTime
106
107     #30
108     sub { my($cdr, $field) = @_; },             #all-1#UniqueIndicator
109     sub { my($cdr, $field) = @_; },             #all-1#PresentationIndicator
110     sub { my($cdr, $field) = @_; },             #empty#Pin
111     'calltypenum',                        #CallType
112
113     #nothing below is used by QIS...
114
115     sub { my($cdr, $field) = @_; },           #Balt/empty #OrigRateCenter
116     sub { my($cdr, $field) = @_; },           #Balt/empty #TermRateCenter
117
118     #OrigTrunkGroup
119     #it appears channels are actually part of trunk groups, but this data
120     #is interesting and we need a source and destination place to put it
121     'channel',                            #OrigTrunkGroup
122
123     'userfield',                                #empty#UserDefined
124     sub { my($cdr, $field) = @_; },             #empty#PseudoDestinationNumber
125     sub { my($cdr, $field) = @_; },             #all-1#PseudoCarrierCode
126
127     #40
128     sub { my($cdr, $field) = @_; },             #empty#PseudoANI
129     sub { my($cdr, $field) = @_; },             #all-1#PseudoFacilityInfo
130     sub { my($cdr, $field) = @_; },       #OrigDialedDigits
131     sub { my($cdr, $field) = @_; },             #all-1#OrigOutboundCarrier
132     sub { my($cdr, $field) = @_; },       #IncomingCarrierID
133     'dcontext',                           #JurisdictionInfo
134     sub { my($cdr, $field) = @_; },       #OrigDestDigits
135     sub { my($cdr, $field) = @_; },       #huh?#InsertTime
136     sub { my($cdr, $field) = @_; },       #key
137     sub { my($cdr, $field) = @_; },             #empty#AMALineNumber
138
139     #50
140     sub { my($cdr, $field) = @_; },             #empty#AMAslpID
141     sub { my($cdr, $field) = @_; },             #empty#AMADigitsDialedWC
142     sub { my($cdr, $field) = @_; },       #OpxOffHook
143     sub { my($cdr, $field) = @_; },       #OpxOnHook
144
145         #acctid - primary key
146   #AUTO #calldate - Call timestamp (SQL timestamp)
147 #clid - Caller*ID with text
148         #XXX src - Caller*ID number / Source number
149         #XXX dst - Destination extension
150         #dcontext - Destination context
151         #channel - Channel used
152         #dstchannel - Destination channel if appropriate
153         #lastapp - Last application if appropriate
154         #lastdata - Last application data
155         #startdate - Start of call (UNIX-style integer timestamp)
156         #answerdate - Answer time of call (UNIX-style integer timestamp)
157         #enddate - End time of call (UNIX-style integer timestamp)
158   #HACK#duration - Total time in system, in seconds
159   #HACK#XXX billsec - Total time call is up, in seconds
160         #disposition - What happened to the call: ANSWERED, NO ANSWER, BUSY
161 #INT amaflags - What flags to use: BILL, IGNORE etc, specified on a per channel basis like accountcode.
162         #accountcode - CDR account number to use: account
163
164         #uniqueid - Unique channel identifier (Unitel/RSLCOM Event ID)
165         #userfield - CDR user-defined field
166
167         #X cdrtypenum - CDR type - see FS::cdr_type (Usage = 1, S&E = 7, OC&C = 8)
168         #XXX charged_party - Service number to be billed
169 #upstream_currency - Wholesale currency from upstream
170 #X upstream_price - Wholesale price from upstream
171 #upstream_rateplanid - Upstream rate plan ID
172 #rated_price - Rated (or re-rated) price
173 #distance - km (need units field?)
174 #islocal - Local - 1, Non Local = 0
175 #calltypenum - Type of call - see FS::cdr_calltype
176 #X description - Description (cdr_type 7&8 only) (used for cust_bill_pkg.itemdesc)
177 #quantity - Number of items (cdr_type 7&8 only)
178 #carrierid - Upstream Carrier ID (see FS::cdr_carrier)
179 #upstream_rateid - Upstream Rate ID
180
181         #svcnum - Link to customer service (see FS::cust_svc)
182         #freesidestatus - NULL, done (or something)
183   ],
184 );
185
186 1;