import torrus 1.0.9
[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       if ( $cdr->is_tollfree ) {        # thankfully this is already available
98         $cdr->charged_party($cdr->dst); # and this
99       } else {
100         $cdr->charged_party($field);
101       }
102     },
103
104     sub { my($cdr, $field) = @_; },       #SubscriberNumber
105     'lastapp',                            #ServiceName
106     sub { my($cdr, $field) = @_; },       #some weirdness #ChargeTime
107     'lastdata',                           #ServiceInformation
108     sub { my($cdr, $field) = @_; },       #FacilityInfo
109     sub { my($cdr, $field) = @_; },             #all 1900-01-01 0#CallTraceTime
110
111     #30
112     sub { my($cdr, $field) = @_; },             #all-1#UniqueIndicator
113     sub { my($cdr, $field) = @_; },             #all-1#PresentationIndicator
114     sub { my($cdr, $field) = @_; },             #empty#Pin
115     'calltypenum',                        #CallType
116
117     #nothing below is used by QIS...
118
119     sub { my($cdr, $field) = @_; },           #Balt/empty #OrigRateCenter
120     sub { my($cdr, $field) = @_; },           #Balt/empty #TermRateCenter
121
122     #OrigTrunkGroup
123     #it appears channels are actually part of trunk groups, but this data
124     #is interesting and we need a source and destination place to put it
125     'channel',                            #OrigTrunkGroup
126
127     'userfield',                                #empty#UserDefined
128     sub { my($cdr, $field) = @_; },             #empty#PseudoDestinationNumber
129     sub { my($cdr, $field) = @_; },             #all-1#PseudoCarrierCode
130
131     #40
132     sub { my($cdr, $field) = @_; },             #empty#PseudoANI
133     sub { my($cdr, $field) = @_; },             #all-1#PseudoFacilityInfo
134     sub { my($cdr, $field) = @_; },       #OrigDialedDigits
135     sub { my($cdr, $field) = @_; },             #all-1#OrigOutboundCarrier
136     sub { my($cdr, $field) = @_; },       #IncomingCarrierID
137     'dcontext',                           #JurisdictionInfo
138     sub { my($cdr, $field) = @_; },       #OrigDestDigits
139     sub { my($cdr, $field) = @_; },       #huh?#InsertTime
140     sub { my($cdr, $field) = @_; },       #key
141     sub { my($cdr, $field) = @_; },             #empty#AMALineNumber
142
143     #50
144     sub { my($cdr, $field) = @_; },             #empty#AMAslpID
145     sub { my($cdr, $field) = @_; },             #empty#AMADigitsDialedWC
146     sub { my($cdr, $field) = @_; },       #OpxOffHook
147     sub { my($cdr, $field) = @_; },       #OpxOnHook
148
149         #acctid - primary key
150   #AUTO #calldate - Call timestamp (SQL timestamp)
151 #clid - Caller*ID with text
152         #XXX src - Caller*ID number / Source number
153         #XXX dst - Destination extension
154         #dcontext - Destination context
155         #channel - Channel used
156         #dstchannel - Destination channel if appropriate
157         #lastapp - Last application if appropriate
158         #lastdata - Last application data
159         #startdate - Start of call (UNIX-style integer timestamp)
160         #answerdate - Answer time of call (UNIX-style integer timestamp)
161         #enddate - End time of call (UNIX-style integer timestamp)
162   #HACK#duration - Total time in system, in seconds
163   #HACK#XXX billsec - Total time call is up, in seconds
164         #disposition - What happened to the call: ANSWERED, NO ANSWER, BUSY
165 #INT amaflags - What flags to use: BILL, IGNORE etc, specified on a per channel basis like accountcode.
166         #accountcode - CDR account number to use: account
167
168         #uniqueid - Unique channel identifier (Unitel/RSLCOM Event ID)
169         #userfield - CDR user-defined field
170
171         #X cdrtypenum - CDR type - see FS::cdr_type (Usage = 1, S&E = 7, OC&C = 8)
172         #XXX charged_party - Service number to be billed
173 #upstream_currency - Wholesale currency from upstream
174 #X upstream_price - Wholesale price from upstream
175 #upstream_rateplanid - Upstream rate plan ID
176 #rated_price - Rated (or re-rated) price
177 #distance - km (need units field?)
178 #islocal - Local - 1, Non Local = 0
179 #calltypenum - Type of call - see FS::cdr_calltype
180 #X description - Description (cdr_type 7&8 only) (used for cust_bill_pkg.itemdesc)
181 #quantity - Number of items (cdr_type 7&8 only)
182 #carrierid - Upstream Carrier ID (see FS::cdr_carrier)
183 #upstream_rateid - Upstream Rate ID
184
185         #svcnum - Link to customer service (see FS::cust_svc)
186         #freesidestatus - NULL, done (or something)
187   ],
188 );
189
190 1;