eancom 0.1.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.gitignore +187 -6
  4. data/.gitlab-ci.yml +27 -0
  5. data/.rspec_status +223 -0
  6. data/.rubocop.yml +2 -0
  7. data/.ruby-version +1 -0
  8. data/Gemfile +4 -2
  9. data/Gemfile.lock +87 -3
  10. data/bin/console +3 -2
  11. data/definitions/desadv/d01b.rb +205 -0
  12. data/definitions/desadv/d96a.rb +108 -73
  13. data/definitions/segments/alc.rb +236 -0
  14. data/definitions/segments/ali.rb +93 -0
  15. data/definitions/segments/bgm.rb +267 -0
  16. data/definitions/segments/cav.rb +122 -0
  17. data/definitions/segments/cci.rb +136 -0
  18. data/definitions/segments/cnt.rb +78 -0
  19. data/definitions/segments/cps.rb +76 -0
  20. data/definitions/segments/cux.rb +167 -0
  21. data/definitions/segments/dtm.rb +159 -0
  22. data/definitions/segments/ftx.rb +143 -0
  23. data/definitions/segments/imd.rb +356 -0
  24. data/definitions/segments/lin.rb +113 -0
  25. data/definitions/segments/loc.rb +89 -0
  26. data/definitions/segments/mea.rb +189 -0
  27. data/definitions/segments/moa.rb +144 -0
  28. data/definitions/segments/nad.rb +254 -0
  29. data/definitions/segments/pac.rb +250 -0
  30. data/definitions/segments/pgi.rb +148 -0
  31. data/definitions/segments/pia.rb +501 -0
  32. data/definitions/segments/pri.rb +188 -0
  33. data/definitions/segments/qty.rb +79 -0
  34. data/definitions/segments/rff.rb +166 -0
  35. data/definitions/segments/tax.rb +259 -0
  36. data/definitions/segments/tdt.rb +254 -0
  37. data/definitions/segments/una.rb +85 -0
  38. data/definitions/segments/unb.rb +284 -0
  39. data/definitions/segments/unh.rb +118 -0
  40. data/definitions/segments/uns.rb +40 -0
  41. data/definitions/segments/unt.rb +48 -0
  42. data/definitions/segments/unz.rb +48 -0
  43. data/definitions/slsrpt/d01b.rb +197 -0
  44. data/definitions/slsrpt/d96a.rb +194 -0
  45. data/eancom.gemspec +9 -5
  46. data/lib/eancom/definition.rb +1 -1
  47. data/lib/eancom/edifact/body.rb +63 -0
  48. data/lib/eancom/edifact/composite.rb +38 -0
  49. data/lib/eancom/edifact/data.rb +108 -0
  50. data/lib/eancom/edifact/document.rb +43 -11
  51. data/lib/eancom/edifact/document_element.rb +26 -0
  52. data/lib/eancom/edifact/footer.rb +6 -0
  53. data/lib/eancom/edifact/header.rb +15 -0
  54. data/lib/eancom/edifact/item.rb +40 -0
  55. data/lib/eancom/edifact/message.rb +24 -16
  56. data/lib/eancom/edifact/segment.rb +131 -12
  57. data/lib/eancom/edifact/segments/alc.rb +61 -0
  58. data/lib/eancom/edifact/segments/ali.rb +52 -0
  59. data/lib/eancom/edifact/segments/bgm.rb +45 -0
  60. data/lib/eancom/edifact/segments/cav.rb +47 -0
  61. data/lib/eancom/edifact/segments/cci.rb +53 -0
  62. data/lib/eancom/edifact/segments/cnt.rb +33 -0
  63. data/lib/eancom/edifact/segments/cps.rb +30 -0
  64. data/lib/eancom/edifact/segments/cux.rb +60 -0
  65. data/lib/eancom/edifact/segments/dtm.rb +43 -0
  66. data/lib/eancom/edifact/segments/ftx.rb +63 -0
  67. data/lib/eancom/edifact/segments/imd.rb +69 -0
  68. data/lib/eancom/edifact/segments/lin.rb +43 -0
  69. data/lib/eancom/edifact/segments/loc.rb +43 -0
  70. data/lib/eancom/edifact/segments/mea.rb +53 -0
  71. data/lib/eancom/edifact/segments/moa.rb +45 -0
  72. data/lib/eancom/edifact/segments/nad.rb +107 -0
  73. data/lib/eancom/edifact/segments/pac.rb +54 -0
  74. data/lib/eancom/edifact/segments/pgi.rb +45 -0
  75. data/lib/eancom/edifact/segments/pia.rb +107 -0
  76. data/lib/eancom/edifact/segments/pri.rb +54 -0
  77. data/lib/eancom/edifact/segments/qty.rb +40 -0
  78. data/lib/eancom/edifact/segments/rff.rb +41 -0
  79. data/lib/eancom/edifact/segments/tax.rb +72 -0
  80. data/lib/eancom/edifact/segments/tdt.rb +54 -0
  81. data/lib/eancom/edifact/segments/una.rb +51 -0
  82. data/lib/eancom/edifact/segments/unb.rb +66 -0
  83. data/lib/eancom/edifact/segments/unh.rb +46 -0
  84. data/lib/eancom/edifact/segments/uns.rb +29 -0
  85. data/lib/eancom/edifact/segments/unt.rb +28 -0
  86. data/lib/eancom/edifact/segments/unz.rb +28 -0
  87. data/lib/eancom/edifact/structure.rb +91 -0
  88. data/lib/eancom/edifact.rb +45 -12
  89. data/lib/eancom/factory.rb +8 -7
  90. data/lib/eancom/parser/document.rb +68 -0
  91. data/lib/eancom/parser/segment.rb +71 -0
  92. data/lib/eancom/parser.rb +7 -0
  93. data/lib/eancom/version.rb +1 -1
  94. data/lib/eancom.rb +59 -16
  95. metadata +138 -5
  96. data/lib/eancom/edifact/element.rb +0 -16
  97. data/lib/eancom/edifact/envelope.rb +0 -24
@@ -0,0 +1,356 @@
1
+ tag = 'IMD'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::IMD)
3
+
4
+ structure = Eancom::Edifact::Structure.new(tag: tag)
5
+ #==============================================================================
6
+ # Tag #
7
+ #==============================================================================
8
+ tag = Eancom::Edifact::Composite.new()
9
+ data = Eancom::Edifact::Data.new(
10
+ type: String,
11
+ length: 3,
12
+ dictionary: nil,
13
+ description: "Message Header",
14
+ required: true
15
+ )
16
+ tag.add(:tag, data)
17
+
18
+ structure << tag
19
+ #==============================================================================
20
+ # Description Format Code #
21
+ #==============================================================================
22
+ description_format_code = Eancom::Edifact::Composite.new()
23
+
24
+ data = Eancom::Edifact::Data.new(
25
+ type: String,
26
+ length: 1..3,
27
+ dictionary: {
28
+ 'C' => {
29
+ description: 'Code (from industry code list)',
30
+ identifier: 'code'
31
+ },
32
+ 'D' => {
33
+ description: 'Free-from price look up',
34
+ identifier: 'free_form_price_look_up'
35
+ },
36
+ 'E' => {
37
+ description: 'Free-form short description',
38
+ identifier: 'free_form_short_description'
39
+ },
40
+ 'F' => {
41
+ description: 'Free-form',
42
+ identifier: 'free_form'
43
+ },
44
+ 'S' => {
45
+ description: 'Structured (from industry code list)',
46
+ identifier: 'structured'
47
+ },
48
+ 'B' => {
49
+ description: 'Code and text',
50
+ identifier: 'code_and_text'
51
+ }
52
+ },
53
+ description: "Description format code",
54
+ required: true
55
+ )
56
+ description_format_code.add(:description_format_code, data)
57
+
58
+ structure << description_format_code
59
+ #==============================================================================
60
+ # Item Characteristic #
61
+ #==============================================================================
62
+ item_characteristic = Eancom::Edifact::Composite.new()
63
+
64
+ item_characteristic_code = Eancom::Edifact::Data.new(
65
+ type: String,
66
+ length: 1..3,
67
+ dictionary: {
68
+ '2' => {
69
+ description: 'General product form',
70
+ identifier: 'general_product_form'
71
+ },
72
+ '4' => {
73
+ description: 'Finish',
74
+ identifier: 'finish'
75
+ },
76
+ '35' => {
77
+ description: 'Colour',
78
+ identifier: 'colour'
79
+ },
80
+ '44' => {
81
+ description: 'Further identifying characteristic',
82
+ identifier: 'further_identifying_characteristic'
83
+ },
84
+ '98' => {
85
+ description: 'Size',
86
+ identifier: 'Size'
87
+ },
88
+ 'ANM' => {
89
+ description: 'Article Name',
90
+ identifier: 'article_name'
91
+ },
92
+ 'BRN' => {
93
+ description: 'Brand Name',
94
+ identifier: 'brand_name'
95
+ },
96
+ 'DSC' => {
97
+ description: 'Description',
98
+ identifier: 'description'
99
+ },
100
+ 'FN' => {
101
+ description: 'Function Name',
102
+ identifier: 'function_name'
103
+ },
104
+ 'IN' => {
105
+ description: 'Invoice name',
106
+ identifier: 'invoice_name'
107
+ },
108
+ 'PR' => {
109
+ description: 'Product range',
110
+ identifier: 'product_range'
111
+ },
112
+ 'SB' => {
113
+ description: 'Subbrand',
114
+ identifier: 'subbrand'
115
+ },
116
+ 'TPE' => {
117
+ description: 'Article Type',
118
+ identifier: 'article_type'
119
+ },
120
+ 'STE' => {
121
+ description: 'Style',
122
+ identifier: 'style'
123
+ },
124
+ 'XX1' => {
125
+ description: 'Collar Type',
126
+ identifier: 'collar_type'
127
+ },
128
+ 'XX3' => {
129
+ description: 'Colthing Cut',
130
+ identifier: 'colthing_cut'
131
+ },
132
+ 'XX4' => {
133
+ description: 'Non marked traded item components',
134
+ identifier: 'non_marked_traded_item_components'
135
+ },
136
+ 'XX5' => {
137
+ description: 'Campaign name',
138
+ identifier: 'campaign_name'
139
+ },
140
+ 'XX6' => {
141
+ description: 'Season name',
142
+ identifier: 'season_name'
143
+ },
144
+ },
145
+ description: "Item characteristic code",
146
+ required: true
147
+ )
148
+ item_characteristic.add(:item_characteristic_code, item_characteristic_code)
149
+
150
+ code_list_identification_code = Eancom::Edifact::Data.new(
151
+ type: String,
152
+ length: 0..17,
153
+ description: "Code list identification code",
154
+ required: false
155
+ )
156
+ item_characteristic.add(:code_list_identification_code, code_list_identification_code)
157
+
158
+ code_list_responsible_agency_code = Eancom::Edifact::Data.new(
159
+ type: String,
160
+ length: 0..3,
161
+ dictionary: {
162
+ '9' => {
163
+ description: 'GS1',
164
+ identifier: 'gs1'
165
+ }
166
+ },
167
+ description: "Code list responsible agency code",
168
+ required: false
169
+ )
170
+ item_characteristic.add(:code_list_responsible_agency_code, code_list_responsible_agency_code)
171
+
172
+ structure << item_characteristic
173
+ #==============================================================================
174
+ # Item Description #
175
+ #==============================================================================
176
+ item_description = Eancom::Edifact::Composite.new()
177
+
178
+ data = Eancom::Edifact::Data.new(
179
+ type: String,
180
+ length: 0..17,
181
+ dictionary: {
182
+ 'ORU' => {
183
+ description: 'Ordering Unit',
184
+ identifier: 'ordering_unit'
185
+ },
186
+ 'NO' => {
187
+ description: 'Not an ordering Unit',
188
+ identifier: 'not_an_ordering_unit'
189
+ },
190
+ 'BU' => {
191
+ description: 'Base unit',
192
+ identifier: 'base_unit'
193
+ },
194
+ 'NBU' => {
195
+ description: 'Not a Base unit',
196
+ identifier: 'not_a_base_unit'
197
+ },
198
+ 'CU' => {
199
+ description: 'Consumer unit (GS1 Permanent Code)',
200
+ identifier: 'consumer_unit'
201
+ },
202
+ 'NCU' => {
203
+ description: 'Not a Consumer unit (GS1 Permanent Code)',
204
+ identifier: 'not_a_consumer_unit'
205
+ },
206
+ 'DU' => {
207
+ description: 'Despatch unit (GS1 Permanent Code)',
208
+ identifier: 'despatch_unit'
209
+ },
210
+ 'NDU' => {
211
+ description: 'Not a Despatch unit (GS1 Permanent Code)',
212
+ identifier: 'not_a_despatch_unit'
213
+ },
214
+ 'IN' => {
215
+ description: 'Invoicing unit',
216
+ identifier: 'invoicing_unit'
217
+ },
218
+ 'NIN' => {
219
+ description: 'Not a Invoicing unit',
220
+ identifier: 'not_a_invoicing_unit'
221
+ },
222
+ 'TU' => {
223
+ description: 'Traded unit (GS1 Permanent Code)',
224
+ identifier: 'traded_unit'
225
+ },
226
+ 'VQ' => {
227
+ description: 'Variable quantity product (GS1 Permanent Code)',
228
+ identifier: 'variable_quantity_product'
229
+ },
230
+ 'NVQ' => {
231
+ description: 'Not a Variable quantity product (GS1 Permanent Code)',
232
+ identifier: 'not_a_variable_quantity_product'
233
+ },
234
+ 'DST' => {
235
+ description: 'Display stand',
236
+ identifier: 'display_stand'
237
+ },
238
+ 'SU' => {
239
+ description: 'Smallest unit',
240
+ identifier: 'smallest_unit'
241
+ },
242
+ 'CA' => {
243
+ description: 'Case',
244
+ identifier: 'case'
245
+ },
246
+ 'DSP' => {
247
+ description: 'Display shipper',
248
+ identifier: 'display_shipper'
249
+ },
250
+ 'MM' => {
251
+ description: 'Mixed module',
252
+ identifier: 'mixed_module'
253
+ },
254
+ 'MP' => {
255
+ description: 'Multipack',
256
+ identifier: 'multipack'
257
+ },
258
+ 'PIP' => {
259
+ description: 'Packer or inner pack',
260
+ identifier: 'packer_or_inner_pack'
261
+ },
262
+ 'PAL' => {
263
+ description: 'Pallet',
264
+ identifier: 'pallet'
265
+ },
266
+ 'PPK' => {
267
+ description: 'Prepack',
268
+ identifier: 'prepack'
269
+ },
270
+ 'PAS' => {
271
+ description: 'Prepack assortment',
272
+ identifier: 'prepack_assortment'
273
+ },
274
+ 'SPK' => {
275
+ description: 'Setpack',
276
+ identifier: 'setpack'
277
+ },
278
+ 'NOT' => {
279
+ description: 'Not, not an NOS item (GS1 Permanent Code)',
280
+ identifier: 'not_not_an_nos_item'
281
+ },
282
+ '*' => {
283
+ description: 'N/A',
284
+ identifier: 'na'
285
+ }
286
+ },
287
+ description: 'Item description code',
288
+ required: false
289
+ )
290
+ item_description.add(:item_description_code, data)
291
+
292
+ code_list_identification_code_1 = Eancom::Edifact::Data.new(
293
+ type: String,
294
+ length: 0..17,
295
+ description: 'Code list identification code',
296
+ required: false
297
+ )
298
+ item_description.add(:code_list_identification_code_1, code_list_identification_code_1)
299
+
300
+ code_list_responsible_agency_code_1 = Eancom::Edifact::Data.new(
301
+ type: String,
302
+ length: 0..3,
303
+ dictionary: {
304
+ '9' => {
305
+ description: 'GS1',
306
+ identifier: 'gs1'
307
+ },
308
+ '91' => {
309
+ description: "Assigned by supplier or supplier's agent",
310
+ identifier: 'assigned_by_supplier_or_suppliers_agent'
311
+ },
312
+ '92' => {
313
+ description: "Assigned by buyer or buyer's agent",
314
+ identifier: "assigned_by_buyer_or_buyers_agent"
315
+ }
316
+ },
317
+ description: 'Code list responsible agency code',
318
+ required: false
319
+ )
320
+ item_description.add(:code_list_responsible_agency_code_1, code_list_responsible_agency_code_1)
321
+
322
+ description = Eancom::Edifact::Data.new(
323
+ type: String,
324
+ length: 0..256,
325
+ description: 'Item description',
326
+ required: false
327
+ )
328
+ item_description.add(:item_description_1, description)
329
+ item_description.add(:item_description_2, description)
330
+
331
+ language_name_code = Eancom::Edifact::Data.new(
332
+ type: String,
333
+ length: 0..3,
334
+ description: 'Language name code',
335
+ required: false
336
+ )
337
+ item_description.add(:language_name_code, language_name_code)
338
+
339
+ structure << item_description
340
+ #==============================================================================
341
+ # Surface or Layer Code #
342
+ #==============================================================================
343
+ surface_or_layer_code = Eancom::Edifact::Composite.new()
344
+
345
+ data = Eancom::Edifact::Data.new(
346
+ type: String,
347
+ length: 0..3,
348
+ dictionary: nil,
349
+ description: "Surface or layer code",
350
+ required: false
351
+ )
352
+ surface_or_layer_code.add(:surface_or_layer_code, data)
353
+
354
+ structure << surface_or_layer_code
355
+ #==============================================================================
356
+ Eancom.register_structure(tag: 'IMD', structure: structure)
@@ -0,0 +1,113 @@
1
+ tag = 'LIN'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::LIN)
3
+
4
+ structure = Eancom::Edifact::Structure.new(tag: tag)
5
+ #==============================================================================
6
+ # Tag #
7
+ #==============================================================================
8
+ tag = Eancom::Edifact::Composite.new()
9
+ data = Eancom::Edifact::Data.new(
10
+ type: String,
11
+ length: 3,
12
+ dictionary: nil,
13
+ description: "Message Header",
14
+ required: true
15
+ )
16
+ tag.add(:tag, data)
17
+
18
+ structure << tag
19
+ #==============================================================================
20
+ # Line item identifier #
21
+ #==============================================================================
22
+ line_item_identifier = Eancom::Edifact::Composite.new()
23
+
24
+ data = Eancom::Edifact::Data.new(
25
+ type: String,
26
+ length: 1..6,
27
+ dictionary: nil,
28
+ description: "Application generated number of the item lines within the message",
29
+ required: true
30
+ )
31
+ line_item_identifier.add(:line_item_identifier_1, data)
32
+
33
+ structure << line_item_identifier
34
+ #==============================================================================
35
+ # Action request/notification description code #
36
+ #==============================================================================
37
+ action_request_notification_description_code = Eancom::Edifact::Composite.new()
38
+
39
+ data = Eancom::Edifact::Data.new(
40
+ type: String,
41
+ length: 0..3,
42
+ dictionary: nil,
43
+ description: 'Action request/notification description code',
44
+ required: false
45
+ )
46
+ action_request_notification_description_code.add(:action_request_notification_description_code, data)
47
+
48
+ structure << action_request_notification_description_code
49
+ #==============================================================================
50
+ # Item Number Identification #
51
+ #==============================================================================
52
+ item_number_identification = Eancom::Edifact::Composite.new()
53
+
54
+ data = Eancom::Edifact::Data.new(
55
+ type: String,
56
+ length: 1..35,
57
+ dictionary: nil,
58
+ description: 'Item identifier',
59
+ required: true
60
+ )
61
+ item_number_identification.add(:item_identifier, data)
62
+
63
+ data = Eancom::Edifact::Data.new(
64
+ type: String,
65
+ length: 1..3,
66
+ dictionary: {
67
+ 'SRV' => {
68
+ description: 'GS1 Global Trade Item Number',
69
+ identifier: 'GS1'
70
+ },
71
+ 'EN' => {
72
+ description: 'International Article Numbering Association (EAN)',
73
+ identifier: 'ean'
74
+ }
75
+ },
76
+ description: 'Item identifier',
77
+ required: true
78
+ )
79
+ item_number_identification.add(:item_type_identification_code, data)
80
+
81
+ structure << item_number_identification
82
+ #==============================================================================
83
+ # Sub-Line information #
84
+ #==============================================================================
85
+ sub_line_information = Eancom::Edifact::Composite.new()
86
+
87
+ data = Eancom::Edifact::Data.new(
88
+ type: String,
89
+ length: 1..3,
90
+ dictionary: {
91
+ '1' => {
92
+ description: 'Sub-line information',
93
+ identifier: 'sub_line_information',
94
+ }
95
+ },
96
+ description: 'Sub-line indicator code',
97
+ required: false
98
+ )
99
+ sub_line_information.add(:sub_line_indicator_code, data)
100
+
101
+ data = Eancom::Edifact::Data.new(
102
+ type: String,
103
+ length: 1..6,
104
+ dictionary: nil,
105
+ description: 'Line item identifier',
106
+ required: false
107
+ )
108
+ sub_line_information.add(:line_item_identifier_2, data)
109
+
110
+
111
+ structure << sub_line_information
112
+ #==============================================================================
113
+ Eancom.register_structure(tag: 'LIN', structure: structure)
@@ -0,0 +1,89 @@
1
+ tag = 'LOC'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::LOC)
3
+
4
+ structure = Eancom::Edifact::Structure.new(tag: tag)
5
+ #==============================================================================
6
+ # Tag #
7
+ #==============================================================================
8
+ tag = Eancom::Edifact::Composite.new()
9
+ data = Eancom::Edifact::Data.new(
10
+ type: String,
11
+ length: 3,
12
+ dictionary: nil,
13
+ description: "Message Header",
14
+ required: true
15
+ )
16
+ tag.add(:tag, data)
17
+
18
+ structure << tag
19
+ #==============================================================================
20
+ # Location Function Qualifier #
21
+ #==============================================================================
22
+ location_function_qualifier = Eancom::Edifact::Composite.new()
23
+
24
+ data = Eancom::Edifact::Data.new(
25
+ type: String,
26
+ length: 3,
27
+ dictionary: {
28
+ '7' => {
29
+ description: 'Place of Delivery',
30
+ identifier: 'place_of_delivery'
31
+ },
32
+ '150' => {
33
+ description: 'Container stack position',
34
+ identifier: 'container_stack_position'
35
+ },
36
+ '162' => {
37
+ description: 'Place or location of sale',
38
+ identifier: 'place_or_location_of_sale'
39
+ },
40
+ },
41
+ description: "Location Function Qualifier",
42
+ required: true
43
+ )
44
+ location_function_qualifier.add(:location_function_qualifier, data)
45
+ structure << location_function_qualifier
46
+ #==============================================================================
47
+ # Location Identification #
48
+ #==============================================================================
49
+ location_identification = Eancom::Edifact::Composite.new()
50
+
51
+ data = Eancom::Edifact::Data.new(
52
+ type: String,
53
+ length: 1..25,
54
+ dictionary: nil,
55
+ description: "Location Name Code",
56
+ required: true
57
+ )
58
+ location_identification.add(:location_name_code, data)
59
+
60
+ data = Eancom::Edifact::Data.new(
61
+ type: String,
62
+ length: 0..17,
63
+ dictionary: nil,
64
+ description: "Code list identification code",
65
+ required: false
66
+ )
67
+ location_identification.add(:code_list_identification_code, data)
68
+
69
+ data = Eancom::Edifact::Data.new(
70
+ type: String,
71
+ length: 0..3,
72
+ dictionary: {
73
+ '9' => {
74
+ description: 'GS1',
75
+ identifier: 'gs1'
76
+ },
77
+ '92' => {
78
+ description: 'Assigned by buyer or buyers agent',
79
+ identifier: 'assigned_by_buyer_or_buyers_agent'
80
+ },
81
+ },
82
+ description: "Code list responsible agency code",
83
+ required: false
84
+ )
85
+ location_identification.add(:code_list_responsible_agancy_code, data)
86
+
87
+ structure << location_identification
88
+ #==============================================================================
89
+ Eancom.register_structure(tag: 'LOC', structure: structure)