rbedi 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/edi +897 -0
- data/lib/rbedi/codes/aaa.rb +437 -0
- data/lib/rbedi/codes/ak1.rb +278 -0
- data/lib/rbedi/codes/ak2.rb +336 -0
- data/lib/rbedi/codes/ak9.rb +55 -0
- data/lib/rbedi/codes/bht.rb +706 -0
- data/lib/rbedi/codes/codeset.rb +27 -0
- data/lib/rbedi/codes/dmg.rb +1583 -0
- data/lib/rbedi/codes/dtp.rb +1342 -0
- data/lib/rbedi/codes/eb.rb +1511 -0
- data/lib/rbedi/codes/eq.rb +286 -0
- data/lib/rbedi/codes/ge.rb +14 -0
- data/lib/rbedi/codes/gs.rb +287 -0
- data/lib/rbedi/codes/hl.rb +273 -0
- data/lib/rbedi/codes/iea.rb +14 -0
- data/lib/rbedi/codes/ik3.rb +32 -0
- data/lib/rbedi/codes/ik4.rb +37 -0
- data/lib/rbedi/codes/ik5.rb +56 -0
- data/lib/rbedi/codes/isa.rb +137 -0
- data/lib/rbedi/codes/le.rb +13 -0
- data/lib/rbedi/codes/ls.rb +13 -0
- data/lib/rbedi/codes/msg.rb +25 -0
- data/lib/rbedi/codes/n3.rb +14 -0
- data/lib/rbedi/codes/n4.rb +706 -0
- data/lib/rbedi/codes/nm1.rb +1916 -0
- data/lib/rbedi/codes/per.rb +308 -0
- data/lib/rbedi/codes/ref.rb +1749 -0
- data/lib/rbedi/codes/se.rb +14 -0
- data/lib/rbedi/codes/segment_names.rb +44 -0
- data/lib/rbedi/codes/st.rb +336 -0
- data/lib/rbedi/codes/trn.rb +22 -0
- data/lib/rbedi/codes.rb +8 -0
- data/lib/rbedi/edi_date_time.rb +69 -0
- data/lib/rbedi/functional_group.rb +52 -0
- data/lib/rbedi/non_existent_element_error.rb +4 -0
- data/lib/rbedi/parser.rb +102 -0
- data/lib/rbedi/segment.rb +114 -0
- data/lib/rbedi/transaction_envelope.rb +77 -0
- data/lib/rbedi/transaction_set.rb +40 -0
- data/lib/rbedi.rb +20 -4
- metadata +79 -10
@@ -0,0 +1,44 @@
|
|
1
|
+
module RBEDI
|
2
|
+
module Codes
|
3
|
+
module SegmentNames
|
4
|
+
SEGMENT_NAMES = {
|
5
|
+
"ISA" => :interchange_control_header,
|
6
|
+
"IEA" => :interchange_control_trailer,
|
7
|
+
"GS" => :functional_group_header,
|
8
|
+
"GE" => :functional_group_trailer,
|
9
|
+
"ST" => :transaction_set_header,
|
10
|
+
"SE" => :transaction_set_trailer,
|
11
|
+
"LS" => :loop_header,
|
12
|
+
"LE" => :loop_trailer,
|
13
|
+
"BHT" => :begin_hierarchial_transaction,
|
14
|
+
"HL" => :hierarchial_level,
|
15
|
+
"NM1" => :individual_or_organization_name,
|
16
|
+
"N3" => :party_location,
|
17
|
+
"N4" => :geographic_location,
|
18
|
+
"PER" => :administrative_communications_contact,
|
19
|
+
"TRN" => :trace,
|
20
|
+
"MSG" => :message_text,
|
21
|
+
"DMG" => :demographic_information,
|
22
|
+
"REF" => :reference_information,
|
23
|
+
"DTP" => :date_time_period,
|
24
|
+
"EQ" => :eligibility_or_benefit_inquiry,
|
25
|
+
"EB" => :eligibility_or_benefit_information,
|
26
|
+
"AAA" => :request_validation,
|
27
|
+
"AK1" => :functional_group_response_header,
|
28
|
+
"AK9" => :functional_group_response_trailer,
|
29
|
+
"AK2" => :transaction_set_response_header,
|
30
|
+
"IK3" => :implementation_data_segment_note,
|
31
|
+
"IK4" => :implementation_data_element_note,
|
32
|
+
"IK5" => :implementation_transaction_set_response_trailer,
|
33
|
+
}
|
34
|
+
|
35
|
+
def self.segment_name(segment)
|
36
|
+
if segment.is_a?(Symbol)
|
37
|
+
SEGMENT_NAMES.key(segment)
|
38
|
+
else
|
39
|
+
SEGMENT_NAMES[segment]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,336 @@
|
|
1
|
+
module RBEDI
|
2
|
+
module Codes
|
3
|
+
module ST
|
4
|
+
extend CodeSet
|
5
|
+
|
6
|
+
SEGMENT_POSITIONS = {
|
7
|
+
1 => :transaction_set_identifier_code,
|
8
|
+
2 => :transaction_set_control_number,
|
9
|
+
3 => :implementation_convention_reference,
|
10
|
+
}
|
11
|
+
|
12
|
+
CODES = {
|
13
|
+
1 => {
|
14
|
+
"100" => :insurance_plan_description,
|
15
|
+
"101" => :name_and_address_lists,
|
16
|
+
"102" => :associated_data,
|
17
|
+
"103" => :abandoned_property_filings,
|
18
|
+
"104" => :air_shipment_information,
|
19
|
+
"105" => :business_entity_filings,
|
20
|
+
"106" => :motor_carrier_rate_proposal,
|
21
|
+
"107" => :request_for_motor_carrier_rate_proposal,
|
22
|
+
"108" => :response_to_a_motor_carrier_rate_proposal,
|
23
|
+
"109" => :vessel_content_details,
|
24
|
+
"110" => :air_freight_details_and_invoice,
|
25
|
+
"111" => :individual_insurance_policy_and_client_information,
|
26
|
+
"112" => :property_damage_report,
|
27
|
+
"113" => :election_campaign_and_lobbyist_reporting,
|
28
|
+
"120" => :vehicle_shipping_order,
|
29
|
+
"121" => :vehicle_service,
|
30
|
+
"124" => :vehicle_damage,
|
31
|
+
"125" => :multilevel_railcar_load_details,
|
32
|
+
"126" => :vehicle_application_advice,
|
33
|
+
"127" => :vehicle_baying_order,
|
34
|
+
"128" => :dealer_information,
|
35
|
+
"129" => :vehicle_carrier_rate_update,
|
36
|
+
"130" => :student_educational_record_transcript,
|
37
|
+
"131" => :student_educational_record_transcript_acknowledgment,
|
38
|
+
"132" => :human_resource_information,
|
39
|
+
"133" => :educational_institution_record,
|
40
|
+
"135" => :student_aid_origination_record,
|
41
|
+
"138" => :educational_testing_and_prospect_request_and_report,
|
42
|
+
"139" => :student_loan_guarantee_result,
|
43
|
+
"140" => :product_registration,
|
44
|
+
"141" => :product_service_claim_response,
|
45
|
+
"142" => :product_service_claim,
|
46
|
+
"143" => :product_service_notification,
|
47
|
+
"144" => :student_loan_transfer_and_status_verification,
|
48
|
+
"146" => :request_for_student_educational_record_transcript,
|
49
|
+
"147" => :response_to_request_for_student_educational_record_transcript,
|
50
|
+
"148" => :report_of_injury_illness_or_incident,
|
51
|
+
"149" => :notice_of_tax_adjustment_or_assessment,
|
52
|
+
"150" => :tax_rate_notification,
|
53
|
+
"151" => :electronic_filing_of_tax_return_data_acknowledgment,
|
54
|
+
"152" => :statistical_government_information,
|
55
|
+
"153" => :unemployment_insurance_tax_claim_or_charge_information,
|
56
|
+
"154" => :secured_interest_filing,
|
57
|
+
"155" => :business_credit_report,
|
58
|
+
"157" => :notice_of_power_of_attorney,
|
59
|
+
"158" => :tax_jurisdiction_sourcing,
|
60
|
+
"159" => :motion_picture_booking_confirmation,
|
61
|
+
"160" => :transportation_automatic_equipment_identification,
|
62
|
+
"161" => :train_sheet,
|
63
|
+
"163" => :transportation_appointment_schedule_information,
|
64
|
+
"170" => :revenue_receipts_statement,
|
65
|
+
"175" => :court_and_law_enforcement_notice,
|
66
|
+
"176" => :court_submission,
|
67
|
+
"179" => :environmental_compliance_reporting,
|
68
|
+
"180" => :return_merchandise_authorization_and_notification,
|
69
|
+
"185" => :royalty_regulatory_report,
|
70
|
+
"186" => :insurance_underwriting_requirements_reporting,
|
71
|
+
"187" => :premium_audit_request_and_return,
|
72
|
+
"188" => :educational_course_inventory,
|
73
|
+
"189" => :application_for_admission_to_educational_institutions,
|
74
|
+
"190" => :student_enrollment_verification,
|
75
|
+
"191" => :student_loan_preclaims_and_claims,
|
76
|
+
"194" => :grant_or_assistance_application,
|
77
|
+
"195" => :federal_communications_commission_fcc_license_application,
|
78
|
+
"196" => :contractor_cost_data_reporting,
|
79
|
+
"197" => :real_estate_title_evidence,
|
80
|
+
"198" => :loan_verification_information,
|
81
|
+
"199" => :real_estate_settlement_information,
|
82
|
+
"200" => :mortgage_credit_report,
|
83
|
+
"201" => :residential_loan_application,
|
84
|
+
"202" => :secondary_mortgage_market_loan_delivery,
|
85
|
+
"203" => :secondary_mortgage_market_investor_report,
|
86
|
+
"204" => :motor_carrier_load_tender,
|
87
|
+
"205" => :mortgage_note,
|
88
|
+
"206" => :real_estate_inspection,
|
89
|
+
"210" => :motor_carrier_freight_details_and_invoice,
|
90
|
+
"211" => :motor_carrier_bill_of_lading,
|
91
|
+
"212" => :motor_carrier_delivery_trailer_manifest,
|
92
|
+
"213" => :motor_carrier_shipment_status_inquiry,
|
93
|
+
"214" => :transportation_carrier_shipment_status_message,
|
94
|
+
"215" => :motor_carrier_pickup_manifest,
|
95
|
+
"216" => :motor_carrier_shipment_pickup_notification,
|
96
|
+
"217" => :motor_carrier_loading_and_route_guide,
|
97
|
+
"219" => :logistics_service_request,
|
98
|
+
"220" => :logistics_service_response,
|
99
|
+
"222" => :cartage_work_assignment,
|
100
|
+
"223" => :consolidators_freight_bill_and_invoice,
|
101
|
+
"224" => :motor_carrier_summary_freight_bill_manifest,
|
102
|
+
"225" => :response_to_a_cartage_work_assignment,
|
103
|
+
"227" => :trailer_usage_report,
|
104
|
+
"228" => :equipment_inspection_report,
|
105
|
+
"240" => :motor_carrier_package_status,
|
106
|
+
"242" => :data_status_tracking,
|
107
|
+
"244" => :product_source_information,
|
108
|
+
"245" => :real_estate_tax_service_response,
|
109
|
+
"248" => :account_assignmentinquiry_and_servicestatus,
|
110
|
+
"249" => :animal_toxicological_data,
|
111
|
+
"250" => :purchase_order_shipment_management_document,
|
112
|
+
"251" => :pricing_support,
|
113
|
+
"252" => :insurance_producer_administration,
|
114
|
+
"255" => :underwriting_information_services,
|
115
|
+
"256" => :periodic_compensation,
|
116
|
+
"259" => :residential_mortgage_insurance_explanation_of_benefits,
|
117
|
+
"260" => :application_for_mortgage_insurance_benefitsa_claim_filed_for_mortgage_insurance_benefits,
|
118
|
+
"261" => :real_estate_information_request,
|
119
|
+
"262" => :real_estate_information_report,
|
120
|
+
"263" => :residential_mortgage_insurance_application_response,
|
121
|
+
"264" => :mortgage_loan_default_status,
|
122
|
+
"265" => :real_estate_title_insurance_services_order,
|
123
|
+
"266" => :mortgage_or_property_record_change_notification,
|
124
|
+
"267" => :individual_life_annuity_and_disability_application,
|
125
|
+
"268" => :annuity_activity,
|
126
|
+
"269" => :health_care_benefit_coordination_verification,
|
127
|
+
"270" => :eligibility_coverage_or_benefit_inquiry,
|
128
|
+
"271" => :eligibility_coverage_or_benefit_information,
|
129
|
+
"272" => :property_and_casualty_loss_notification,
|
130
|
+
"273" => :insuranceannuity_application_status,
|
131
|
+
"274" => :healthcare_provider_information,
|
132
|
+
"275" => :patient_information,
|
133
|
+
"276" => :health_care_claim_status_request,
|
134
|
+
"277" => :health_care_information_status_notification,
|
135
|
+
"278" => :health_care_services_review_information,
|
136
|
+
"280" => :voter_registration_information,
|
137
|
+
"283" => :tax_or_fee_exemption_certification,
|
138
|
+
"284" => :commercial_vehicle_safety_reports,
|
139
|
+
"285" => :commercial_vehicle_safety_and_credentials_information_exchange,
|
140
|
+
"286" => :commercial_vehicle_credentials,
|
141
|
+
"288" => :wage_determination,
|
142
|
+
"290" => :cooperative_advertising_agreements,
|
143
|
+
"300" => :reservation_booking_request_ocean,
|
144
|
+
"301" => :confirmation_ocean,
|
145
|
+
"303" => :booking_cancellation_ocean,
|
146
|
+
"304" => :shipping_instructions,
|
147
|
+
"309" => :customs_manifest,
|
148
|
+
"310" => :freight_receipt_and_invoice_ocean,
|
149
|
+
"311" => :canada_customs_information,
|
150
|
+
"312" => :arrival_notice_ocean,
|
151
|
+
"313" => :shipment_status_inquiry_ocean,
|
152
|
+
"315" => :status_details_ocean,
|
153
|
+
"317" => :deliverypickup_order,
|
154
|
+
"319" => :terminal_information,
|
155
|
+
"322" => :terminal_operations_and_intermodal_ramp_activity,
|
156
|
+
"323" => :vessel_schedule_and_itinerary_ocean,
|
157
|
+
"324" => :vessel_stow_plan_ocean,
|
158
|
+
"325" => :consolidation_of_goods_in_container,
|
159
|
+
"326" => :consignment_summary_list,
|
160
|
+
"350" => :customs_status_information,
|
161
|
+
"352" => :us_customs_carrier_general_order_status,
|
162
|
+
"353" => :customs_events_advisory_details,
|
163
|
+
"354" => :us_customs_automated_manifest_archive_status,
|
164
|
+
"355" => :us_customs_acceptancerejection,
|
165
|
+
"356" => :us_customs_permit_to_transfer_request,
|
166
|
+
"357" => :us_customs_inbond_information,
|
167
|
+
"358" => :customs_consist_information,
|
168
|
+
"361" => :carrier_interchange_agreement_ocean,
|
169
|
+
"362" => :cargo_insurance_advice_of_shipment,
|
170
|
+
"404" => :rail_carrier_shipment_information,
|
171
|
+
"410" => :rail_carrier_freight_details_and_invoice,
|
172
|
+
"412" => :trailer_or_container_repair_billing,
|
173
|
+
"414" => :rail_carhire_settlements,
|
174
|
+
"417" => :rail_carrier_waybill_interchange,
|
175
|
+
"418" => :rail_advance_interchange_consist,
|
176
|
+
"419" => :advance_car_disposition,
|
177
|
+
"420" => :car_handling_information,
|
178
|
+
"421" => :estimated_time_of_arrival_and_car_scheduling,
|
179
|
+
"422" => :equipment_order,
|
180
|
+
"423" => :rail_industrial_switch_list,
|
181
|
+
"424" => :rail_carrier_services_settlement,
|
182
|
+
"425" => :rail_waybill_request,
|
183
|
+
"426" => :rail_revenue_waybill,
|
184
|
+
"429" => :railroad_retirement_activity,
|
185
|
+
"431" => :railroad_station_master_file,
|
186
|
+
"432" => :rail_deprescription,
|
187
|
+
"433" => :railroad_reciprocal_switch_file,
|
188
|
+
"434" => :railroad_mark_register_update_activity,
|
189
|
+
"435" => :standard_transportation_commodity_code_master,
|
190
|
+
"436" => :locomotive_information,
|
191
|
+
"437" => :railroad_junctions_and_interchanges_activity,
|
192
|
+
"440" => :shipment_weights,
|
193
|
+
"451" => :railroad_event_report,
|
194
|
+
"452" => :railroad_problem_log_inquiry_or_advice,
|
195
|
+
"453" => :railroad_service_commitment_advice,
|
196
|
+
"455" => :railroad_parameter_trace_registration,
|
197
|
+
"456" => :railroad_equipment_inquiry_or_advice,
|
198
|
+
"460" => :railroad_price_distribution_request_or_response,
|
199
|
+
"463" => :rail_rate_reply,
|
200
|
+
"466" => :rate_request,
|
201
|
+
"468" => :rate_docket_journal_log,
|
202
|
+
"470" => :railroad_clearance,
|
203
|
+
"475" => :rail_route_file_maintenance,
|
204
|
+
"485" => :ratemaking_action,
|
205
|
+
"486" => :rate_docket_expiration,
|
206
|
+
"490" => :rate_group_definition,
|
207
|
+
"492" => :miscellaneous_rates,
|
208
|
+
"494" => :rail_scale_rates,
|
209
|
+
"500" => :medical_event_reporting,
|
210
|
+
"501" => :vendor_performance_review,
|
211
|
+
"503" => :pricing_history,
|
212
|
+
"504" => :clauses_and_provisions,
|
213
|
+
"511" => :requisitiontransaction_set_for_ordering_equipment_and_material_from_a_supply_distribution_system_this_can_also_be_used_to_inquire_about_amend_or_terminate_the_original_order,
|
214
|
+
"517" => :material_obligation_validationtransaction_set_for_verifying_the_continued_need_for_open_orders_can_also_be_used_to_confirm_open_order_quantities_and_request_reinstatement_of_previously_cancelled_open_orders,
|
215
|
+
"521" => :income_or_asset_offset,
|
216
|
+
"527" => :material_duein_and_receipttransaction_set_for_reporting_material_duesin_anticipated_receipts_and_receipts,
|
217
|
+
"536" => :logistics_reassignmenttransaction_set_for_reporting_information_needed_by_a_new_manager_when_transferring_inventory_management_responsibility_between_organizations,
|
218
|
+
"540" => :notice_of_employment_status,
|
219
|
+
"561" => :contract_abstracta_summary_of_the_essential_elements_of_a_contract_sufficient_to_enable_the_contract_administration_process_to_commence,
|
220
|
+
"567" => :contract_completion_statustransaction_set_for_reporting_the_administrative_closure_status_of_physically_completed_contracts,
|
221
|
+
"568" => :contract_payment_management_report,
|
222
|
+
"601" => :us_customs_export_shipment_information,
|
223
|
+
"602" => :transportation_services_tender,
|
224
|
+
"620" => :excavation_communication,
|
225
|
+
"625" => :well_information,
|
226
|
+
"650" => :maintenance_service_order,
|
227
|
+
"715" => :intermodal_group_loading_plan,
|
228
|
+
"753" => :request_for_routing_instructions,
|
229
|
+
"754" => :routing_instructions,
|
230
|
+
"805" => :contract_pricing_proposal,
|
231
|
+
"806" => :project_schedule_reporting,
|
232
|
+
"810" => :invoice,
|
233
|
+
"811" => :consolidated_service_invoicestatement,
|
234
|
+
"812" => :creditdebit_adjustment,
|
235
|
+
"813" => :electronic_filing_of_tax_return_data,
|
236
|
+
"814" => :general_request_response_or_confirmation,
|
237
|
+
"815" => :cryptographic_service_message,
|
238
|
+
"816" => :organizational_relationships,
|
239
|
+
"818" => :commission_sales_report,
|
240
|
+
"819" => :joint_interest_billing_and_operating_expense_statement,
|
241
|
+
"820" => :payment_orderremittance_advice,
|
242
|
+
"821" => :financial_information_reporting,
|
243
|
+
"822" => :account_analysis,
|
244
|
+
"823" => :lockbox,
|
245
|
+
"824" => :application_advice,
|
246
|
+
"826" => :tax_information_exchange,
|
247
|
+
"827" => :financial_return_notice,
|
248
|
+
"828" => :debit_authorization,
|
249
|
+
"829" => :payment_cancellation_request,
|
250
|
+
"830" => :planning_schedule_with_release_capability,
|
251
|
+
"831" => :application_control_totals,
|
252
|
+
"832" => :pricesales_catalog,
|
253
|
+
"833" => :mortgage_credit_report_order,
|
254
|
+
"834" => :benefit_enrollment_and_maintenance,
|
255
|
+
"835" => :health_care_claim_paymentadvice,
|
256
|
+
"836" => :procurement_notices,
|
257
|
+
"837" => :health_care_claim,
|
258
|
+
"838" => :trading_partner_profile,
|
259
|
+
"839" => :project_cost_reporting,
|
260
|
+
"840" => :request_for_quotation,
|
261
|
+
"841" => :specificationstechnical_information,
|
262
|
+
"842" => :nonconformance_report,
|
263
|
+
"843" => :response_to_request_for_quotation,
|
264
|
+
"844" => :product_transfer_account_adjustment,
|
265
|
+
"845" => :price_authorization_acknowledgmentstatus,
|
266
|
+
"846" => :inventory_inquiryadvice,
|
267
|
+
"847" => :material_claim,
|
268
|
+
"848" => :material_safety_data_sheet,
|
269
|
+
"849" => :response_to_product_transfer_account_adjustment,
|
270
|
+
"850" => :purchase_order,
|
271
|
+
"851" => :asset_schedule,
|
272
|
+
"852" => :product_activity_data,
|
273
|
+
"853" => :routing_and_carrier_instruction,
|
274
|
+
"854" => :shipment_delivery_discrepancy_information,
|
275
|
+
"855" => :purchase_order_acknowledgment,
|
276
|
+
"856" => :ship_noticemanifest,
|
277
|
+
"857" => :shipment_and_billing_notice,
|
278
|
+
"858" => :shipment_information,
|
279
|
+
"859" => :freight_invoice,
|
280
|
+
"860" => :purchase_order_change_request__buyer_initiated,
|
281
|
+
"861" => :receiving_adviceacceptance_certificate,
|
282
|
+
"862" => :shipping_schedule,
|
283
|
+
"863" => :report_of_test_results,
|
284
|
+
"864" => :text_message,
|
285
|
+
"865" => :purchase_order_change_acknowledgmentrequest__seller_initiated,
|
286
|
+
"866" => :production_sequence,
|
287
|
+
"867" => :product_transfer_and_resale_report,
|
288
|
+
"868" => :electronic_form_structure,
|
289
|
+
"869" => :order_status_inquiry,
|
290
|
+
"870" => :order_status_report,
|
291
|
+
"871" => :component_parts_content,
|
292
|
+
"872" => :residential_mortgage_insurance_application,
|
293
|
+
"873" => :commodity_movement_services,
|
294
|
+
"874" => :commodity_movement_services_response,
|
295
|
+
"875" => :grocery_products_purchase_order,
|
296
|
+
"876" => :grocery_products_purchase_order_change,
|
297
|
+
"877" => :manufacturer_coupon_family_code_structure,
|
298
|
+
"878" => :product_authorizationdeauthorization,
|
299
|
+
"879" => :price_information,
|
300
|
+
"880" => :grocery_products_invoice,
|
301
|
+
"881" => :manufacturer_coupon_redemption_detail,
|
302
|
+
"882" => :direct_store_delivery_summary_information,
|
303
|
+
"883" => :market_development_fund_allocation,
|
304
|
+
"884" => :market_development_fund_settlement,
|
305
|
+
"885" => :retail_account_characteristics,
|
306
|
+
"886" => :customer_call_reporting,
|
307
|
+
"887" => :coupon_notification,
|
308
|
+
"888" => :item_maintenance,
|
309
|
+
"889" => :promotion_announcement,
|
310
|
+
"891" => :deduction_research_report,
|
311
|
+
"893" => :item_information_request,
|
312
|
+
"894" => :deliveryreturn_base_record,
|
313
|
+
"895" => :deliveryreturn_acknowledgment_or_adjustment,
|
314
|
+
"896" => :product_dimension_maintenance,
|
315
|
+
"920" => :loss_or_damage_claim__general_commodities,
|
316
|
+
"924" => :loss_or_damage_claim__motor_vehicle,
|
317
|
+
"925" => :claim_tracer,
|
318
|
+
"926" => :claim_status_report_and_tracer_reply,
|
319
|
+
"928" => :automotive_inspection_detail,
|
320
|
+
"940" => :warehouse_shipping_order,
|
321
|
+
"943" => :warehouse_stock_transfer_shipment_advice,
|
322
|
+
"944" => :warehouse_stock_transfer_receipt_advice,
|
323
|
+
"945" => :warehouse_shipping_advice,
|
324
|
+
"947" => :warehouse_inventory_adjustment_advice,
|
325
|
+
"980" => :functional_group_totals,
|
326
|
+
"990" => :response_to_a_load_tender,
|
327
|
+
"993" => :secured_receipt_or_acknowledgment,
|
328
|
+
"996" => :file_transfer,
|
329
|
+
"997" => :functional_acknowledgment,
|
330
|
+
"998" => :set_cancellation,
|
331
|
+
"999" => :implementation_acknowledgment,
|
332
|
+
}
|
333
|
+
}
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module RBEDI
|
2
|
+
module Codes
|
3
|
+
module TRN
|
4
|
+
extend CodeSet
|
5
|
+
|
6
|
+
SEGMENT_POSITIONS = {
|
7
|
+
1 => :trace_type_code,
|
8
|
+
2 => :reference_identification,
|
9
|
+
3 => :originating_company_identifier,
|
10
|
+
4 => :second_reference_identification,
|
11
|
+
}
|
12
|
+
|
13
|
+
CODES = {
|
14
|
+
1 => {
|
15
|
+
"1" => :current_transaction,
|
16
|
+
"2" => :referenced_transaction,
|
17
|
+
"3" => :financial_reassociation,
|
18
|
+
}
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/rbedi/codes.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
module RBEDI
|
2
|
+
class EDIDateTime
|
3
|
+
CCYYMMDD_STRFTIME = "%Y%m%d"
|
4
|
+
YYMMDD_STRFTIME = "%y%m%d"
|
5
|
+
HHMMSS_STRFTIME = "%H%M%S"
|
6
|
+
HHMM_STRFTIME = "%H%M"
|
7
|
+
DEFAULT_OFFSET = DateTime.now.strftime("%z")
|
8
|
+
|
9
|
+
def initialize(datetime_start, datetime_end = nil)
|
10
|
+
if datetime_start.is_a?(EDIDateTime)
|
11
|
+
@datetime_start = datetime_start.datetime_start
|
12
|
+
@datetime_end = datetime_start.datetime_end
|
13
|
+
else
|
14
|
+
@datetime_start = datetime_start
|
15
|
+
@datetime_end = datetime_end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.now
|
20
|
+
new(DateTime.now)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.now_range
|
24
|
+
new(DateTime.now, DateTime.now)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.parse(date: "", time: "", offset: DEFAULT_OFFSET)
|
28
|
+
start_date, end_date = date.split("-")
|
29
|
+
start_time, end_time = time.split("-")
|
30
|
+
|
31
|
+
if start_date.nil? || start_date.empty?
|
32
|
+
date_strftime = ""
|
33
|
+
else
|
34
|
+
date_strftime = CCYYMMDD_STRFTIME if start_date.length == 8
|
35
|
+
date_strftime = YYMMDD_STRFTIME if start_date.length == 6
|
36
|
+
end
|
37
|
+
|
38
|
+
if start_time.nil? || start_time.empty?
|
39
|
+
time_strftime = ""
|
40
|
+
else
|
41
|
+
time_strftime = HHMMSS_STRFTIME if start_time.length == 6
|
42
|
+
time_strftime = HHMM_STRFTIME if start_time.length == 4
|
43
|
+
end
|
44
|
+
|
45
|
+
start_datetime = DateTime.strptime("#{start_date}#{start_time}#{offset}", date_strftime + time_strftime + "%z")
|
46
|
+
end_datetime = end_date || end_time ? DateTime.strptime("#{end_date}#{end_time}#{offset}", date_strftime + time_strftime + "%z") : nil
|
47
|
+
|
48
|
+
new(start_datetime, end_datetime)
|
49
|
+
end
|
50
|
+
|
51
|
+
def ccyymmdd
|
52
|
+
@datetime_end ? "#{@datetime_start.strftime(CCYYMMDD_STRFTIME)}-#{@datetime_end.strftime(CCYYMMDD_STRFTIME)}" : @datetime_start.strftime(CCYYMMDD_STRFTIME)
|
53
|
+
end
|
54
|
+
|
55
|
+
def yymmdd
|
56
|
+
@datetime_end ? "#{@datetime_start.strftime(YYMMDD_STRFTIME)}-#{@datetime_end.strftime(YYMMDD_STRFTIME)}" : @datetime_start.strftime(YYMMDD_STRFTIME)
|
57
|
+
end
|
58
|
+
|
59
|
+
def hhmmss
|
60
|
+
@datetime_end ? "#{@datetime_start.strftime(HHMMSS_STRFTIME)}-#{@datetime_end.strftime(HHMMSS_STRFTIME)}" : @datetime_start.strftime(HHMMSS_STRFTIME)
|
61
|
+
end
|
62
|
+
|
63
|
+
def hhmm
|
64
|
+
@datetime_end ? "#{@datetime_start.strftime(HHMM_STRFTIME)}-#{@datetime_end.strftime(HHMM_STRFTIME)}" : @datetime_start.strftime(HHMM_STRFTIME)
|
65
|
+
end
|
66
|
+
|
67
|
+
attr_accessor :datetime_start, :datetime_end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module RBEDI
|
2
|
+
class FunctionalGroup
|
3
|
+
include Codes
|
4
|
+
|
5
|
+
def initialize(
|
6
|
+
group_control_number:,
|
7
|
+
functional_identifier_code:,
|
8
|
+
application_sender_code:,
|
9
|
+
application_receiver_code:,
|
10
|
+
date_time: DateTime.now,
|
11
|
+
transaction_sets: []
|
12
|
+
)
|
13
|
+
@group_control_number = group_control_number.to_s
|
14
|
+
@functional_identifier_code = functional_identifier_code
|
15
|
+
@application_sender_code = application_sender_code
|
16
|
+
@application_receiver_code = application_receiver_code
|
17
|
+
@transaction_sets = transaction_sets
|
18
|
+
@date_time = EDIDateTime.new(date_time)
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
header.to_s +
|
23
|
+
@transaction_sets.map(&:to_s).join +
|
24
|
+
trailer.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
def header
|
28
|
+
Segment.new(
|
29
|
+
:functional_group_header,
|
30
|
+
functional_identifier_code: @functional_identifier_code,
|
31
|
+
application_sender_code: @application_sender_code,
|
32
|
+
application_receiver_code: @application_receiver_code,
|
33
|
+
date: @date_time.ccyymmdd,
|
34
|
+
time: @date_time.hhmm,
|
35
|
+
group_control_number: @group_control_number,
|
36
|
+
responsible_agency_code: :accredited_standards_committee_x12,
|
37
|
+
version_code: Codes::VERSION_CODE
|
38
|
+
)
|
39
|
+
end
|
40
|
+
|
41
|
+
def trailer
|
42
|
+
Segment.new(
|
43
|
+
:functional_group_trailer,
|
44
|
+
transaction_set_count: @transaction_sets.length,
|
45
|
+
group_control_number: @group_control_number
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
attr_accessor :group_control_number, :application_sender_code, :application_receiver_code,
|
50
|
+
:date_time, :functional_identifier_code, :transaction_sets
|
51
|
+
end
|
52
|
+
end
|
data/lib/rbedi/parser.rb
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
module RBEDI
|
2
|
+
class Parser
|
3
|
+
def initialize(edi_data, fragment: false, separator: nil)
|
4
|
+
@edi_data = edi_data
|
5
|
+
@fragment = fragment
|
6
|
+
@separator = separator
|
7
|
+
end
|
8
|
+
|
9
|
+
def parse
|
10
|
+
segments = to_segments
|
11
|
+
return segments.map{|s|Segment.parse(s, separator: @separator)} if @fragment
|
12
|
+
|
13
|
+
generate_transaction(segments)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def generate_transaction(segments)
|
19
|
+
transaction_envelope = nil
|
20
|
+
current_functional_group = nil
|
21
|
+
current_transaction_set = nil
|
22
|
+
|
23
|
+
segments.each do |segment|
|
24
|
+
segment = Segment.parse(segment, separator: @separator)
|
25
|
+
|
26
|
+
if segment.segment_type == :interchange_control_header
|
27
|
+
transaction_envelope = generate_transaction_envelope(segment)
|
28
|
+
@separator = transaction_envelope.repetition_separator unless @separator
|
29
|
+
next
|
30
|
+
end
|
31
|
+
|
32
|
+
break if segment.segment_type == :interchange_control_trailer
|
33
|
+
|
34
|
+
if segment.segment_type == :functional_group_header
|
35
|
+
current_functional_group = generate_functional_group(segment)
|
36
|
+
next
|
37
|
+
end
|
38
|
+
|
39
|
+
if segment.segment_type == :functional_group_trailer
|
40
|
+
transaction_envelope.functional_groups << current_functional_group
|
41
|
+
current_functional_group = nil
|
42
|
+
next
|
43
|
+
end
|
44
|
+
|
45
|
+
if segment.segment_type == :transaction_set_header
|
46
|
+
current_transaction_set = generate_transaction_set(segment)
|
47
|
+
next
|
48
|
+
end
|
49
|
+
|
50
|
+
if segment.segment_type == :transaction_set_trailer
|
51
|
+
current_functional_group.transaction_sets << current_transaction_set
|
52
|
+
current_transaction_set = nil
|
53
|
+
next
|
54
|
+
end
|
55
|
+
|
56
|
+
current_transaction_set&.segments&.push(segment)
|
57
|
+
end
|
58
|
+
|
59
|
+
transaction_envelope
|
60
|
+
end
|
61
|
+
|
62
|
+
def generate_transaction_set(segment)
|
63
|
+
TransactionSet.new(
|
64
|
+
transaction_set_control_number: segment[:transaction_set_control_number].to_i,
|
65
|
+
transaction_set_identifier_code: segment[:transaction_set_identifier_code]
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
def generate_functional_group(segment)
|
70
|
+
FunctionalGroup.new(
|
71
|
+
group_control_number: segment[:group_control_number].to_i,
|
72
|
+
functional_identifier_code: segment[:functional_identifier_code],
|
73
|
+
application_sender_code: segment[:application_sender_code].strip,
|
74
|
+
application_receiver_code: segment[:application_receiver_code].strip,
|
75
|
+
date_time: EDIDateTime.parse(date: segment[:date], time: segment[:time]).datetime_start
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
def generate_transaction_envelope(segment)
|
80
|
+
TransactionEnvelope.new(
|
81
|
+
authorization_information_qualifier: segment[:authorization_information_qualifier],
|
82
|
+
authorization_information: segment[:authorization_information],
|
83
|
+
security_information_qualifier: segment[:security_information_qualifier],
|
84
|
+
security_information: segment[:security_information],
|
85
|
+
interchange_sender_id_qualifier: segment[:interchange_sender_id_qualifier],
|
86
|
+
interchange_sender_id: segment[:interchange_sender_id],
|
87
|
+
interchange_receiver_id_qualifier: segment[:interchange_receiver_id_qualifier],
|
88
|
+
interchange_receiver_id: segment[:interchange_receiver_id],
|
89
|
+
repetition_separator: segment[:repetition_separator],
|
90
|
+
interchange_control_number: segment[:interchange_control_number].to_i,
|
91
|
+
acknowledgement_requested: segment[:acknowledgement_requested],
|
92
|
+
interchange_usage_indicator: segment[:interchange_usage_indicator],
|
93
|
+
component_element_separator: segment[:component_element_separator],
|
94
|
+
date_time: EDIDateTime.parse(date: segment[:interchange_date], time: segment[:interchange_time]).datetime_start,
|
95
|
+
)
|
96
|
+
end
|
97
|
+
|
98
|
+
def to_segments
|
99
|
+
segments = @edi_data.split(Codes::SEGMENT_TERMINATOR)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|