summaryrefslogtreecommitdiff
path: root/FS/FS/cdr/taqua.pm
blob: 26c0bda62c83cef40417c86e0509e5a9aa28089c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
package FS::cdr::taqua;

use strict;
use vars qw(@ISA %info $da_rewrite);
use FS::cdr qw(_cdr_date_parser_maker);

@ISA = qw(FS::cdr);

%info = (
  'name'          => 'Taqua',
  'weight'        => 130,
  'header'        => 1,
  'import_fields' => [  #some of these are kind arbitrary...

    #0
    #RecordType
    sub {
      my($cdr, $field, $conf, $hashref) = @_;
      $hashref->{skiprow} = 1 unless ($field == 0 && $cdr->disposition == 100);
      $cdr->cdrtypenum($field);
    },

    sub { my($cdr, $field) = @_; },             #all10#RecordVersion
    sub { my($cdr, $field) = @_; },       #OrigShelfNumber
    sub { my($cdr, $field) = @_; },       #OrigCardNumber
    sub { my($cdr, $field) = @_; },       #OrigCircuit
    sub { my($cdr, $field) = @_; },       #OrigCircuitType
    'uniqueid',                           #SequenceNumber
    'accountcode',                        #SessionNumber
    'src',                                #CallingPartyNumber
    #'dst',                                #CalledPartyNumber
    #CalledPartyNumber
    sub {
      my( $cdr, $field, $conf ) = @_;
      if ( $cdr->calltypenum == 6 && $cdr->cdrtypenum == 0 ) {
        $cdr->dst("+$field");
      } else {
        $cdr->dst($field);
      }
    },

    #10
    _cdr_date_parser_maker('startdate', 'gmt' => 1),  #CallArrivalTime
    _cdr_date_parser_maker('enddate', 'gmt' => 1),    #CallCompletionTime

    #Disposition
    #sub { my($cdr, $d ) = @_; $cdr->disposition( $disposition{$d}): },
    'disposition',
                                          #  -1 => '',
                                          #   0 => '',
                                          # 100 => '',
                                          # 101 => '',
                                          # 102 => '',
                                          # 103 => '',
                                          # 104 => '',
                                          # 105 => '',
                                          # 201 => '',
                                          # 203 => '',

    _cdr_date_parser_maker('answerdate', 'gmt' => 1), #DispositionTime
    sub { my($cdr, $field) = @_; },       #TCAP
    sub { my($cdr, $field) = @_; },       #OutboundCarrierConnectTime
    sub { my($cdr, $field) = @_; },       #OutboundCarrierDisconnectTime

    #TermTrunkGroup
    #it appears channels are actually part of trunk groups, but this data
    #is interesting and we need a source and destination place to put it
    'dstchannel',                         #TermTrunkGroup


    sub { my($cdr, $field) = @_; },       #TermShelfNumber
    sub { my($cdr, $field) = @_; },       #TermCardNumber

    #20
    sub { my($cdr, $field) = @_; },       #TermCircuit
    sub { my($cdr, $field) = @_; },       #TermCircuitType
    'carrierid',                          #OutboundCarrierId

    #BillingNumber
    #'charged_party',                      
    sub {
      my( $cdr, $field, $conf ) = @_;

      #could be more efficient for the no config case, if anyone ever needs that
      $da_rewrite ||= $conf->config('cdr-taqua-da_rewrite');

      if ( $da_rewrite && $field =~ /\d/ ) {
        my $rewrite = $da_rewrite;
        $rewrite =~ s/\s//g;
        my @rewrite = split(',', $conf->config('cdr-taqua-da_rewrite') );
        if ( grep { $field eq $_ } @rewrite ) {
          $cdr->charged_party( $cdr->src() );
          $cdr->calltypenum(12);
          return;
        }
      }
      if ( $cdr->is_tollfree ) {        # thankfully this is already available
        $cdr->charged_party($cdr->dst); # and this
      } else {
        $cdr->charged_party($field);
      }
    },

    sub { my($cdr, $field) = @_; },       #SubscriberNumber
    'lastapp',                            #ServiceName
    sub { my($cdr, $field) = @_; },       #some weirdness #ChargeTime
    'lastdata',                           #ServiceInformation
    sub { my($cdr, $field) = @_; },       #FacilityInfo
    sub { my($cdr, $field) = @_; },             #all 1900-01-01 0#CallTraceTime

    #30
    sub { my($cdr, $field) = @_; },             #all-1#UniqueIndicator
    sub { my($cdr, $field) = @_; },             #all-1#PresentationIndicator
    sub { my($cdr, $field) = @_; },             #empty#Pin
    'calltypenum',                        #CallType

    #nothing below is used by QIS...

    sub { my($cdr, $field) = @_; },           #Balt/empty #OrigRateCenter
    sub { my($cdr, $field) = @_; },           #Balt/empty #TermRateCenter

    #OrigTrunkGroup
    #it appears channels are actually part of trunk groups, but this data
    #is interesting and we need a source and destination place to put it
    'channel',                            #OrigTrunkGroup

    'userfield',                                #empty#UserDefined
    sub { my($cdr, $field) = @_; },             #empty#PseudoDestinationNumber
    sub { my($cdr, $field) = @_; },             #all-1#PseudoCarrierCode

    #40
    sub { my($cdr, $field) = @_; },             #empty#PseudoANI
    sub { my($cdr, $field) = @_; },             #all-1#PseudoFacilityInfo
    sub { my($cdr, $field) = @_; },       #OrigDialedDigits
    sub { my($cdr, $field) = @_; },             #all-1#OrigOutboundCarrier
    sub { my($cdr, $field) = @_; },       #IncomingCarrierID
    'dcontext',                           #JurisdictionInfo
    sub { my($cdr, $field) = @_; },       #OrigDestDigits
    sub { my($cdr, $field) = @_; },       #huh?#InsertTime
    sub { my($cdr, $field) = @_; },       #key
    sub { my($cdr, $field) = @_; },             #empty#AMALineNumber

    #50
    sub { my($cdr, $field) = @_; },             #empty#AMAslpID
    sub { my($cdr, $field) = @_; },             #empty#AMADigitsDialedWC
    sub { my($cdr, $field) = @_; },       #OpxOffHook
    sub { my($cdr, $field) = @_; },       #OpxOnHook

        #acctid - primary key
  #AUTO #calldate - Call timestamp (SQL timestamp)
#clid - Caller*ID with text
        #XXX src - Caller*ID number / Source number
        #XXX dst - Destination extension
        #dcontext - Destination context
        #channel - Channel used
        #dstchannel - Destination channel if appropriate
        #lastapp - Last application if appropriate
        #lastdata - Last application data
        #startdate - Start of call (UNIX-style integer timestamp)
        #answerdate - Answer time of call (UNIX-style integer timestamp)
        #enddate - End time of call (UNIX-style integer timestamp)
  #HACK#duration - Total time in system, in seconds
  #HACK#XXX billsec - Total time call is up, in seconds
        #disposition - What happened to the call: ANSWERED, NO ANSWER, BUSY
#INT amaflags - What flags to use: BILL, IGNORE etc, specified on a per channel basis like accountcode.
        #accountcode - CDR account number to use: account

        #uniqueid - Unique channel identifier (Unitel/RSLCOM Event ID)
        #userfield - CDR user-defined field

        #X cdrtypenum - CDR type - see FS::cdr_type (Usage = 1, S&E = 7, OC&C = 8)
        #XXX charged_party - Service number to be billed
#upstream_currency - Wholesale currency from upstream
#X upstream_price - Wholesale price from upstream
#upstream_rateplanid - Upstream rate plan ID
#rated_price - Rated (or re-rated) price
#distance - km (need units field?)
#islocal - Local - 1, Non Local = 0
#calltypenum - Type of call - see FS::cdr_calltype
#X description - Description (cdr_type 7&8 only) (used for cust_bill_pkg.itemdesc)
#quantity - Number of items (cdr_type 7&8 only)
#carrierid - Upstream Carrier ID (see FS::cdr_carrier)
#upstream_rateid - Upstream Rate ID

        #svcnum - Link to customer service (see FS::cust_svc)
        #freesidestatus - NULL, done (or something)
  ],
);

1;