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