eancom 0.1.0 → 1.2.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 +225 -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 +201 -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 +69 -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,250 @@
1
+ tag = 'PAC'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::PAC)
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
+ description: "Message Header",
13
+ required: true
14
+ )
15
+ tag.add(:tag, data)
16
+
17
+ structure << tag
18
+ #==============================================================================
19
+ # Document/Message Name #
20
+ #==============================================================================
21
+ package_quantity = Eancom::Edifact::Composite.new()
22
+
23
+ data = Eancom::Edifact::Data.new(
24
+ # TODO: int
25
+ type: String,
26
+ length: 1..8,
27
+ description: "Package quantity",
28
+ required: false
29
+ )
30
+ package_quantity.add(:package_quantity, data)
31
+
32
+ structure << package_quantity
33
+ #==============================================================================
34
+ # Packaging Details #
35
+ #==============================================================================
36
+ packaging_details = Eancom::Edifact::Composite.new()
37
+
38
+ packaging_level_code = Eancom::Edifact::Data.new(
39
+ type: String,
40
+ length: 1..3,
41
+ description: "Packaging level code",
42
+ required: false
43
+ )
44
+ packaging_details.add(:packaging_level_code, packaging_level_code)
45
+
46
+ packaging_related_description_code = Eancom::Edifact::Data.new(
47
+ type: String,
48
+ length: 0..3,
49
+ dictionary: {
50
+ '50' => {
51
+ description: 'Package barcoded EAN-13 or EAN-8',
52
+ identifier: 'package_barcoded_ean13_or_ean8'
53
+ },
54
+ '51' => {
55
+ description: 'Package barcoded ITF-14',
56
+ identifier: 'package_barcoded_itf14'
57
+ },
58
+ '52' => {
59
+ description: 'Package barcoded UCC or EAN-128',
60
+ identifier: 'package_barcoded_ucc_or_ean128'
61
+ },
62
+ '78' => {
63
+ description: 'Package bar-coded and EPC tagged',
64
+ identifier: 'package_barcoded_and_epc_tagged'
65
+ },
66
+ '79' => {
67
+ description: 'Package EPC tagged only',
68
+ identifier: 'package_epc_tagged_only'
69
+ },
70
+ },
71
+ description: "Packaging related description code",
72
+ required: false
73
+ )
74
+ packaging_details.add(:packaging_related_description_code, packaging_related_description_code)
75
+
76
+
77
+ packaging_terms_and_conditions = Eancom::Edifact::Data.new(
78
+ type: String,
79
+ length: 0..3,
80
+ dictionary: {
81
+ '1' => {
82
+ description: 'Packaging cost paid by supplier',
83
+ identifier: 'packaging_cost_paid_by_supplier'
84
+ },
85
+ '2' => {
86
+ description: 'Packaging cost paid by recipient',
87
+ identifier: 'packaging_cost_paid_by_recipient'
88
+ },
89
+ '3' => {
90
+ description: 'Packaging cost not charged (returnable)',
91
+ identifier: 'packaging_cost_not_charged'
92
+ },
93
+ '24' => {
94
+ description: 'Rented',
95
+ identifier: 'rented'
96
+ },
97
+ '25' => {
98
+ description: 'Safe return deposit',
99
+ identifier: 'safe_return_deposit'
100
+ },
101
+ '26' => {
102
+ description: 'Not reusable',
103
+ identifier: 'not_reusable'
104
+ },
105
+ '27' => {
106
+ description: 'Package exchangeable at the point of delivery',
107
+ identifier: 'package_exchangeable_at_the_point_of_delivery'
108
+ },
109
+ },
110
+ description: "Packaging terms and conditions code",
111
+ required: false
112
+ )
113
+ packaging_details.add(:packaging_terms_and_conditions, packaging_terms_and_conditions)
114
+
115
+ structure << packaging_details
116
+ #==============================================================================
117
+ # Package Type #
118
+ #==============================================================================
119
+ package_type = Eancom::Edifact::Composite.new()
120
+
121
+ package_type_description_code = Eancom::Edifact::Data.new(
122
+ type: String,
123
+ length: 0..17,
124
+ dictionary: {
125
+ '09' => {
126
+ description: 'Returnable pallet (GS1 Temporary Code)',
127
+ identifier: 'returnable_pallet'
128
+ },
129
+ '201' => {
130
+ description: 'Pallet ISO 1 - 1/1 EURO Pallet (GS1 Temporary Code)',
131
+ identifier: 'pallet_iso_1_euro_pallet'
132
+ },
133
+ 'PK' => {
134
+ # TODO: Find out what this is used for
135
+ description: 'PK: Function Unknown',
136
+ identifier: 'pk_function_unknown'
137
+ },
138
+ 'SL' => {
139
+ # TODO: Find out what this is used for
140
+ description: 'SL: Function Unknown',
141
+ identifier: 'sl_function_unknown'
142
+ },
143
+ },
144
+ description: "Package type description code",
145
+ required: false
146
+ )
147
+ package_type.add(:package_type_description_code, package_type_description_code)
148
+
149
+ code_list_identification_code = Eancom::Edifact::Data.new(
150
+ type: String,
151
+ length: 0..17,
152
+ description: "Code list identification code",
153
+ required: false
154
+ )
155
+ package_type.add(:code_list_identification_code, code_list_identification_code)
156
+
157
+ code_list_responsible_agency_code = Eancom::Edifact::Data.new(
158
+ type: String,
159
+ length: 0..17,
160
+ dictionary: {
161
+ '9' => {
162
+ description: 'GS1',
163
+ identifier: 'gs1'
164
+ }
165
+ },
166
+ description: "Code list responsible agency code",
167
+ required: false
168
+ )
169
+ package_type.add(:code_list_responsible_agency_code, code_list_responsible_agency_code)
170
+
171
+ type_of_packages = Eancom::Edifact::Data.new(
172
+ type: String,
173
+ length: 0..35,
174
+ description: "Type of packages",
175
+ required: false
176
+ )
177
+ package_type.add(:type_of_packages, type_of_packages)
178
+
179
+ structure << package_type
180
+ #==============================================================================
181
+ # Package Type Identification #
182
+ #==============================================================================
183
+ package_type_identification = Eancom::Edifact::Composite.new()
184
+
185
+ description_format_code = Eancom::Edifact::Data.new(
186
+ type: String,
187
+ length: 0..3,
188
+ description: "Description format code",
189
+ required: false
190
+ )
191
+ package_type_identification.add(:description_format_code, description_format_code)
192
+
193
+ type_of_packages = Eancom::Edifact::Data.new(
194
+ type: String,
195
+ length: 0..35,
196
+ description: "Type of packages",
197
+ required: false
198
+ )
199
+ package_type_identification.add(:type_of_packages_1, type_of_packages)
200
+
201
+ item_type_identification_code = Eancom::Edifact::Data.new(
202
+ type: String,
203
+ length: 0..3,
204
+ description: "Item type identification code",
205
+ required: false
206
+ )
207
+ package_type_identification.add(:item_type_identification_code_1, item_type_identification_code)
208
+
209
+ package_type_identification.add(:type_of_packages_2, type_of_packages)
210
+ package_type_identification.add(:item_type_identification_code_2, item_type_identification_code)
211
+
212
+ structure << package_type_identification
213
+ #==============================================================================
214
+ # Returnable Package Details #
215
+ #==============================================================================
216
+ returnable_package_details = Eancom::Edifact::Composite.new()
217
+
218
+ returnable_package_freight_payment_responsibility_code = Eancom::Edifact::Data.new(
219
+ type: String,
220
+ length: 0..3,
221
+ dictionary: {
222
+ '1' => {
223
+ description: 'Paid by customer',
224
+ identifier: 'paid_by_customer'
225
+ },
226
+ '2' => {
227
+ description: 'Free',
228
+ identifier: 'free'
229
+ },
230
+ '3' => {
231
+ description: 'Paid by supplier',
232
+ identifier: 'paid_by_supplier'
233
+ }
234
+ },
235
+ description: "Returnable package freight",
236
+ required: false
237
+ )
238
+ returnable_package_details.add(:returnable_package_freight_payment_responsibility_code, returnable_package_freight_payment_responsibility_code)
239
+
240
+ returnable_package_load_contents_code = Eancom::Edifact::Data.new(
241
+ type: String,
242
+ length: 0..3,
243
+ description: "Returnable package load contents code",
244
+ required: false
245
+ )
246
+ returnable_package_details.add(:returnable_package_load_contents_code, returnable_package_load_contents_code)
247
+
248
+ structure << returnable_package_details
249
+ #==============================================================================
250
+ Eancom.register_structure(tag: 'PAC', structure: structure)
@@ -0,0 +1,148 @@
1
+ tag = 'PGI'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::PGI)
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
+ # Product group type code #
21
+ #==============================================================================
22
+ product_group_type_code = Eancom::Edifact::Composite.new()
23
+
24
+ data = Eancom::Edifact::Data.new(
25
+ type: String,
26
+ length: 1..3,
27
+ dictionary: {
28
+ '2' => {
29
+ description: 'No price group used',
30
+ identifier: 'no_price_group_used'
31
+ },
32
+ '3' => {
33
+ description: 'Catalogue',
34
+ identifier: 'catalogue'
35
+ },
36
+ '4' => {
37
+ description: 'Group of products with same price',
38
+ identifier: 'group_of_products_with_same_price'
39
+ },
40
+ '9' => {
41
+ description: 'No group used',
42
+ identifier: 'no_group_uses'
43
+ },
44
+ '10' => {
45
+ description: 'Price group',
46
+ identifier: 'price_group'
47
+ },
48
+ '12' => {
49
+ description: 'Promotional group',
50
+ identifier: 'promotional_group'
51
+ },
52
+ '14' => {
53
+ description: 'Geographical target market devsion/subdivison code',
54
+ identifier: 'geographical_targeg_marget_devision_subdivision_code'
55
+ },
56
+ 'BAX' => {
57
+ description: 'Base article execution rule group',
58
+ identifier: 'base_article_execution_rule_group'
59
+ },
60
+ '11' => {
61
+ description: 'Product group',
62
+ identifier: 'product_group'
63
+ },
64
+ '10E' => {
65
+ description: 'Group of complementary products',
66
+ identifier: 'group_of_complementary_products'
67
+ },
68
+ 'DEF' => {
69
+ description: 'Definition Group',
70
+ identifier: 'definition_group'
71
+ },
72
+ 'MUL' => {
73
+ description: 'Metadata linked to multi-media objects group',
74
+ identifier: 'metadata_linked_to_multi_media_objects_group'
75
+ },
76
+ 'PAX' => {
77
+ description: 'Price allocation group',
78
+ identifier: 'price_allocation_group'
79
+ },
80
+ 'PXC' => {
81
+ description: 'Price execution rule group',
82
+ identifier: 'price_execution_rule_group'
83
+ }
84
+ },
85
+ description: 'Product group type code',
86
+ required: true
87
+ )
88
+ product_group_type_code.add(:product_group_type_code, data)
89
+
90
+ structure << product_group_type_code
91
+ #==============================================================================
92
+ # Product group #
93
+ #==============================================================================
94
+ product_group = Eancom::Edifact::Composite.new()
95
+
96
+ data = Eancom::Edifact::Data.new(
97
+ type: String,
98
+ length: 0..25,
99
+ dictionary: nil,
100
+ description: 'Product group name code',
101
+ required: false
102
+ )
103
+ product_group.add(:product_group_name_code, data)
104
+
105
+ data = Eancom::Edifact::Data.new(
106
+ type: String,
107
+ length: 0..17,
108
+ dictionary: nil,
109
+ description: 'Code list identification code',
110
+ required: false
111
+ )
112
+ product_group.add(:code_list_idenfitifaction_code, data)
113
+
114
+ data = Eancom::Edifact::Data.new(
115
+ type: String,
116
+ length: 0..3,
117
+ dictionary: {
118
+ '9' => {
119
+ description: 'GS1',
120
+ identifier: 'gsi',
121
+ },
122
+ '91' => {
123
+ description: 'Assigned by supplier or suppliers agent',
124
+ identifier: 'assigned_by_supplier_or_suppliers_agent'
125
+ },
126
+ '92' => {
127
+ description: 'Assigned by buyer or buyers agent',
128
+ identifier: 'assigned_by_buyer_or_buyers_agent'
129
+ }
130
+ },
131
+ description: 'Code list responsible agancy code',
132
+ required: false
133
+ )
134
+ product_group.add(:code_list_responsibility_agency_code, data)
135
+
136
+ data = Eancom::Edifact::Data.new(
137
+ type: String,
138
+ length: 0..35,
139
+ dictionary: nil,
140
+ description: 'Product group name',
141
+ required: false
142
+ )
143
+ product_group.add(:product_group_name, data)
144
+
145
+
146
+ structure << product_group
147
+ #==============================================================================
148
+ Eancom.register_structure(tag: 'PGI', structure: structure)