backup the schema for tables we don't need the data from. RT#85959
[freeside.git] / FS / FS / cdr / broadsoft22.pm
1 package FS::cdr::broadsoft22;
2
3 =head1 NAME
4
5 FS::cdr::broadsoft22 - CDR parse module for Broadsoft R22.0
6
7 =head1 DESCRIPTION
8
9 Ref: BW-AccountingCDRInterfaceSpec-R22.pdf
10
11 =cut
12
13 use strict;
14 use base qw( FS::cdr );
15 use vars qw( %info );
16 use FS::cdr qw( _cdr_date_parser_maker _cdr_min_parser_maker );
17
18 %info = (
19   name     => 'Broadsoft R22',
20   weight   => 500,
21   header   => 1,
22   type     => 'csv',
23   sep_char => ',',
24   disabled => 0,
25
26   import_fields => [
27
28     # 1: recordId
29     # 2: serviceProvider
30     skip(2),
31
32     # 3: type
33     sub {
34       my ( $cdr, $data, $conf, $param ) = @_;
35       $param->{skiprow} = 1
36         if lc($data) ne 'normal';
37       '';
38     },
39
40     # 4: userNumber
41     # 5: groupNumber
42     skip(2),
43
44     # 6: direction
45     'dcontext',
46
47     # 7: callingNumber
48     trim('src'),
49
50     # 8: callingPresentationINdicator
51     skip(1),
52
53     # 9: calledNumber
54     trim('dst'),
55
56     # 10: startTime
57     _cdr_date_parser_maker('startdate'),
58
59     # 11: userTimeZone
60     skip(1),
61
62     # 12: answerIndicator
63     sub {
64       my( $cdr, $data ) = @_;
65       $cdr->disposition( lc($data) eq 'yes' ? 'ANSWERED' : 'NO ANSWER');
66     },
67
68     # 13: answerTime
69     _cdr_date_parser_maker('answerdate'),
70
71     # 14: releaseTime
72     _cdr_date_parser_maker('enddate'),
73
74     # 15: terminationCause
75     # 16: networkType
76     # 17: carrierIdentificationCode
77     # 18: dialedDigits
78     # 19: callCategory
79     # 20: networkCallType
80     # 21: networkTranslatedNumber
81     # 22: networkTranslatedGroup
82     # 23: releasingParty
83     # 24: route
84     # 25: networkCallID
85     # 26: codedc
86     # 27: accessDeviceAddress
87     # 28: accessCallID
88     # 29: spare
89     # 30: failoverCorrelationId
90     # 31: spare
91     # 32: group
92     # 33: department
93     skip(19),
94
95     # 34: accountCode
96     sub {
97       my( $cdr, $data ) = @_;
98       $cdr->set(
99         'accountcode',
100         $cdr->is_tollfree ? substr( $cdr->dst, 0, 32 ) : $data
101       );
102     },
103
104     # 35: authorizationCode
105     # 36: originalCalledNumber
106     # 37: originalCalledPresentationIndicator
107     # 38: originalCalledReason
108     # 39: redirectingNumber
109     # 40: redirectingPresentationIndicator
110     # 41: redirectingReason
111     # 42: chargeIndicator
112     # 43: typeOfNetwork
113     # 44: voicePortalCalling.invocationTime
114     # 45: localCallId
115     # 46: remoteCallId
116     # 47: callingPartyCategory
117     #
118     # Also... cols 48 - 448 see Broadsoft documentation
119
120   ],
121
122 );
123
124 sub trim {
125   my $fieldname = shift;
126   return sub {
127     my($cdr, $data) = @_;
128     $data =~ s/^\+1//;
129     $cdr->$fieldname($data);
130     ''
131   }
132 }
133
134 sub skip {
135   map { undef } (1..$_[0]);
136 }
137
138 1;
139
140 __END__
141
142 list of freeside CDR fields, useful ones marked with *
143
144            acctid - primary key
145     *[1]   calldate - Call timestamp (SQL timestamp)
146            clid - Caller*ID with text
147 7   *      src - Caller*ID number / Source number
148 9   *      dst - Destination extension
149            dcontext - Destination context
150            channel - Channel used
151            dstchannel - Destination channel if appropriate
152            lastapp - Last application if appropriate
153            lastdata - Last application data
154 10  *      startdate - Start of call (UNIX-style integer timestamp)
155 13         answerdate - Answer time of call (UNIX-style integer timestamp)
156 14  *      enddate - End time of call (UNIX-style integer timestamp)
157     *      duration - Total time in system, in seconds
158     *      billsec - Total time call is up, in seconds
159 12  *[2]   disposition - What happened to the call: ANSWERED, NO ANSWER, BUSY
160            amaflags - What flags to use: BILL, IGNORE etc, specified on a per
161            channel basis like accountcode.
162 4   *[3]   accountcode - CDR account number to use: account
163            uniqueid - Unique channel identifier
164            userfield - CDR user-defined field
165            cdr_type - CDR type - see FS::cdr_type (Usage = 1, S&E = 7, OC&C = 8)
166     *[4]   charged_party - Service number to be billed
167            upstream_currency - Wholesale currency from upstream
168     *[5]   upstream_price - Wholesale price from upstream
169            upstream_rateplanid - Upstream rate plan ID
170            rated_price - Rated (or re-rated) price
171            distance - km (need units field?)
172            islocal - Local - 1, Non Local = 0
173     *[6]   calltypenum - Type of call - see FS::cdr_calltype
174            description - Description (cdr_type 7&8 only) (used for
175            cust_bill_pkg.itemdesc)
176            quantity - Number of items (cdr_type 7&8 only)
177            carrierid - Upstream Carrier ID (see FS::cdr_carrier)
178            upstream_rateid - Upstream Rate ID
179            svcnum - Link to customer service (see FS::cust_svc)
180            freesidestatus - NULL, done (or something)
181
182 [1] Auto-populated from startdate if not present
183 [2] Package options available to ignore calls without a specific disposition
184 [3] When using 'cdr-charged_party-accountcode' config
185 [4] Auto-populated from src (normal calls) or dst (toll free calls) if not present
186 [5] When using 'upstream_simple' rating method.
187 [6] Set to usage class classnum when using pre-rated CDRs and usage class-based
188     taxation (local/intrastate/interstate/international)