fix TeleAPI import (what kind of crack was Christopher smoking that he couldn't fix...
[freeside.git] / FS / FS / cdr / taqua62.pm
1 package FS::cdr::taqua62;
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.2',
11   'weight'        => 131,
12   'header'        => 1,
13   'import_fields' => [
14
15     #0
16     '', #Key 
17     '', #InsertTime, irrelevant
18     #RecordType
19     sub {
20       my($cdr, $field, $conf, $hashref) = @_;
21       $hashref->{skiprow} = 1
22         unless ($field == 0 && $cdr->disposition == 100       )  #regular CDR
23             || ($field == 1 && $cdr->lastapp     eq 'acctcode')  #accountcode
24             || ($field == 1 && $cdr->lastapp     eq 'CallerId')  #CID blocking
25             ;
26       $cdr->cdrtypenum($field);
27     },
28
29     '',       #RecordVersion
30     '',       #OrigShelfNumber
31     '',       #OrigCardNumber
32     '',       #OrigCircuit
33     '',       #OrigCircuitType
34     'uniqueid',                           #SequenceNumber
35     'sessionnum',                         #SessionNumber
36     #10
37     'src',                                #CallingPartyNumber
38     #CalledPartyNumber
39     sub {
40       my( $cdr, $field, $conf ) = @_;
41       if ( $cdr->calltypenum == 6 && $cdr->cdrtypenum == 0 ) {
42         $cdr->dst("+$field");
43       } else {
44         $cdr->dst($field);
45       }
46     },
47
48     _cdr_date_parser_maker('startdate', 'gmt' => 1),  #CallArrivalTime
49     _cdr_date_parser_maker('enddate', 'gmt' => 1),    #CallCompletionTime
50
51     #Disposition
52     #sub { my($cdr, $d ) = @_; $cdr->disposition( $disposition{$d}): },
53     'disposition',
54                                           #  -1 => '',
55                                           #   0 => '',
56                                           # 100 => '', #regular cdr
57                                           # 101 => '',
58                                           # 102 => '',
59                                           # 103 => '',
60                                           # 104 => '',
61                                           # 105 => '',
62                                           # 201 => '',
63                                           # 203 => '',
64                                           # 204 => '',
65
66     _cdr_date_parser_maker('answerdate', 'gmt' => 1), #DispositionTime
67     '',       #TCAP
68     '',       #OutboundCarrierConnectTime
69     '',       #OutboundCarrierDisconnectTime
70
71     #TermTrunkGroup
72     #it appears channels are actually part of trunk groups, but this data
73     #is interesting and we need a source and destination place to put it
74     'dstchannel',                         #TermTrunkGroup
75
76     #20
77
78     '',       #TermShelfNumber
79     '',       #TermCardNumber
80     '',       #TermCircuit
81     '',       #TermCircuitType
82     'carrierid',                          #OutboundCarrierId
83
84     #BillingNumber
85     #'charged_party',                      
86     sub {
87       my( $cdr, $field, $conf ) = @_;
88
89       #could be more efficient for the no config case, if anyone ever needs that
90       $da_rewrite ||= $conf->config('cdr-taqua-da_rewrite');
91
92       if ( $da_rewrite && $field =~ /\d/ ) {
93         my $rewrite = $da_rewrite;
94         $rewrite =~ s/\s//g;
95         my @rewrite = split(',', $conf->config('cdr-taqua-da_rewrite') );
96         if ( grep { $field eq $_ } @rewrite ) {
97           $cdr->charged_party( $cdr->src() );
98           $cdr->calltypenum(12);
99           return;
100         }
101       }
102       if ( $cdr->is_tollfree ) {        # thankfully this is already available
103         $cdr->charged_party($cdr->dst); # and this
104       } else {
105         $cdr->charged_party($field);
106       }
107     },
108
109     'subscriber',                         #SubscriberName
110     'lastapp',                            #ServiceName
111     '',       #some weirdness #ChargeTime
112     'lastdata',                           #ServiceInformation
113
114     #30
115
116     '',       #FacilityInfo
117     '',             #all 1900-01-01 0#CallTraceTime
118     '',             #all-1#UniqueIndicator
119     '',             #all-1#PresentationIndicator
120     '',             #empty#Pin
121     'calltypenum',                        #CallType
122
123     #nothing below is used by QIS...
124
125     '',           #Balt/empty #OrigRateCenter
126     '',           #Balt/empty #TermRateCenter
127
128     #OrigTrunkGroup
129     #it appears channels are actually part of trunk groups, but this data
130     #is interesting and we need a source and destination place to put it
131     'channel',                            #OrigTrunkGroup
132     'userfield',                                #empty#UserDefined
133
134     #40
135
136     '',             #empty#PseudoDestinationNumber
137     '',             #all-1#PseudoCarrierCode
138     '',             #empty#PseudoANI
139     '',             #all-1#PseudoFacilityInfo
140     '',       #OrigDialedDigits
141     '',             #all-1#OrigOutboundCarrier
142     '',       #IncomingCarrierID
143     'dcontext',                           #JurisdictionInfo
144     '',       #OrigDestDigits
145     '',             #empty#AMALineNumber
146
147     #50
148
149     '',             #empty#AMAslpID
150     '',             #empty#AMADigitsDialedWC
151     '',       #OpxOffHook
152     '',       #OpxOnHook
153     '',       #OrigCalledNumber
154     '',       #RedirectingNumber
155     '',       #RouteAttempts
156     '',       #OrigMGCPTerm
157     '',       #TermMGCPTerm
158     '',       #ReasonCode
159
160     #60
161     
162     '',       #OrigIPCallID
163     '',       #ESAIPTrunkGroup
164     '',       #ESAReason
165     '',       #BearerlessCall
166     '',       #oCodec
167     '',       #tCodec
168     '',       #OrigTrunkGroupNumber
169     '',       #TermTrunkGroupNumber
170     '',       #TermRecord
171     '',       #OrigRoutingIndicator
172
173     #70
174
175     '',       #TermRoutingIndicator
176
177   ],
178 );
179
180 1;