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