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