backup the schema for tables we don't need the data from. RT#85959
[freeside.git] / FS / FS / cdr / emi.pm
1 package FS::cdr::emi;
2 use base qw( FS::cdr );
3
4 use strict;
5 use vars qw( %info );
6 use Time::Local;
7 #use FS::cdr qw( _cdr_date_parser_maker _cdr_min_parser_maker );
8
9 %info = (
10   'name'               => 'EMI (Exchange Message Interface)',
11   'weight'             => 60,
12   'type'               => 'fixedlength',
13   'fixedlength_format' => [qw(
14     record_identification:6:1:6
15     record_date:6:7:12
16     calling_number_length:2:13:14
17     calling_number:10:15:24
18     overflow_digits:3:25:27
19     called_number_length:2:28:29
20     called_number:10:30:39
21     amount_collected:7:40:46
22
23     UNKNOWN_1:8:47:54
24
25     connect_time:6:55:60
26     conversation_time:7:61:67
27     method_of_recording:2:68:69
28
29     UNKNOWN_1A:9:70:78
30
31     rate_class:1:79:79
32     message_type:1:80:80
33
34     UNKNOWN_2:1:81:81
35
36     indicator_1:1:82:82
37     indicator_2:1:83:83
38     indicator_3:1:84:84
39     indicator_4:1:85:85
40     indicator_5:1:86:86
41     indicator_6:1:87:87
42     indicator_7:1:88:88
43     indicator_8:1:89:89
44     indicator_9:1:90:90
45     indicator_10:1:91:91
46     indicator_11:1:92:92
47     indicator_12:1:93:93
48     indicator_13:1:94:94
49     indicator_14:1:95:95
50     indicator_15:1:96:96
51     indicator_16:1:97:97
52     indicator_17:1:98:98
53     indicator_18:1:99:99
54     indicator_19:1:100:100
55
56     UNKNOWN_3:12:101:112
57
58     billing_number:10:113:122
59     calling_city:10:123:132
60     calling_state:2:133:134
61     called_city:10:135:144
62     called_state:2:145:146
63
64     UNKNOWN_4:2:147:148
65
66     settlement_code:1:149:149
67
68     UNKNOWN_5:11:150:160
69
70     ind24:1:161:161
71
72     UNKNOWN_6:49:162:210
73
74     calling_module:4:211:214
75     module_value_length:3:215:217
76     cai:1:218:218
77     account_code:10:219:228
78
79     UNKNOWN_7:30:229:258
80
81     tmod:4:259:262
82
83   )],
84   'import_fields'      => [
85
86     sub { # record_identification
87       my($cdr, $data, $conf, $param) = @_;
88       $cdr->{_record_identification} = $data;
89       if ( $data eq '202401' || $data eq '202402' ) { #header/footer
90         $param->{skiprow} = 1;
91       }
92     },
93
94    # _cdr_date_parser_maker('startdate'),  # record_date
95    sub { #record_date
96      my($cdr, $data, $conf, $param) = @_;
97      $data =~ /^(\d\d)(\d\d)(\d\d)$/ or die "unparsable record_date: $data";
98      $cdr->{_tmp_year} = "20$1";
99      $cdr->{_tmp_mon} = $2;
100      $cdr->{_tmp_mday} = $3;
101    },
102
103     '', #calling_number_length
104
105     'src', #calling_number
106
107     '', #XXX
108     #sub { #overflow_digits... add to dst???
109     #  my($cdr, $data, $conf, $param) = @_;
110     #  if ( $cdr->{_record_identification} eq '010201' ) {
111     #    $cdr->dst( $cdr->dst . $data
112     #  }
113     #}
114
115     '', #called_number_length
116
117     'dst', #called_number
118
119     sub { #amount_collected
120       my($cdr, $data, $conf, $param) = @_;
121
122       $cdr->upstream_price( $data / 1000 );
123     },
124
125     '', #UNKNOWN_1
126
127     sub { #connect_time
128       my($cdr, $data, $conf, $param) = @_;
129
130      $data =~ /^(\d\d)(\d\d)(\d\d)$/ or die "unparsable connect_time: $data";
131      $cdr->startdate( timelocal(
132                         $3, $2, $1,
133                         $cdr->{_tmp_mday}, $cdr->{_tmp_mon}-1, $cdr->{_tmp_year}
134                       )
135                     );
136     },
137
138     sub { #conversation_time
139       my($cdr, $data, $conf, $param) = @_;
140
141        $data =~ /^(\d{6})(\d)$/ or die "unparsable connect_time: $data";
142
143        my $time = $1;
144        $time++ if $2 >= 5; #round up if tenths > .5
145
146        $cdr->duration($time);
147        $cdr->billsec($time);
148     
149     },
150
151     '', #method_of_recording
152
153     '', #UNKNOWN_1A
154
155     'upstream_rateplanid', #rate_class
156
157     '', #message_type
158 #A one-position numeric field that identifies the billing arrangement applicable to the transaction, e.g., sent-paid or collect. Values are as follows: 
159 #1 = Sent Paid 
160 #2 = Third Number 
161 #3 = Calling Card 
162 #4 = Collect 
163 #5 = Special Collect/Reverse Billing 
164 #6 = Coin Paid 
165 #7 = Unassigned 
166 #8 = Unassigned 
167 #9 = Unassigned
168
169     '', #UNKNOWN_2
170
171     '', #indicator_1
172 #Indicator 1 - Coin/Hotel - Motel - Hospital - University Dorm Room - OUTWATS Out Of Band 
173 #Value
174 #Indicates
175 #Definition 
176 #1 
177 #Telephone Company Owned Public Telephone Originated 
178 #Message originated at a telephone company-owned public telephone station. Included are PUBLIC, SEMIPUBLIC, CHARGE-A-CALL, and INMATE CALLS. 
179 #2 
180 #Coin Over Collection 
181 #Indicates that the AMOUNT COLLECTED exceeds the COIN TARIFF AMOUNT, plus the COIN FEDERAL TAX, plus the STATE TAX (if applicable) plus LOCAL TAX (if applicable) on a COIN PAID MESSAGE. On a OSS COIN MEMO, the value in the AMOUNT COLLECTED field represents the excess collected over the amount due 
182 #3 
183 #Coin Undercollection 
184 #Indicates that the AMOUNT COLLECTED is less than the COIN TARIFF AMOUNT, plus COIN FEDERAL TAX, plus STATE TAX (if applicable), plus LOCAL TAX (if applicable) on a COIN PAID MESSAGE. On a OSS Coin Memo, the value and the AMOUNT COLLECTED field represents the difference between the amount collected and the amount due. 
185 #4 
186 #Hotel-Motel-Hospital- University Dorm Room Originated 
187 #The Message originated at an extension in a hotel, motel, hospital, or university dorm room 
188 #5 
189 #OUTWATS Out of Band 
190 #Message originated at an OUTWATS line and terminated at an out-of-band point. 
191 #6 
192 #Non-Hotel-Auto/Voice Quote 
193 #OSS message originated at a non-hotel business subscribing to automated Voice Charge Quotation Service 
194 #7 
195 #IC Carrier Owned Public Telephone Originated 
196 #Message originated at an IC Carrier owned public telephone station 
197 #8* 
198 #Customer Owned Public Telephone Originated 
199 #Message originated at a customer owned public telephone station. 
200
201     '', #indicator_2
202     '', #indicator_3
203     '', #indicator_4
204     '', #indicator_5
205     '', #indicator_6
206     '', #indicator_7
207     '', #indicator_8
208     '', #indicator_9
209
210     '', #indicator_10
211 #Indicator 10 – Radio Services or IP Services Terminated
212 #Value
213 #Indicates
214 #Definition
215 #1
216 #Mobile Non-Roamer Terminated
217 #Indicates that the transaction terminated at a Mobile Non-Roamer.
218 #2
219 #Mobile Roamer Terminated
220 #Indicates that the transaction terminated at a Mobile Roamer.
221 #3
222 #Aircraft Terminated
223 #Indicates that the transaction terminated through Air/Ground facilities.
224 #4
225 #High Speed Train Terminated
226 #Indicates that the transaction terminated aboard a High Speed Train.
227 #5
228 #Marine Terminated
229 #Indicates that the transaction terminated through Coastal Harbor, VHF, marine facilities.
230 #6
231 #MARISAT Terminated
232 #Indicates that the transaction terminated using Marine Satellite facilities.
233 #7
234 #High Seas Terminated Indicates that the transaction Terminated through
235 #High Seas Marine facilities.
236 #8
237 #Cellular Terminated
238 #Indicates that the transaction is cellular terminated.
239 #9
240 #IP Terminated
241
242     '', #indicator_11
243     '', #indicator_12
244     '', #indicator_13
245     '', #indicator_14
246     '', #indicator_15
247     '', #indicator_16
248     '', #indicator_17
249     '', #indicator_18
250
251     '', #indicator_19
252 #Indicator 19 - LATA Identifier 
253 #Value
254 #Indicates
255 #Definition 
256 #0 
257 #Not Applicable 
258 #Valid for Unrated Message (Category 10), Telegram Charge (01-01-14), summary Non-Detail Credit (41-50-01), summary Non-Detail Charge (42-50-01), summary Post-Billing Adjustment Non-Detail (45-50-01) records and 800 Records Recorded at the SSP (01-01-25) records. Also valid for IP records. 
259 #1 
260 #IntraLATA - LEC Message 
261 #Indicates that the message originated and terminated within the same LATA and was for telecommunications services provided by a LEC or traffic transported by facilities belonging to or leased by a LEC. Revenue belongs to the LEC. For Category 11 records, this value indicates IntraLATA only, and not whether IC or LEC carried. This is the preferred value for Category 11 IntraLATA. 
262 #2 
263 #InterLATA - IC Message 
264 #Indicates that the message originated in one LATA and terminated in another LATA and was transported by an IC. Revenue belongs to the IC. For Category 11 records, this value indicates InterLATA only, and not whether IC or LEC carried. This is the preferred value for Category 11 InterLATA. 
265 #3 
266 #InterLATA - LEC Message 
267 #Indicates that the message originated in one LATA and terminated in another LATA and was for telecommunications services provided by a LEC or traffic transported by facilities belonging to or leased by a LEC (e.g., Corridor Traffic or interLATA local traffic, as defined in the local tariff). Revenue belongs to the LEC. For Category 11 records, this value indicates InterLATA only, and not whether IC or LEC carried.
268 #
269 #Indicator 24 - Specialized Services 
270 #Value 
271 #Indicates 
272 #Definition 
273 #1 
274 #Telecommunications Relay Service 
275 #Indicates a call was placed using a Telecommunications Relay Service. 
276 #2 
277 #Three Way Calling 
278 #Indicates the message originated as part of the Three Way Calling feature. 
279 #3 
280 #Directory Assistance Call Completion 
281 #Indicates the call was completed as a result of a call to a Directory Assistance Call Completion (DACC). 
282
283     '', #UNKNOWN_3
284
285     'charged_party', #billing_number
286
287     'upstream_src_regionname', #calling_city
288
289     sub { #calling_state
290       my($cdr, $data, $conf, $param) = @_;
291       $cdr->upstream_src_regionname( $cdr->upstream_src_regionname.', '. $data);
292     },
293
294     'upstream_dst_regionname', #called_city
295
296     sub { #called_state
297       my($cdr, $data, $conf, $param) = @_;
298       $cdr->upstream_dst_regionname( $cdr->upstream_dst_regionname.', '. $data);
299     },
300
301     '', #UNKNOWN_4
302
303     '', #settlement_code
304 #Settlement Code A one-position alphanumeric field used for the classification of messages and revenues. Two levels of detail are defined below: 1. The first set of codes is considered to be the minimum requirement. 2. The second set of codes provide a higher level of detail regarding the origin and termination of the message. This additional level of detail can be used where required and where negotiated between the Sending and Receiving companies.
305 #
306 # Minimum Requirements: 6 2. A message between points within the same company’s territory in Canada. Example: Points within the Province of Quebec. J 
307 #Settlement Code 
308 #Description 
309 #5 
310 #INTER-CANADA 
311 #A message between points within Canada. (Also see Settlement Codes ‘5’ and ‘8’in the optional, more detailed section below.) 
312 #LOCAL 
313 #Identifies a service filed under a Local Exchange Tariff. This value is not valid for Category 11 records when traffic utilizes the IC network. (1+ presubscribed, 101XXXX dialed, etc.) 
314 #7 
315 #EAS/EMS (Extended Area Service/Extended Metro Service) This value is to be used for Access Record exchange. 
316 #8 
317 #INTRASTATE - U.S./U.S. 
318 #INTERSTATE - U.S./U.S. 
319 #A message between points in different states within the United States or its territories (i.e., Puerto Rico, the U. S. Virgin Islands, Guam, American Samoa and the Commonwealth of the Northern Mariana Islands). Examples: New Jersey/Maryland, New York/Puerto Rico, California/Alaska. (Also see Settlement Codes ‘G’ and ‘Q’ in the optional, more detailed descriptions below.) 
320 #NOTE: This Settlement Code is used for all interstate Radio Link Charges. 
321 #K 
322 #INTERNATIONAL - U.S./CANADA 
323 #A message between a point within the United States and its territories (i.e., Puerto Rico, the U. S. Virgin Islands, Guam, American Samoa and the Commonwealth of the Northern Mariana Islands) and a point in Canada. Example: New York/Quebec. 
324
325     '', #UNKNOWN_5
326
327     '', #ind24
328 #Indicator 24 - Specialized Services 
329 #Value 
330 #Indicates 
331 #Definition 
332 #1 
333 #Telecommunications Relay Service 
334 #Indicates a call was placed using a Telecommunications Relay Service. 
335 #2 
336 #Three Way Calling 
337 #Indicates the message originated as part of the Three Way Calling feature. 
338 #3 
339 #Directory Assistance Call Completion 
340 #Indicates the call was completed as a result of a call to a Directory Assistance Call Completion (DACC). 
341
342     '', #UNKNOWN_6
343
344     '', #calling_module
345 #Calling Module contains a 3 digit value that identifies the module plus a one position alpha filed that contains the module version. 
346
347     '', #module_value_length
348
349     '', #cai
350
351     'accountcode', #account_code
352
353     '', #UNKNOWN_7
354
355     '', #tmod
356
357   ],
358
359 );
360
361 1;
362