eancom 0.1.0 → 2.0.0

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.
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,221 @@
1
+ Eancom::Definition.create(name: 'D96A', type: :retann) do |document, config|
2
+ document.header do |header|
3
+ header.segment Eancom::Edifact::UNA.new
4
+
5
+ header.segment Eancom::Edifact::UNB.new(
6
+ syntax_identifier: 'UNOC',
7
+ syntax_version_number: '3',
8
+ interchange_sender_identification: config.header.interchange_sender_identification,
9
+ sender_identifiction_code_qualifier: '14',
10
+ interchange_recipient_identification: config.header.interchange_recipient_identification,
11
+ recipient_identifiction_code_qualifier: '14',
12
+ date: config.header.date,
13
+ time: config.header.time,
14
+ interchange_control_reference: config.header.interchange_control_reference,
15
+ application_reference: config.header.application_reference,
16
+ interchange_agreement_identifier: config.header.interchange_agreement_identifier
17
+ )
18
+
19
+ header.segment Eancom::Edifact::UNH.new(
20
+ message_reference_number: config.header.message_reference_number,
21
+ message_type: config.header.message_type,
22
+ message_version_number: config.header.message_version_number,
23
+ message_release_number: config.header.message_release_number,
24
+ controlling_agency: config.header.controlling_agency,
25
+ association_assigned_code: config.header.association_assigned_code
26
+ )
27
+ end
28
+
29
+ document.body do |body|
30
+ messages = config.body.messages
31
+ messages.each do |message|
32
+ body.segment Eancom::Edifact::BGM.new(
33
+ document_name_code: message.document_name_code,
34
+ code_list_identification_code: '',
35
+ code_list_responsible_agency_code: '9',
36
+ document_identifier: message.document_identifier,
37
+ message_function_code: message.message_function_code
38
+ )
39
+
40
+ date_time_messages = message.date_time_messages
41
+ date_time_messages.each_with_index do |dtm, index|
42
+ next unless index == 0
43
+ structure = Eancom.find_structure(tag: 'DTM')
44
+ key = dtm.identifier.intern.to_sym
45
+ body.segment Eancom::Edifact::DTM.new(
46
+ type: structure.dictionary_lookup(:type, dtm.identifier),
47
+ date_time: dtm[key].date_time,
48
+ format: '102'
49
+ )
50
+ end
51
+
52
+ date_time_messages.each_with_index do |dtm, index|
53
+ next unless index == 1
54
+ structure = Eancom.find_structure(tag: 'DTM')
55
+ key = dtm.identifier.intern.to_sym
56
+ body.segment Eancom::Edifact::DTM.new(
57
+ type: structure.dictionary_lookup(:type, dtm.identifier),
58
+ date_time: dtm[key].date_time,
59
+ format: '102'
60
+ )
61
+ end
62
+
63
+ references = message.references
64
+ references.each_with_index do |rff, index|
65
+ next unless index == 0
66
+ structure = Eancom.find_structure(tag: 'RFF')
67
+ key = rff.identifier.intern.to_sym
68
+ body.segment Eancom::Edifact::RFF.new(
69
+ reference_code_qualifier: structure.dictionary_lookup(:reference_code_qualifier, rff.identifier),
70
+ reference_identifier: rff[key].reference_identifier
71
+ )
72
+ end
73
+
74
+ date_time_messages.each_with_index do |dtm, index|
75
+ next unless index == 2
76
+ structure = Eancom.find_structure(tag: 'DTM')
77
+ key = dtm.identifier.intern.to_sym
78
+ body.segment Eancom::Edifact::DTM.new(
79
+ type: structure.dictionary_lookup(:type, dtm.identifier),
80
+ date_time: dtm[key].date_time,
81
+ format: '102'
82
+ )
83
+ end
84
+
85
+ nads = message.nads
86
+ nads.each_with_index do |nad, index|
87
+ next unless index == 0
88
+ structure = Eancom.find_structure(tag: 'NAD')
89
+ key = nad.identifier.intern.to_sym
90
+ body.segment Eancom::Edifact::NAD.new(
91
+ party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
92
+ party_identifier: nad[key].party_identifier,
93
+ code_list_responsible_agency_code_1: '9'
94
+ )
95
+ end
96
+
97
+ nads.each_with_index do |nad, index|
98
+ next unless index == 1
99
+ structure = Eancom.find_structure(tag: 'NAD')
100
+ key = nad.identifier.intern.to_sym
101
+ body.segment Eancom::Edifact::NAD.new(
102
+ party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
103
+ party_identifier: nad[key].party_identifier,
104
+ code_list_responsible_agency_code_1: '9'
105
+ )
106
+ end
107
+
108
+ nads.each_with_index do |nad, index|
109
+ next unless index == 2
110
+ structure = Eancom.find_structure(tag: 'NAD')
111
+ key = nad.identifier.intern.to_sym
112
+ body.segment Eancom::Edifact::NAD.new(
113
+ party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
114
+ party_identifier: nad[key].party_identifier,
115
+ code_list_responsible_agency_code_1: '9'
116
+ )
117
+ end
118
+
119
+ nads.each_with_index do |nad, index|
120
+ next unless index == 3
121
+ structure = Eancom.find_structure(tag: 'NAD')
122
+ key = nad.identifier.intern.to_sym
123
+ body.segment Eancom::Edifact::NAD.new(
124
+ party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
125
+ party_identifier: nad[key].party_identifier,
126
+ code_list_responsible_agency_code_1: '9'
127
+ )
128
+ end
129
+
130
+ total_quantity = 0
131
+
132
+ items = message.items
133
+
134
+ items.each_with_index do |item, index|
135
+ total_quantity += item.quantity.to_i
136
+
137
+ structure = Eancom.find_structure(tag: 'LIN')
138
+ body.segment Eancom::Edifact::LIN.new(
139
+ line_item_identifier_1: (index + 1).to_s,
140
+ item_identifier: item.ean,
141
+ item_type_identification_code: structure.dictionary_lookup(:item_type_identification_code, item.item_type_identification_code)
142
+ )
143
+
144
+ if additional_product_id = item.additional_product_id
145
+ additional_product_id.each do |id|
146
+ next unless additional_information = id.additional_information
147
+
148
+ structure = Eancom.find_structure(tag: 'PIA')
149
+ body.segment Eancom::Edifact::PIA.new(
150
+ product_identifier_code_qualifier: structure.dictionary_lookup(:product_identifier_code_qualifier, additional_information.product_identifier_code_qualifier),
151
+ item_identifier_1: additional_information.item_identifier_1,
152
+ item_type_identification_code_1: structure.dictionary_lookup(:item_type_identification_code_1, additional_information.item_type_identification_code_1)
153
+ )
154
+ end
155
+ end
156
+
157
+ prices = item.prices
158
+ prices.each do |price|
159
+ next unless price = price.price
160
+
161
+ structure = Eancom.find_structure(tag: 'PRI')
162
+ body.segment Eancom::Edifact::PRI.new(
163
+ price_code_qualifier: structure.dictionary_lookup(:price_code_qualifier, price.price_code_qualifier),
164
+ price_amount: price.price_amount
165
+ )
166
+ end
167
+
168
+ qty = item.quantities
169
+ qty.each_with_index do |qty, index|
170
+ structure = Eancom.find_structure(tag: 'QTY')
171
+ key = qty.identifier.intern.to_sym
172
+ body.segment Eancom::Edifact::QTY.new(
173
+ quantity_type_code_qualifier: structure.dictionary_lookup(:quantity_type_code_qualifier, qty.identifier),
174
+ quantity: qty[key].quantity,
175
+ measurement_unit_code: structure.dictionary_lookup(:measurement_unit_code, qty.measurement_unit_code)
176
+ )
177
+ end
178
+
179
+ structure = Eancom.find_structure(tag: 'CDI')
180
+ body.segment Eancom::Edifact::CDI.new(
181
+ physical_or_logical_state_type_code_qualifier: structure.dictionary_lookup(:physical_or_logical_state_type_code_qualifier, item.physical_or_logical_state_type_code_qualifier)
182
+ )
183
+ end
184
+ end
185
+ end
186
+
187
+ document.footer do |footer|
188
+ footer.segment Eancom::Edifact::UNS.new(
189
+ section_identification: 'S'
190
+ )
191
+
192
+ messages = config.body.messages
193
+
194
+ messages.each do |message|
195
+ items = message.items
196
+
197
+ items.each_with_index do |item, index|
198
+ next unless index == items.size - 1
199
+
200
+ counts = item.counts
201
+ counts.each_with_index do |cnt, index|
202
+ structure = Eancom.find_structure(tag: 'CNT')
203
+ footer.segment Eancom::Edifact::CNT.new(
204
+ control_total_type_code_quantifier: structure.dictionary_lookup(:control_total_type_code_quantifier, cnt.control_total_type_code_quantifier),
205
+ control_total_value: (index + 2).to_s
206
+ )
207
+ end
208
+ end
209
+ end
210
+
211
+ footer.segment Eancom::Edifact::UNT.new(
212
+ number_of_segments_in_message: (document.total_segments + 2).to_s,
213
+ message_reference_number: config.header.message_reference_number
214
+ )
215
+
216
+ footer.segment Eancom::Edifact::UNZ.new(
217
+ interchange_control_count: messages.size.to_s,
218
+ interchange_control_reference: config.header.interchange_control_reference.to_s
219
+ )
220
+ end
221
+ end
@@ -0,0 +1,47 @@
1
+ tag = 'AJT'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::AJT)
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: 'Message Header',
14
+ required: true
15
+ )
16
+ tag.add(:tag, data)
17
+
18
+ structure << tag
19
+ #==============================================================================
20
+ # HAZARD CODE #
21
+ #==============================================================================
22
+ adjustment_reason_description = Eancom::Edifact::Composite.new
23
+ data = Eancom::Edifact::Data.new(
24
+ type: String,
25
+ length: 1..3,
26
+ dictionary: {
27
+ '3' => {
28
+ description: 'Damaged goods',
29
+ identifier: 'damaged_goods'
30
+ },
31
+ '5' => {
32
+ description: 'Price query',
33
+ identifier: 'price_query'
34
+ },
35
+ '9' => {
36
+ description: 'Invoice error',
37
+ identifier: 'invoice_error'
38
+ }
39
+ },
40
+ description: 'Adjustment reason description',
41
+ required: true
42
+ )
43
+ adjustment_reason_description.add(:adjustment_reason_description, data)
44
+
45
+ structure << adjustment_reason_description
46
+ #==============================================================================
47
+ Eancom.register_structure(tag: 'AJT', structure: structure)
@@ -0,0 +1,328 @@
1
+ tag = 'ALC'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::ALC)
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
+ # Allowance or Charge code qualifier
21
+ #==============================================================================
22
+ allowance_or_charge_code_qualifier = Eancom::Edifact::Composite.new
23
+ data = Eancom::Edifact::Data.new(
24
+ type: String,
25
+ length: 1..3,
26
+ dictionary: {
27
+ 'A' => {
28
+ description: 'Allowance',
29
+ identifier: 'allowance'
30
+ },
31
+ 'C' => {
32
+ description: 'Charge',
33
+ identifier: 'charge'
34
+ },
35
+ 'N' => {
36
+ description: 'No allowance or charge',
37
+ identifier: 'no_allowance_or_charge'
38
+ }
39
+ },
40
+ description: 'Allowance or Charge code qualifier',
41
+ required: true
42
+ )
43
+ allowance_or_charge_code_qualifier.add(:allowance_or_charge_code_qualifier, data)
44
+
45
+ structure << allowance_or_charge_code_qualifier
46
+ #==============================================================================
47
+ # Allowance/Charge information
48
+ #==============================================================================
49
+ allowance_charge_information = Eancom::Edifact::Composite.new
50
+
51
+ data = Eancom::Edifact::Data.new(
52
+ type: String,
53
+ length: 0..35,
54
+ dictionary: nil,
55
+ description: 'Allowance or charge identifier',
56
+ required: false
57
+ )
58
+ allowance_charge_information.add(:allowance_or_charge_identifier, data)
59
+
60
+ data = Eancom::Edifact::Data.new(
61
+ type: String,
62
+ length: 0..3,
63
+ dictionary: {
64
+ '64' => {
65
+ description: 'Special agreement',
66
+ identifier: 'special_agreement'
67
+ },
68
+ '69' => {
69
+ description: 'Charge for a customer specific finish',
70
+ identifier: 'charge_for_a_customer_specific_finisch'
71
+ },
72
+ '64E' => {
73
+ description: 'Yearly turnover allowance/charge',
74
+ identifier: 'yearly_turnover_allowance_charge'
75
+ },
76
+ '101' => {
77
+ description: 'Carbon footprint charge',
78
+ identifier: 'carbon_footprint_charge'
79
+ }
80
+ },
81
+ description: 'Allowance or charge identification code',
82
+ required: false
83
+ )
84
+ allowance_charge_information.add(:allowance_or_charge_identification_code, data)
85
+
86
+ data = Eancom::Edifact::Data.new(
87
+ type: String,
88
+ length: 0..3,
89
+ dictionary: {
90
+ '1' => {
91
+ description: 'Bill back',
92
+ identifier: 'bill_back'
93
+ },
94
+ '2' => {
95
+ description: 'Off invoice',
96
+ identifier: 'off_invoice'
97
+ },
98
+ '5' => {
99
+ description: 'Charge to be paid by vendor',
100
+ identifier: 'charge_to_be_paid_by_vendor'
101
+ },
102
+ '6' => {
103
+ description: 'Charge to be paid by customer',
104
+ identifier: 'charge_to_be_paid_by_customer'
105
+ }
106
+ },
107
+ description: 'Settlement mean code',
108
+ required: false
109
+ )
110
+ allowance_charge_information.add(:settlement_mean_code, data)
111
+
112
+ data = Eancom::Edifact::Data.new(
113
+ type: String,
114
+ length: 0..3,
115
+ dictionary: {
116
+ '1' => {
117
+ description: 'First step of calculation',
118
+ identifier: 'first_step_of_calculation'
119
+ },
120
+ '2' => {
121
+ description: 'Second step of calculation',
122
+ identifier: 'second_step_of_calculation'
123
+ },
124
+ '3' => {
125
+ description: 'Third step of calculation',
126
+ identifier: 'third_step_of_calculation'
127
+ },
128
+ '4' => {
129
+ description: 'Forth step of calculation',
130
+ identifier: 'forth_step_of_calculation'
131
+ },
132
+ '5' => {
133
+ description: 'Fith step of calculation',
134
+ identifier: 'fith_step_of_calculation'
135
+ },
136
+ '6' => {
137
+ description: 'Sixth step of calculation',
138
+ identifier: 'sixth_step_of_calculation'
139
+ },
140
+ '7' => {
141
+ description: 'Seventh step of calculation',
142
+ identifier: 'seventh_step_of_calculation'
143
+ },
144
+ '8' => {
145
+ description: 'Eighth step of calculation',
146
+ identifier: 'eighth_step_of_calculation'
147
+ },
148
+ '9' => {
149
+ description: 'Ninth step of calculation',
150
+ identifier: 'ninth_step_of_calculation'
151
+ }
152
+ },
153
+ description: 'Calculation sequence code',
154
+ required: false
155
+ )
156
+ allowance_charge_information.add(:calculation_sequence_code, data)
157
+
158
+ structure << allowance_charge_information
159
+ #==============================================================================
160
+ # Special Services identification
161
+ #==============================================================================
162
+ special_services_identification = Eancom::Edifact::Composite.new
163
+
164
+ data = Eancom::Edifact::Data.new(
165
+ type: String,
166
+ length: 1..3,
167
+ dictionary: {
168
+ 'AJ' => {
169
+ description: 'Adjustments',
170
+ identifier: 'adjustments'
171
+ },
172
+ 'DDA' => {
173
+ description: 'Dealer discount/allowance (GS1 Temporary Code)',
174
+ identifier: 'dealer_discount_allowance_gs1'
175
+ },
176
+ 'DBD' => {
177
+ description: 'Debtor bound (GS1 Temporary Code)',
178
+ identifier: 'debtor_bound'
179
+ },
180
+ 'CAC' => {
181
+ description: 'Cash Discount',
182
+ identifier: 'cash_discount'
183
+ },
184
+ 'CAV' => {
185
+ description: 'Battery collection and recycling',
186
+ identifier: 'battery_collection_and_recycling'
187
+ },
188
+ 'CAU' => {
189
+ description: 'Sorting',
190
+ identifier: 'sorting'
191
+ },
192
+ 'CAW' => {
193
+ description: 'Product Take Back Fee',
194
+ identifier: 'product_take_back_fee'
195
+ },
196
+ 'AEK' => {
197
+ description: 'Cash on delivery service',
198
+ identifier: 'cash_on_delivery_service'
199
+ },
200
+ 'AAB' => {
201
+ description: 'Returned goods charges',
202
+ identifier: 'returned_goods_charges'
203
+ },
204
+ 'ABA' => {
205
+ description: 'Compulsory storage fee',
206
+ identifier: 'compulsory_storage_fee'
207
+ },
208
+ 'ABL' => {
209
+ description: 'Packaging surcharge',
210
+ identifier: 'packaging_surcharge'
211
+ },
212
+ 'ABZ' => {
213
+ description: 'Miscellaneous rebate or discount',
214
+ identifier: 'miscellaneous_rebate_or_discount'
215
+ },
216
+ 'ACZ' => {
217
+ description: 'Damaged merchandise',
218
+ identifier: 'damaged_merchandise'
219
+ },
220
+ 'ADS' => {
221
+ description: 'Full pallet ordering',
222
+ identifier: 'full_pallet_ordering'
223
+ },
224
+ 'ADT' => {
225
+ description: 'Pick-up',
226
+ identifier: 'pick_up'
227
+ },
228
+ 'EAB' => {
229
+ description: 'Early payment allowance',
230
+ identifier: 'early_payment_allowance'
231
+ },
232
+ 'RCH' => {
233
+ description: 'Return handling (GS1 Temporary Code)',
234
+ identifier: 'return_handling'
235
+ },
236
+ 'TD' => {
237
+ description: 'Trade discount',
238
+ identifier: 'trade_discount'
239
+ },
240
+ 'FC' => {
241
+ description: 'Freight charge',
242
+ identifier: 'freght_charge'
243
+ },
244
+ 'FI' => {
245
+ description: 'Finance charge',
246
+ identifier: 'finance_charge'
247
+ },
248
+ 'FR' => {
249
+ description: 'Flat Rate (GS1 Temporary Code)',
250
+ identifier: 'flat_rate'
251
+ },
252
+ 'HD' => {
253
+ description: 'Handling',
254
+ identifier: 'handling'
255
+ },
256
+ 'QD' => {
257
+ description: 'Quantity discount',
258
+ identifier: 'quantity_discount'
259
+ },
260
+ 'X01' => {
261
+ description: 'Allowance Global (GS1 Temporary Code)',
262
+ identifier: 'allowance_global'
263
+ },
264
+ 'X02' => {
265
+ description: 'Charge Global (GS1 Temporary Code)',
266
+ identifier: 'charge_global'
267
+ },
268
+ 'X03' => {
269
+ description: 'Consolidated (GS1 Temporary Code)',
270
+ identifier: 'consolidated'
271
+ },
272
+ 'X04' => {
273
+ description: 'Lump sum (GS1 Temporary Code)',
274
+ identifier: 'lump_sum'
275
+ },
276
+ 'X05' => {
277
+ description: 'Markup for small volume purchases',
278
+ identifier: 'markup_for_small_volume_purchases'
279
+ },
280
+ 'X30' => {
281
+ description: 'Point of sales allowance (GS1 Temporary Code)',
282
+ identifier: 'point_of_sales_allowance'
283
+ },
284
+ 'X40' => {
285
+ description: 'Allowance/charge regulated by law',
286
+ identifier: 'allowance_charge_regulated_by_law'
287
+ }
288
+ },
289
+ description: 'Special service description_code',
290
+ required: false
291
+ )
292
+ special_services_identification.add(:special_service_description_code, data)
293
+
294
+ data = Eancom::Edifact::Data.new(
295
+ type: String,
296
+ length: 0..17,
297
+ description: 'Code list identification code',
298
+ required: false
299
+ )
300
+ special_services_identification.add(:code_list_identification_code, data)
301
+
302
+ data = Eancom::Edifact::Data.new(
303
+ type: String,
304
+ length: 0..3,
305
+ dictionary: {
306
+ '9' => {
307
+ description: 'GS1',
308
+ identifier: 'gs1'
309
+ }
310
+ },
311
+ description: 'Code list responsible agency code',
312
+ required: false
313
+ )
314
+ special_services_identification.add(:code_list_responsible_agency_code, data)
315
+
316
+ data = Eancom::Edifact::Data.new(
317
+ type: String,
318
+ length: 0..3,
319
+ dictionary: nil,
320
+ description: 'Special service description',
321
+ required: false
322
+ )
323
+ special_services_identification.add(:special_service_description_1, data)
324
+ special_services_identification.add(:special_service_description_2, data)
325
+
326
+ structure << special_services_identification
327
+ #==============================================================================
328
+ Eancom.register_structure(tag: 'ALC', structure: structure)