eancom 0.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +190 -5
  3. data/.gitlab-ci.yml +25 -0
  4. data/.ruby-version +1 -0
  5. data/Gemfile.lock +22 -18
  6. data/README.md +46 -0
  7. data/bin/console +3 -2
  8. data/definitions/desadv/d01b.rb +251 -0
  9. data/definitions/desadv/d96a.rb +208 -87
  10. data/definitions/invoic/d01b.rb +559 -0
  11. data/definitions/invoic/d96a.rb +389 -0
  12. data/definitions/invrpt/d01b.rb +134 -0
  13. data/definitions/invrpt/d96a.rb +125 -0
  14. data/definitions/orders/d01b.rb +182 -0
  15. data/definitions/orders/d96b.rb +198 -0
  16. data/definitions/ordrsp/d01b.rb +251 -0
  17. data/definitions/ordrsp/d96b.rb +226 -0
  18. data/definitions/pricat/d01b.rb +225 -0
  19. data/definitions/pricat/d96b.rb +207 -0
  20. data/definitions/retann/d01b.rb +172 -0
  21. data/definitions/retann/d96b.rb +221 -0
  22. data/definitions/segments/ajt.rb +47 -0
  23. data/definitions/segments/alc.rb +328 -0
  24. data/definitions/segments/ali.rb +93 -0
  25. data/definitions/segments/bgm.rb +395 -0
  26. data/definitions/segments/cav.rb +122 -0
  27. data/definitions/segments/cci.rb +136 -0
  28. data/definitions/segments/cdi.rb +39 -0
  29. data/definitions/segments/cnt.rb +82 -0
  30. data/definitions/segments/cps.rb +76 -0
  31. data/definitions/segments/cta.rb +89 -0
  32. data/definitions/segments/cux.rb +174 -0
  33. data/definitions/segments/dgs.rb +34 -0
  34. data/definitions/segments/doc.rb +45 -0
  35. data/definitions/segments/dtm.rb +243 -0
  36. data/definitions/segments/efi.rb +67 -0
  37. data/definitions/segments/eqd.rb +37 -0
  38. data/definitions/segments/ftx.rb +165 -0
  39. data/definitions/segments/gin.rb +113 -0
  40. data/definitions/segments/imd.rb +360 -0
  41. data/definitions/segments/inv.rb +94 -0
  42. data/definitions/segments/lin.rb +133 -0
  43. data/definitions/segments/loc.rb +137 -0
  44. data/definitions/segments/mea.rb +189 -0
  45. data/definitions/segments/moa.rb +228 -0
  46. data/definitions/segments/nad.rb +314 -0
  47. data/definitions/segments/pac.rb +262 -0
  48. data/definitions/segments/pat.rb +171 -0
  49. data/definitions/segments/pcd.rb +72 -0
  50. data/definitions/segments/pci.rb +110 -0
  51. data/definitions/segments/pgi.rb +152 -0
  52. data/definitions/segments/pia.rb +501 -0
  53. data/definitions/segments/pri.rb +208 -0
  54. data/definitions/segments/qty.rb +293 -0
  55. data/definitions/segments/rff.rb +210 -0
  56. data/definitions/segments/rte.rb +52 -0
  57. data/definitions/segments/tax.rb +266 -0
  58. data/definitions/segments/tdt.rb +278 -0
  59. data/definitions/segments/tod.rb +64 -0
  60. data/definitions/segments/tru.rb +34 -0
  61. data/definitions/segments/una.rb +85 -0
  62. data/definitions/segments/unb.rb +284 -0
  63. data/definitions/segments/unh.rb +183 -0
  64. data/definitions/segments/uns.rb +40 -0
  65. data/definitions/segments/unt.rb +48 -0
  66. data/definitions/segments/unz.rb +48 -0
  67. data/definitions/slsrpt/d01b.rb +206 -0
  68. data/definitions/slsrpt/d96a.rb +199 -0
  69. data/eancom.gemspec +2 -1
  70. data/lib/eancom.rb +61 -16
  71. data/lib/eancom/definition.rb +1 -1
  72. data/lib/eancom/edifact.rb +60 -13
  73. data/lib/eancom/edifact/body.rb +63 -0
  74. data/lib/eancom/edifact/composite.rb +38 -0
  75. data/lib/eancom/edifact/data.rb +108 -0
  76. data/lib/eancom/edifact/document.rb +43 -11
  77. data/lib/eancom/edifact/document_element.rb +26 -0
  78. data/lib/eancom/edifact/footer.rb +7 -0
  79. data/lib/eancom/edifact/header.rb +15 -0
  80. data/lib/eancom/edifact/item.rb +40 -0
  81. data/lib/eancom/edifact/message.rb +24 -16
  82. data/lib/eancom/edifact/segment.rb +131 -12
  83. data/lib/eancom/edifact/segments/ajt.rb +32 -0
  84. data/lib/eancom/edifact/segments/alc.rb +61 -0
  85. data/lib/eancom/edifact/segments/ali.rb +50 -0
  86. data/lib/eancom/edifact/segments/bgm.rb +46 -0
  87. data/lib/eancom/edifact/segments/cav.rb +47 -0
  88. data/lib/eancom/edifact/segments/cci.rb +53 -0
  89. data/lib/eancom/edifact/segments/cdi.rb +30 -0
  90. data/lib/eancom/edifact/segments/cnt.rb +40 -0
  91. data/lib/eancom/edifact/segments/cps.rb +33 -0
  92. data/lib/eancom/edifact/segments/cta.rb +30 -0
  93. data/lib/eancom/edifact/segments/cux.rb +60 -0
  94. data/lib/eancom/edifact/segments/dgs.rb +31 -0
  95. data/lib/eancom/edifact/segments/doc.rb +30 -0
  96. data/lib/eancom/edifact/segments/dtm.rb +47 -0
  97. data/lib/eancom/edifact/segments/efi.rb +38 -0
  98. data/lib/eancom/edifact/segments/eqd.rb +30 -0
  99. data/lib/eancom/edifact/segments/ftx.rb +63 -0
  100. data/lib/eancom/edifact/segments/gin.rb +45 -0
  101. data/lib/eancom/edifact/segments/imd.rb +69 -0
  102. data/lib/eancom/edifact/segments/inv.rb +43 -0
  103. data/lib/eancom/edifact/segments/lin.rb +47 -0
  104. data/lib/eancom/edifact/segments/loc.rb +46 -0
  105. data/lib/eancom/edifact/segments/mea.rb +54 -0
  106. data/lib/eancom/edifact/segments/moa.rb +45 -0
  107. data/lib/eancom/edifact/segments/nad.rb +112 -0
  108. data/lib/eancom/edifact/segments/pac.rb +56 -0
  109. data/lib/eancom/edifact/segments/pat.rb +37 -0
  110. data/lib/eancom/edifact/segments/pcd.rb +33 -0
  111. data/lib/eancom/edifact/segments/pci.rb +40 -0
  112. data/lib/eancom/edifact/segments/pgi.rb +45 -0
  113. data/lib/eancom/edifact/segments/pia.rb +108 -0
  114. data/lib/eancom/edifact/segments/pri.rb +53 -0
  115. data/lib/eancom/edifact/segments/qty.rb +44 -0
  116. data/lib/eancom/edifact/segments/rff.rb +47 -0
  117. data/lib/eancom/edifact/segments/rte.rb +33 -0
  118. data/lib/eancom/edifact/segments/tax.rb +78 -0
  119. data/lib/eancom/edifact/segments/tdt.rb +57 -0
  120. data/lib/eancom/edifact/segments/tod.rb +33 -0
  121. data/lib/eancom/edifact/segments/tru.rb +31 -0
  122. data/lib/eancom/edifact/segments/una.rb +52 -0
  123. data/lib/eancom/edifact/segments/unb.rb +68 -0
  124. data/lib/eancom/edifact/segments/unh.rb +50 -0
  125. data/lib/eancom/edifact/segments/uns.rb +32 -0
  126. data/lib/eancom/edifact/segments/unt.rb +28 -0
  127. data/lib/eancom/edifact/segments/unz.rb +28 -0
  128. data/lib/eancom/edifact/structure.rb +90 -0
  129. data/lib/eancom/factory.rb +9 -8
  130. data/lib/eancom/parser.rb +7 -0
  131. data/lib/eancom/parser/document.rb +60 -0
  132. data/lib/eancom/parser/segment.rb +71 -0
  133. data/lib/eancom/version.rb +1 -1
  134. data/pricat.json +1 -0
  135. metadata +141 -9
  136. data/lib/eancom/edifact/element.rb +0 -16
  137. data/lib/eancom/edifact/envelope.rb +0 -24
@@ -0,0 +1,284 @@
1
+ tag = 'UNB'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::UNB)
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: 1..3,
12
+ dictionary: nil,
13
+ description: "Interchange Header",
14
+ required: true
15
+ )
16
+ tag.add(:tag, data)
17
+
18
+ structure << tag
19
+
20
+ #==============================================================================
21
+ # Syntax identifier #
22
+ #==============================================================================
23
+ syntax_identifier = Eancom::Edifact::Composite.new()
24
+
25
+ syntax_dictionary = {
26
+ 'UNOA' => {
27
+ description: 'UN/ECE level A'
28
+ },
29
+ 'UNOB' => {
30
+ description: 'UN/ECE level B'
31
+ },
32
+ 'UNOC' => {
33
+ description: 'UN/ECE level C'
34
+ },
35
+ 'UNOD' => {
36
+ description: 'UN/ECE level D'
37
+ },
38
+ 'UNOE' => {
39
+ description: 'UN/ECE level E'
40
+ },
41
+ 'UNOF' => {
42
+ description: 'UN/ECE level F'
43
+ },
44
+ }
45
+ data = Eancom::Edifact::Data.new(
46
+ type: String,
47
+ length: 1..4,
48
+ dictionary: syntax_dictionary,
49
+ description: "Syntax identifier.",
50
+ required: true
51
+ )
52
+ syntax_identifier.add(:syntax_identifier, data)
53
+
54
+ syntax_version_dict = {
55
+ '2' => {
56
+ description: 'Version 2'
57
+ },
58
+ '3' => {
59
+ description: 'Version 3'
60
+ }
61
+ }
62
+ data = Eancom::Edifact::Data.new(
63
+ type: String,
64
+ length: 1,
65
+ dictionary: syntax_version_dict,
66
+ description: "Syntax version number.",
67
+ required: true
68
+ )
69
+ syntax_identifier.add(:syntax_version_number, data)
70
+
71
+ structure << syntax_identifier
72
+
73
+ #==============================================================================
74
+ # Interchange Sender #
75
+ #==============================================================================
76
+ interchange_sender = Eancom::Edifact::Composite.new()
77
+
78
+ data = Eancom::Edifact::Data.new(
79
+ type: String,
80
+ length: 1..35,
81
+ dictionary: nil,
82
+ description: "Interchange sender identification (GLN).",
83
+ required: true
84
+ )
85
+ interchange_sender.add(:interchange_sender_identification, data)
86
+
87
+ data = Eancom::Edifact::Data.new(
88
+ type: String,
89
+ length: 1..4,
90
+ dictionary: nil,
91
+ description: "Identification code qualifier (14 = GS1).",
92
+ required: true
93
+ )
94
+ interchange_sender.add(:sender_identifiction_code_qualifier, data)
95
+
96
+ data = Eancom::Edifact::Data.new(
97
+ type: String,
98
+ length: 1..35,
99
+ dictionary: nil,
100
+ description: "Interchange sender internal identification.",
101
+ required: false
102
+ )
103
+ interchange_sender.add(:interchange_sender_internal_identification, data)
104
+
105
+ structure << interchange_sender
106
+
107
+ #==============================================================================
108
+ # Interchange Recipient #
109
+ #==============================================================================
110
+ interchange_recipient = Eancom::Edifact::Composite.new
111
+
112
+ data = Eancom::Edifact::Data.new(
113
+ type: String,
114
+ length: 1..35,
115
+ dictionary: nil,
116
+ description: "Interchange recipient identification (GLN).",
117
+ required: true
118
+ )
119
+ interchange_recipient.add(:interchange_recipient_identification, data)
120
+
121
+ data = Eancom::Edifact::Data.new(
122
+ type: String,
123
+ length: 1..4,
124
+ dictionary: nil,
125
+ description: "Identification code qualifier (14 = GS1).",
126
+ required: true
127
+ )
128
+ interchange_recipient.add(:recipient_identifiction_code_qualifier, data)
129
+
130
+ data = Eancom::Edifact::Data.new(
131
+ type: String,
132
+ length: 1..35,
133
+ dictionary: nil,
134
+ description: "Interchange sender internal identification",
135
+ required: false
136
+ )
137
+ interchange_recipient.add(:interchange_recipient_internal_identification, data)
138
+
139
+ structure << interchange_recipient
140
+
141
+ #==============================================================================
142
+ # Date and Time of Preparation #
143
+ #==============================================================================
144
+ date_and_time_of_preparation = Eancom::Edifact::Composite.new
145
+
146
+ data = Eancom::Edifact::Data.new(
147
+ type: String,
148
+ length: 6..8,
149
+ dictionary: nil,
150
+ description: "Date (YYMMDD)",
151
+ required: true
152
+ )
153
+ date_and_time_of_preparation.add(:date, data)
154
+
155
+ data = Eancom::Edifact::Data.new(
156
+ type: String,
157
+ length: 1..4,
158
+ dictionary: nil,
159
+ description: "Time (HHMM)",
160
+ required: true
161
+ )
162
+ date_and_time_of_preparation.add(:time, data)
163
+
164
+ structure << date_and_time_of_preparation
165
+ #==============================================================================
166
+ # Interchange control reference #
167
+ #==============================================================================
168
+ interchange_control_reference = Eancom::Edifact::Composite.new
169
+
170
+ data = Eancom::Edifact::Data.new(
171
+ type: String,
172
+ length: 1..14,
173
+ dictionary: nil,
174
+ description: "Interchange control reference.",
175
+ required: true
176
+ )
177
+ interchange_control_reference.add(:interchange_control_reference, data)
178
+
179
+ structure << interchange_control_reference
180
+ #==============================================================================
181
+ # Recipient Reference / Password Details #
182
+ #==============================================================================
183
+ recipient_reference = Eancom::Edifact::Composite.new
184
+
185
+ data = Eancom::Edifact::Data.new(
186
+ type: String,
187
+ length: 1..14,
188
+ dictionary: nil,
189
+ description: "Recipient reference/password.",
190
+ required: true
191
+ )
192
+ recipient_reference.add(:recipient_reference, data)
193
+
194
+ data = Eancom::Edifact::Data.new(
195
+ type: String,
196
+ length: 1..2,
197
+ dictionary: nil,
198
+ description: "Recipient reference/password qualifier.",
199
+ required: false
200
+ )
201
+ recipient_reference.add(:recipient_reference_qualifier, data)
202
+
203
+ structure << recipient_reference
204
+ #==============================================================================
205
+ # Application Reference #
206
+ #==============================================================================
207
+ application_reference = Eancom::Edifact::Composite.new
208
+
209
+ data = Eancom::Edifact::Data.new(
210
+ type: String,
211
+ length: 1..14,
212
+ dictionary: nil,
213
+ description: "Application reference.",
214
+ required: false
215
+ )
216
+ application_reference.add(:application_reference, data)
217
+
218
+ structure << application_reference
219
+ #==============================================================================
220
+ # Processing priority code #
221
+ #==============================================================================
222
+ processing_priority_code = Eancom::Edifact::Composite.new
223
+
224
+ data = Eancom::Edifact::Data.new(
225
+ type: String,
226
+ length: 1,
227
+ dictionary: { 'A' => { description: 'A = Highest priority' }},
228
+ description: "Processing priority code.",
229
+ required: false
230
+ )
231
+ processing_priority_code.add(:processing_priority_code, data)
232
+
233
+ structure << processing_priority_code
234
+ #==============================================================================
235
+ # Acknowledgement request #
236
+ #==============================================================================
237
+ acknowledgement_request = Eancom::Edifact::Composite.new
238
+
239
+ data = Eancom::Edifact::Data.new(
240
+ type: String,
241
+ length: 1,
242
+ dictionary: { '1' => { description: '1 = Requested' }},
243
+ description: "Acknowledgement request.",
244
+ required: false
245
+ )
246
+ acknowledgement_request.add(:acknowledgement_request, data)
247
+
248
+ structure << acknowledgement_request
249
+ #==============================================================================
250
+ # Interchange Agreement Identifier #
251
+ #==============================================================================
252
+ interchange_agreement_identifier = Eancom::Edifact::Composite.new
253
+
254
+ data = Eancom::Edifact::Data.new(
255
+ type: String,
256
+ length: 1..35,
257
+ dictionary: nil ,
258
+ description: "Interchange agreement identifier.",
259
+ required: false
260
+ )
261
+ interchange_agreement_identifier.add(:interchange_agreement_identifier, data)
262
+
263
+ structure << interchange_agreement_identifier
264
+ #==============================================================================
265
+ # Test Indicator #
266
+ #==============================================================================
267
+ test_indicator = Eancom::Edifact::Composite.new
268
+
269
+ data = Eancom::Edifact::Data.new(
270
+ type: String,
271
+ length: 1..35,
272
+ dictionary: {
273
+ '0' => { description: '0 = interchange is not a test'},
274
+ '1' => { description: '1 = interchange is a test'}
275
+ },
276
+ description: "Test indicator.",
277
+ required: false
278
+ )
279
+ test_indicator.add(:test_indicator, data)
280
+
281
+ structure << test_indicator
282
+ #==============================================================================
283
+ Eancom.register_structure(tag: 'UNB', structure: structure)
284
+
@@ -0,0 +1,183 @@
1
+ tag = 'UNH'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::UNH)
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
+ # Message reference number #
21
+ #==============================================================================
22
+ message_reference_number = Eancom::Edifact::Composite.new()
23
+ data = Eancom::Edifact::Data.new(
24
+ type: String,
25
+ length: 1..14,
26
+ dictionary: nil,
27
+ description: 'Unique reference number assigned to a message within an interchange by the sender. Same reference number as in DE 0062 of the UNT segment of the message.',
28
+ required: true
29
+ )
30
+ message_reference_number.add(:message_reference_number, data)
31
+
32
+ structure << message_reference_number
33
+ #==============================================================================
34
+ # Message Identifier #
35
+ #==============================================================================
36
+ message_identifier = Eancom::Edifact::Composite.new()
37
+
38
+ data = Eancom::Edifact::Data.new(
39
+ type: String,
40
+ length: 1..6,
41
+ dictionary: {
42
+ 'ORDERS' => {
43
+ description: 'Purchase order message'
44
+ },
45
+ 'SLSRPT' => {
46
+ description: 'Sales data report message'
47
+ },
48
+ 'DESADV' => {
49
+ description: 'Despatch advice message'
50
+ },
51
+ 'INVRPT' => {
52
+ description: 'Inventory report message'
53
+ },
54
+ 'PRICAT' => {
55
+ description: 'Price catalogue message'
56
+ },
57
+ 'ORDRSP' => {
58
+ description: 'Orders report message'
59
+ },
60
+ 'INVOIC' => {
61
+ description: 'Invoice message'
62
+ },
63
+ 'RETANN' => {
64
+ description: 'Announcement for returns message'
65
+ }
66
+ },
67
+ description: 'Message Type',
68
+ required: true
69
+ )
70
+ message_identifier.add(:message_type, data)
71
+
72
+ data = Eancom::Edifact::Data.new(
73
+ type: String,
74
+ length: 1..3,
75
+ dictionary: {
76
+ 'D' => {
77
+ description: 'UN/EDIFACT Directory'
78
+ }
79
+ },
80
+ description: 'Message version number',
81
+ required: true
82
+ )
83
+ message_identifier.add(:message_version_number, data)
84
+
85
+ data = Eancom::Edifact::Data.new(
86
+ type: String,
87
+ length: 1..3,
88
+ dictionary: {
89
+ '01B' => {
90
+ description: 'Release 2001 - B'
91
+ },
92
+ '93A' => {
93
+ description: 'Release 93A'
94
+ },
95
+ '96A' => {
96
+ description: 'Release 96A'
97
+ },
98
+ 'UN' => {
99
+ description: 'UN/CEFACT'
100
+ }
101
+ },
102
+ description: 'Message release number',
103
+ required: true
104
+ )
105
+ message_identifier.add(:message_release_number, data)
106
+
107
+ data = Eancom::Edifact::Data.new(
108
+ type: String,
109
+ length: 1..2,
110
+ dictionary: {
111
+ 'UN' => {
112
+ description: 'UN/CEFACT'
113
+ },
114
+ 'EN' => {
115
+ description: 'Default value'
116
+ }
117
+ },
118
+ description: 'Controlling agency',
119
+ required: true
120
+ )
121
+ message_identifier.add(:controlling_agency, data)
122
+
123
+ data = Eancom::Edifact::Data.new(
124
+ type: String,
125
+ length: 1..6,
126
+ dictionary: {
127
+ 'EAN001' => {
128
+ description: 'GS1 version control number (GS1 Permanent Code)'
129
+ },
130
+ 'EAN011' => {
131
+ description: 'GS1 version control number (GS1 Permanent Code)'
132
+ },
133
+ 'EAN003' => {
134
+ description: 'GS1 version control number (GS1 Permanent Code)'
135
+ },
136
+ 'EAN004' => {
137
+ description: 'GS1 version control number (GS1 Permanent Code)'
138
+ },
139
+ 'EAN005' => {
140
+ description: 'GS1 version control number (GS1 Permanent Code)'
141
+ },
142
+ 'EAN006' => {
143
+ description: 'GS1 version control number (GS1 Permanent Code)'
144
+ },
145
+ 'EAN007' => {
146
+ description: 'GS1 version control number (GS1 Permanent Code)'
147
+ },
148
+ 'EAN008' => {
149
+ description: 'GS1 version control number (GS1 Permanent Code)'
150
+ },
151
+ 'EAN009' => {
152
+ description: 'GS1 version control number (GS1 Permanent Code)'
153
+ },
154
+ 'EAN010' => {
155
+ description: 'GS1 version control number (GS1 Code)'
156
+ },
157
+ 'GDSN23' => {
158
+ description: 'GDSN version 2.3 (GS1 Permanent Code)'
159
+ }
160
+ },
161
+ description: 'Association assigned code',
162
+ required: false
163
+ )
164
+ message_identifier.add(:association_assigned_code, data)
165
+
166
+ structure << message_identifier
167
+ #==============================================================================
168
+ # Code list directory version number #
169
+ #==============================================================================
170
+ code_list_directory_version_number = Eancom::Edifact::Composite.new()
171
+
172
+ data = Eancom::Edifact::Data.new(
173
+ type: String,
174
+ length: 1..6,
175
+ dictionary: nil,
176
+ description: 'Code list directory version number',
177
+ required: false
178
+ )
179
+ code_list_directory_version_number.add(:code_list_directory_version_number, data)
180
+
181
+ structure << code_list_directory_version_number
182
+ #==============================================================================
183
+ Eancom.register_structure(tag: 'UNH', structure: structure)