remove obsolete/customer-specific "set to toll free" processing for accountcode,...
[freeside.git] / FS / FS / cdr / broadsoft.pm
1 package FS::cdr::broadsoft;
2
3 =head1 NAME
4
5 FS::cdr::broadsoft - CDR parse module for Broadsoft
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',
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( $data =~ /^yes/i ? '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     skip(10),
85
86     # 25: networkCallID
87     'sipcallid',
88
89     # 26: codedc
90     # 27: accessDeviceAddress
91     # 28: accessCallID
92     # 29: spare
93     # 30: failoverCorrelationId
94     # 31: spare
95     # 32: group
96     # 33: department
97     skip(8),
98
99     # 34: accountCode
100     'accountcode',
101
102     # 35: authorizationCode
103     # 36: originalCalledNumber
104     # 37: originalCalledPresentationIndicator
105     # 38: originalCalledReason
106     # 39: redirectingNumber
107     # 40: redirectingPresentationIndicator
108     # 41: redirectingReason
109     # 42: chargeIndicator
110     # 43: typeOfNetwork
111     # 44: voicePortalCalling.invocationTime
112     # 45: localCallId
113     # 46: remoteCallId
114     # 47: callingPartyCategory
115     #
116     # Also... cols 48 - 448 see Broadsoft documentation
117     skip(87), #35-121 inclusive
118
119     #122: otherPartyName
120     'clid',
121
122     skip(23), #123-145 inclusive
123
124     # 146: chargedNumber
125     'charged_party',
126
127   ],
128
129 );
130
131 sub trim {
132   my $fieldname = shift;
133   return sub {
134     my($cdr, $data) = @_;
135     $data =~ s/^\+1//;
136     $cdr->$fieldname($data);
137     ''
138   }
139 }
140
141 sub skip {
142   map { undef } (1..$_[0]);
143 }
144
145 1;
146
147 __END__
148
149 list of freeside CDR fields, useful ones marked with *
150
151            acctid - primary key
152     *[1]   calldate - Call timestamp (SQL timestamp)
153            clid - Caller*ID with text
154 7   *      src - Caller*ID number / Source number
155 9   *      dst - Destination extension
156            dcontext - Destination context
157            channel - Channel used
158            dstchannel - Destination channel if appropriate
159            lastapp - Last application if appropriate
160            lastdata - Last application data
161 10  *      startdate - Start of call (UNIX-style integer timestamp)
162 13         answerdate - Answer time of call (UNIX-style integer timestamp)
163 14  *      enddate - End time of call (UNIX-style integer timestamp)
164     *      duration - Total time in system, in seconds
165     *      billsec - Total time call is up, in seconds
166 12  *[2]   disposition - What happened to the call: ANSWERED, NO ANSWER, BUSY
167            amaflags - What flags to use: BILL, IGNORE etc, specified on a per
168            channel basis like accountcode.
169 4   *[3]   accountcode - CDR account number to use: account
170            uniqueid - Unique channel identifier
171            userfield - CDR user-defined field
172            cdr_type - CDR type - see FS::cdr_type (Usage = 1, S&E = 7, OC&C = 8)
173     *[4]   charged_party - Service number to be billed
174            upstream_currency - Wholesale currency from upstream
175     *[5]   upstream_price - Wholesale price from upstream
176            upstream_rateplanid - Upstream rate plan ID
177            rated_price - Rated (or re-rated) price
178            distance - km (need units field?)
179            islocal - Local - 1, Non Local = 0
180     *[6]   calltypenum - Type of call - see FS::cdr_calltype
181            description - Description (cdr_type 7&8 only) (used for
182            cust_bill_pkg.itemdesc)
183            quantity - Number of items (cdr_type 7&8 only)
184            carrierid - Upstream Carrier ID (see FS::cdr_carrier)
185            upstream_rateid - Upstream Rate ID
186            svcnum - Link to customer service (see FS::cust_svc)
187            freesidestatus - NULL, done (or something)
188
189 [1] Auto-populated from startdate if not present
190 [2] Package options available to ignore calls without a specific disposition
191 [3] When using 'cdr-charged_party-accountcode' config
192 [4] Auto-populated from src (normal calls) or dst (toll free calls) if not present
193 [5] When using 'upstream_simple' rating method.
194 [6] Set to usage class classnum when using pre-rated CDRs and usage class-based
195     taxation (local/intrastate/interstate/international)