2 use base qw( FS::cdr );
7 #use FS::cdr qw( _cdr_date_parser_maker _cdr_min_parser_maker );
10 'name' => 'EMI (Exchange Message Interface)',
12 'type' => 'fixedlength',
13 'fixedlength_format' => [qw(
14 record_identification:6:1:6
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
26 conversation_time:7:61:67
27 method_of_recording:2:68:69
54 indicator_19:1:100:100
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
66 settlement_code:1:149:149
74 calling_module:4:211:214
75 module_value_length:3:215:217
77 account_code:10:219:228
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;
94 # _cdr_date_parser_maker('startdate'), # 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;
103 '', #calling_number_length
105 'src', #calling_number
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
115 '', #called_number_length
117 'dst', #called_number
119 sub { #amount_collected
120 my($cdr, $data, $conf, $param) = @_;
122 $cdr->upstream_price( $data / 1000 );
128 my($cdr, $data, $conf, $param) = @_;
130 $data =~ /^(\d\d)(\d\d)(\d\d)$/ or die "unparsable connect_time: $data";
131 $cdr->startdate( timelocal(
133 $cdr->{_tmp_mday}, $cdr->{_tmp_mon}-1, $cdr->{_tmp_year}
138 sub { #conversation_time
139 my($cdr, $data, $conf, $param) = @_;
141 $data =~ /^(\d{6})(\d)$/ or die "unparsable connect_time: $data";
144 $time++ if $2 >= 5; #round up if tenths > .5
146 $cdr->duration($time);
147 $cdr->billsec($time);
151 '', #method_of_recording
155 'upstream_rateplanid', #rate_class
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:
163 #5 = Special Collect/Reverse Billing
172 #Indicator 1 - Coin/Hotel - Motel - Hospital - University Dorm Room - OUTWATS Out Of Band
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.
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
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.
186 #Hotel-Motel-Hospital- University Dorm Room Originated
187 #The Message originated at an extension in a hotel, motel, hospital, or university dorm room
190 #Message originated at an OUTWATS line and terminated at an out-of-band point.
192 #Non-Hotel-Auto/Voice Quote
193 #OSS message originated at a non-hotel business subscribing to automated Voice Charge Quotation Service
195 #IC Carrier Owned Public Telephone Originated
196 #Message originated at an IC Carrier owned public telephone station
198 #Customer Owned Public Telephone Originated
199 #Message originated at a customer owned public telephone station.
211 #Indicator 10 – Radio Services or IP Services Terminated
216 #Mobile Non-Roamer Terminated
217 #Indicates that the transaction terminated at a Mobile Non-Roamer.
219 #Mobile Roamer Terminated
220 #Indicates that the transaction terminated at a Mobile Roamer.
223 #Indicates that the transaction terminated through Air/Ground facilities.
225 #High Speed Train Terminated
226 #Indicates that the transaction terminated aboard a High Speed Train.
229 #Indicates that the transaction terminated through Coastal Harbor, VHF, marine facilities.
232 #Indicates that the transaction terminated using Marine Satellite facilities.
234 #High Seas Terminated Indicates that the transaction Terminated through
235 #High Seas Marine facilities.
238 #Indicates that the transaction is cellular terminated.
252 #Indicator 19 - LATA Identifier
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.
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.
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.
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.
269 #Indicator 24 - Specialized Services
274 #Telecommunications Relay Service
275 #Indicates a call was placed using a Telecommunications Relay Service.
278 #Indicates the message originated as part of the Three Way Calling feature.
280 #Directory Assistance Call Completion
281 #Indicates the call was completed as a result of a call to a Directory Assistance Call Completion (DACC).
285 'charged_party', #billing_number
287 'upstream_src_regionname', #calling_city
290 my($cdr, $data, $conf, $param) = @_;
291 $cdr->upstream_src_regionname( $cdr->upstream_src_regionname.', '. $data);
294 'upstream_dst_regionname', #called_city
297 my($cdr, $data, $conf, $param) = @_;
298 $cdr->upstream_dst_regionname( $cdr->upstream_dst_regionname.', '. $data);
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.
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
311 #A message between points within Canada. (Also see Settlement Codes ‘5’ and ‘8’in the optional, more detailed section below.)
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.)
315 #EAS/EMS (Extended Area Service/Extended Metro Service) This value is to be used for Access Record exchange.
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.
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.
328 #Indicator 24 - Specialized Services
333 #Telecommunications Relay Service
334 #Indicates a call was placed using a Telecommunications Relay Service.
337 #Indicates the message originated as part of the Three Way Calling feature.
339 #Directory Assistance Call Completion
340 #Indicates the call was completed as a result of a call to a Directory Assistance Call Completion (DACC).
345 #Calling Module contains a 3 digit value that identifies the module plus a one position alpha filed that contains the module version.
347 '', #module_value_length
351 'accountcode', #account_code