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