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,79 @@
1
+ tag = 'QTY'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::QTY)
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: 'QUANTITY DETAILS',
13
+ required: true
14
+ )
15
+ tag.add(:tag, data)
16
+
17
+ structure << tag
18
+ #==============================================================================
19
+ # Quantity Details #
20
+ #==============================================================================
21
+ quantity_details = Eancom::Edifact::Composite.new
22
+
23
+ data = Eancom::Edifact::Data.new(
24
+ type: String,
25
+ length: 1..3,
26
+ dictionary: {
27
+ '11' => {
28
+ description: 'Split quantity',
29
+ identifier: 'split_quantity',
30
+ },
31
+ '12' => {
32
+ description: 'Despatch quantity',
33
+ identifier: 'despatch_quantity'
34
+ },
35
+ '21' => {
36
+ description: 'Ordered quantity',
37
+ identifier: 'ordered_quantity'
38
+ },
39
+ '47' => {
40
+ description: 'Invoiced quantity',
41
+ identifier: 'invoiced_quantity'
42
+ },
43
+ '59' => {
44
+ description: 'Numbers of consumer units in the traded unit',
45
+ identifier: 'numbers_or_consumer_units_in_the_traded_unit'
46
+ },
47
+ '153' => {
48
+ description: 'Statistical sales quantity',
49
+ identifier: 'statistical_sales_quantitiy'
50
+ },
51
+ '160' => {
52
+ description: 'Minimum production batch',
53
+ identifier: 'minimum_production_batch'
54
+ }
55
+ },
56
+ description: 'Quantity type code qualifier',
57
+ required: true
58
+ )
59
+ quantity_details.add(:quantity_type_code_qualifier, data)
60
+
61
+ data = Eancom::Edifact::Data.new(
62
+ type: String,
63
+ length: 1..35,
64
+ description: 'Quantity',
65
+ required: true
66
+ )
67
+ quantity_details.add(:quantity, data)
68
+
69
+ data = Eancom::Edifact::Data.new(
70
+ type: String,
71
+ length: 0..3,
72
+ description: 'Measurement unit code',
73
+ required: false
74
+ )
75
+ quantity_details.add(:measurement_unit_code, data)
76
+
77
+ structure << quantity_details
78
+ #==============================================================================
79
+ Eancom.register_structure(tag: 'QTY', structure: structure)
@@ -0,0 +1,166 @@
1
+ tag = 'RFF'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::RFF)
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
+ # Reference #
21
+ #==============================================================================
22
+ reference = Eancom::Edifact::Composite.new()
23
+
24
+ data = Eancom::Edifact::Data.new(
25
+ type: String,
26
+ length: 1..3,
27
+ dictionary: {
28
+ 'AAB' => {
29
+ description: 'Proforma Invoice number',
30
+ identifier: 'proforma_invoice_number'
31
+ },
32
+ 'AAJ' => {
33
+ description: 'Delivery order number',
34
+ identifier: 'delivery_order_number'
35
+ },
36
+ 'AAK' => {
37
+ description: 'Despache advice number',
38
+ identifier: 'despatch_advice_number'
39
+ },
40
+ 'AAN' => {
41
+ description: 'Delivery schedule number',
42
+ identifier: 'delivery_schedule_number'
43
+ },
44
+ 'AAU' => {
45
+ description: 'Despatch note number',
46
+ identifier: 'despatch_note_number'
47
+ },
48
+ 'AFO' => {
49
+ description: 'Beneficiarys reference',
50
+ identifier: 'beneficiarys_reference'
51
+ },
52
+ 'ALL' => {
53
+ description: 'Message Batch number',
54
+ identifier: 'message_batch_number'
55
+ },
56
+ 'AIZ' => {
57
+ description: 'Consolidated Invoice number',
58
+ identifier: 'consolidated_invoice_number'
59
+ },
60
+ 'AMT' => {
61
+ description: 'Goods and Service Tax identifier number',
62
+ identifier: 'goods_and_service_tax_identifier_number'
63
+ },
64
+ 'APQ' => {
65
+ description: 'Commercial account summary',
66
+ identifier: 'commercial_account_summary'
67
+ },
68
+ 'AWT' => {
69
+ description: 'Administrative reference Code',
70
+ identifier: 'administrative_reference_code'
71
+ },
72
+ 'CD' => {
73
+ description: 'Credit note number',
74
+ identifier: 'credit_note_number'
75
+ },
76
+ 'CR' => {
77
+ description: 'Customer reference number',
78
+ identifier: 'customer_reference_number'
79
+ },
80
+ 'CT' => {
81
+ description: 'Contact number',
82
+ identifier: 'contact_number'
83
+ },
84
+ 'DL' => {
85
+ description: 'Debit note number',
86
+ identifier: 'debit_note_number'
87
+ },
88
+ 'DQ' => {
89
+ description: 'Delivery note number',
90
+ identifier: 'deliver_note_number'
91
+ },
92
+ 'FC' => {
93
+ description: 'Fiscal number',
94
+ identifier: 'fiscal_number'
95
+ },
96
+ 'IP' => {
97
+ description: 'Import licence number',
98
+ identifier: 'import_licence_number'
99
+ },
100
+ 'IV' => {
101
+ description: 'Invoice number',
102
+ identifier: 'invoice_number'
103
+ },
104
+ 'ON' => {
105
+ description: 'Order number (buyer)',
106
+ identifier: 'order_number'
107
+ },
108
+ 'PL' => {
109
+ description: 'Price list number',
110
+ identifier: 'price_list_numebr'
111
+ },
112
+ 'PK' => {
113
+ description: 'Packing list number',
114
+ identifier: 'packing_list_number'
115
+ },
116
+ 'POR' => {
117
+ description: 'Purchase order response number',
118
+ identifier: 'purchase_order_response_number'
119
+ },
120
+ 'PP' => {
121
+ description: 'Purchase order change number',
122
+ identifier: 'purchase_order_change_number'
123
+ },
124
+ 'RF' => {
125
+ description: 'Export reference number',
126
+ identifier: 'export_reference_number'
127
+ },
128
+ 'TN' => {
129
+ description: 'Transaction reference number',
130
+ identifier: 'transaction_reference_number'
131
+ },
132
+ 'VN' => {
133
+ description: 'Order number (supplier)',
134
+ identifier: 'order_number'
135
+ },
136
+ 'VA' => {
137
+ description: 'VAT registration number',
138
+ identifier: 'vat_registration_number'
139
+ },
140
+ },
141
+ description: "Reference code quailifier",
142
+ required: true
143
+ )
144
+ reference.add(:reference_code_qualifier, data)
145
+
146
+ data = Eancom::Edifact::Data.new(
147
+ type: String,
148
+ length: 1..70,
149
+ dictionary: nil,
150
+ description: "Reference identifier",
151
+ required: true
152
+ )
153
+ reference.add(:reference_identifier, data)
154
+
155
+ data = Eancom::Edifact::Data.new(
156
+ type: String,
157
+ length: 1..6,
158
+ dictionary: nil,
159
+ description: "Document line identifier",
160
+ required: false
161
+ )
162
+ reference.add(:document_line_identifier, data)
163
+
164
+ structure << reference
165
+ #==============================================================================
166
+ Eancom.register_structure(tag: 'RFF', structure: structure)
@@ -0,0 +1,259 @@
1
+ tag = 'TAX'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::TAX)
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
+ # Duty or tax or fee function code qualifier #
21
+ #==============================================================================
22
+ duty_or_tax_or_fee_function_code_qualifier = Eancom::Edifact::Composite.new()
23
+
24
+ data = Eancom::Edifact::Data.new(
25
+ type: String,
26
+ length: 1..3,
27
+ dictionary: {
28
+ '7' => {
29
+ description: 'Tax',
30
+ identifier: 'tax'
31
+ }
32
+ },
33
+ description: 'Duty or tax or fee function code qualifier',
34
+ required: true
35
+ )
36
+ duty_or_tax_or_fee_function_code_qualifier.add(
37
+ :duty_or_tax_or_fee_function_code_qualifier, data)
38
+
39
+ structure << duty_or_tax_or_fee_function_code_qualifier
40
+ #==============================================================================
41
+ # Duty/Tax/Fee Type #
42
+ #==============================================================================
43
+ duty_tax_fee_type = Eancom::Edifact::Composite.new()
44
+
45
+ data = Eancom::Edifact::Data.new(
46
+ type: String,
47
+ length: 1..3,
48
+ dictionary: {
49
+ 'ENV' => {
50
+ description: 'Environmental tax',
51
+ identifier: 'environmental_tax'
52
+ },
53
+ 'GST' => {
54
+ description: 'Goods and services tax',
55
+ identifier: 'goods_and_services_tax'
56
+ },
57
+ 'AAD' => {
58
+ description: 'Tabacco tax',
59
+ identifier: 'tabacco_tax'
60
+ },
61
+ 'VAT' => {
62
+ description: 'Value added tax',
63
+ identifier: 'vat'
64
+ },
65
+ },
66
+ description: 'Duty or tax or fee type name code',
67
+ required: true
68
+ )
69
+ duty_tax_fee_type.add(:duty_or_tax_or_fee_name_code, data)
70
+
71
+ data = Eancom::Edifact::Data.new(
72
+ type: String,
73
+ length: 0..17,
74
+ dictionary: nil,
75
+ description: 'Code list identifiaction code',
76
+ required: false
77
+ )
78
+ duty_tax_fee_type.add(:code_list_identification_code_1, data)
79
+
80
+ data = Eancom::Edifact::Data.new(
81
+ type: String,
82
+ length: 0..3,
83
+ dictionary: {
84
+ '9' => {
85
+ description: 'EAN',
86
+ identifier: 'ean',
87
+ }
88
+ },
89
+ description: 'Code list responsible agancy code',
90
+ required: false
91
+ )
92
+ duty_tax_fee_type.add(:code_list_responsibility_agency_code_1, data)
93
+
94
+ data = Eancom::Edifact::Data.new(
95
+ type: String,
96
+ length: 0..35,
97
+ dictionary: nil,
98
+ description: 'Duty or tax or fee type_name',
99
+ required: false
100
+ )
101
+ duty_tax_fee_type.add(:duty_or_tax_or_fee_type_name, data)
102
+
103
+ structure << duty_tax_fee_type
104
+ #==============================================================================
105
+ # Duty/Tax/Fee Account Detail #
106
+ #==============================================================================
107
+ duty_tax_fee_account_detail = Eancom::Edifact::Composite.new()
108
+
109
+ data = Eancom::Edifact::Data.new(
110
+ type: String,
111
+ length: 0..6,
112
+ dictionary: nil,
113
+ description: 'Duty or tax or fee account code',
114
+ required: false
115
+ )
116
+ duty_tax_fee_account_detail.add(:duty_or_tax_or_fee_account_code, data)
117
+
118
+ data = Eancom::Edifact::Data.new(
119
+ type: String,
120
+ length: 0..17,
121
+ dictionary: nil,
122
+ description: 'Code List identifiaction code',
123
+ required: false
124
+ )
125
+ duty_tax_fee_account_detail.add(:code_list_identification_code_2, data)
126
+
127
+ data = Eancom::Edifact::Data.new(
128
+ type: String,
129
+ length: 0..3,
130
+ dictionary: nil,
131
+ description: 'Code list responsible agancy code',
132
+ required: false
133
+ )
134
+ duty_tax_fee_account_detail.add(:code_list_responsibility_agency_code_2, data)
135
+
136
+ structure << duty_tax_fee_account_detail
137
+ #==============================================================================
138
+ # Duty or Tax or fee assessment basis value #
139
+ #==============================================================================
140
+ duty_or_tax_of_fee_assessment_basis_value = Eancom::Edifact::Composite.new()
141
+ data = Eancom::Edifact::Data.new(
142
+ type: String,
143
+ length: 1..15,
144
+ dictionary: nil,
145
+ description: 'Duty or Tax or fee assessment basis value',
146
+ required: false
147
+ )
148
+ duty_or_tax_of_fee_assessment_basis_value.add(:duty_or_tax_of_fee_assessment_basis_value, data)
149
+
150
+ structure << duty_or_tax_of_fee_assessment_basis_value
151
+ #==============================================================================
152
+ # Duty/Tax/Fee Detail #
153
+ #==============================================================================
154
+ duty_tax_fee_detail = Eancom::Edifact::Composite.new()
155
+
156
+ data = Eancom::Edifact::Data.new(
157
+ type: String,
158
+ length: 0..7,
159
+ dictionary: nil,
160
+ description: 'Duty or Tax or Fee rate code',
161
+ required: false
162
+ )
163
+ duty_tax_fee_detail.add(:duty_tax_fee_rate_code, data)
164
+
165
+ data = Eancom::Edifact::Data.new(
166
+ type: String,
167
+ length: 0..17,
168
+ dictionary: nil,
169
+ description: 'Code List identifiaction code',
170
+ required: false
171
+ )
172
+ duty_tax_fee_detail.add(:code_list_identification_code_3, data)
173
+
174
+ data = Eancom::Edifact::Data.new(
175
+ type: String,
176
+ length: 0..3,
177
+ dictionary: nil,
178
+ description: 'Code list responsible agancy code',
179
+ required: false
180
+ )
181
+ duty_tax_fee_detail.add(:code_list_responsibility_agency_code_3, data)
182
+
183
+ data = Eancom::Edifact::Data.new(
184
+ type: String,
185
+ length: 0..17,
186
+ dictionary: nil,
187
+ description: 'Duty or Tax or Fee rate',
188
+ required: false
189
+ )
190
+
191
+ duty_tax_fee_detail.add(:duty_or_tax_or_fee_rate, data)
192
+
193
+ data = Eancom::Edifact::Data.new(
194
+ type: String,
195
+ length: 0..17,
196
+ dictionary: nil,
197
+ description: 'Duty or Tax or fee basis code',
198
+ required: false
199
+ )
200
+ duty_tax_fee_detail.add(:duty_or_tax_or_fee_basis_code, data)
201
+
202
+ data = Eancom::Edifact::Data.new(
203
+ type: String,
204
+ length: 0..17,
205
+ dictionary: nil,
206
+ description: 'Duty or Tax or fee basis code',
207
+ required: false
208
+ )
209
+ duty_tax_fee_detail.add(:duty_or_tax_or_fee_basis_code, data)
210
+
211
+ data = Eancom::Edifact::Data.new(
212
+ type: String,
213
+ length: 0..17,
214
+ dictionary: nil,
215
+ description: 'Code List identifiaction code',
216
+ required: false
217
+ )
218
+ duty_tax_fee_detail.add(:code_list_identification_code_4, data)
219
+
220
+ data = Eancom::Edifact::Data.new(
221
+ type: String,
222
+ length: 0..3,
223
+ dictionary: nil,
224
+ description: 'Code list responsible agancy code',
225
+ required: false
226
+ )
227
+ duty_tax_fee_detail.add(:code_list_responsibility_agency_code_4, data)
228
+
229
+ structure << duty_tax_fee_detail
230
+ #==============================================================================
231
+ # Duty or tax or fee category code
232
+ #==============================================================================
233
+ duty_or_tax_or_fee_category_code = Eancom::Edifact::Composite.new()
234
+
235
+ data = Eancom::Edifact::Data.new(
236
+ type: String,
237
+ length: 0..3,
238
+ dictionary: {
239
+ 'A' => {
240
+ description: 'Mixed tax rate',
241
+ identifier: 'mixed_tax_rage',
242
+ },
243
+ 'E' => {
244
+ description: 'Exempt from tax',
245
+ identifier: 'exempt_from_tax',
246
+ },
247
+ 'S' => {
248
+ description: 'Standard rate',
249
+ identifier: 'standard_rate',
250
+ },
251
+ },
252
+ description: 'Duty or tax or fee category code',
253
+ required: false
254
+ )
255
+ duty_or_tax_or_fee_category_code.add(:duty_or_tax_or_fee_category_code, data)
256
+
257
+ structure << duty_or_tax_or_fee_category_code
258
+ #==============================================================================
259
+ Eancom.register_structure(tag: 'TAX', structure: structure)