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,205 @@
1
+ Eancom::Definition.create(name: 'D01B', type: :desadv) 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: 'DESADV0720',
16
+ interchange_agreement_identifier: 'EANCOM76170270000007613067000000900',
17
+ test_indicator: '0'
18
+ )
19
+
20
+ header.segment Eancom::Edifact::UNH.new(
21
+ message_reference_number: config.header.message_reference_number,
22
+ message_type: config.header.message_type,
23
+ message_version_number: config.header.message_version_number,
24
+ message_release_number: config.header.message_release_number,
25
+ controlling_agency: config.header.controlling_agency,
26
+ association_assigned_code: config.header.association_assigned_code
27
+ )
28
+ end
29
+
30
+ document.body do |body|
31
+
32
+ # Messages
33
+ messages = config.body.messages
34
+
35
+ messages.each do |message|
36
+
37
+ body.segment Eancom::Edifact::BGM.new(
38
+ document_name_code: '351',
39
+ document_identifier: message.document_identifier,
40
+ message_function_code: '9'
41
+ )
42
+
43
+ # Document Date
44
+ body.segment Eancom::Edifact::DTM.new(
45
+ type: '137',
46
+ date_time: message.document_message_date_time.date_time,
47
+ format: '204'
48
+ )
49
+
50
+ # Delivery Date Estimated
51
+ if date_time = message.delivery_date_time_estimated.date_time
52
+ body.segment Eancom::Edifact::DTM.new(
53
+ type: '17',
54
+ date_time: date_time,
55
+ format: '204'
56
+ )
57
+ end
58
+
59
+ # Order Reference
60
+ if reference_identifier = message.order_number.reference_identifier
61
+ body.segment Eancom::Edifact::RFF.new(
62
+ reference_code_qualifier: 'ON',
63
+ reference_identifier: reference_identifier
64
+ )
65
+ end
66
+
67
+ # Buyer
68
+ if buyer = message.buyer
69
+ body.segment Eancom::Edifact::NAD.new(
70
+ party_function_code_qualifier: 'BY',
71
+ party_identifier: buyer.party_identifier,
72
+ code_list_responsible_agancy_code_1: '9'
73
+ )
74
+ end
75
+
76
+ # Supplier
77
+ if supplier = message.supplier
78
+ body.segment Eancom::Edifact::NAD.new(
79
+ party_function_code_qualifier: 'SU',
80
+ party_identifier: supplier.party_identifier,
81
+ code_list_responsible_agancy_code_1: '9'
82
+ )
83
+ end
84
+
85
+ # Manufacturer ILN
86
+ if manufacturer = message.manufacturer
87
+ body.segment Eancom::Edifact::NAD.new(
88
+ party_function_code_qualifier: 'MF',
89
+ party_identifier: manufacturer.party_identifier,
90
+ code_list_responsible_agancy_code_1: '9'
91
+ )
92
+ end
93
+
94
+ # Delivery Party
95
+ if delivery_party = message.delivery_party
96
+ body.segment Eancom::Edifact::NAD.new(
97
+ party_function_code_qualifier: 'DP',
98
+ party_identifier: delivery_party.party_identifier,
99
+ code_list_responsible_agancy_code_1: '9',
100
+ city_name: delivery_party.city_name,
101
+ party_name_1: delivery_party.party_name_1,
102
+ postal_identification_code: delivery_party.postal_identification_code,
103
+ street_and_number_1: delivery_party.street_and_number_1,
104
+ country_name_code: delivery_party.country_name_code
105
+ )
106
+ end
107
+
108
+ # Ultimate consignee
109
+ if ultimate_consignee = message.ultimate_consignee
110
+ body.segment Eancom::Edifact::NAD.new(
111
+ party_function_code_qualifier: 'UC',
112
+ party_identifier: ultimate_consignee.party_identifier,
113
+ code_list_responsible_agancy_code_1: '9',
114
+ city_name: ultimate_consignee.city_name,
115
+ party_name_1: ultimate_consignee.party_name_1,
116
+ postal_identification_code: ultimate_consignee.postal_identification_code,
117
+ street_and_number_1: ultimate_consignee.street_and_number_1,
118
+ country_name_code: ultimate_consignee.country_name_code
119
+ )
120
+ end
121
+
122
+ body.segment Eancom::Edifact::TDT.new(
123
+ transport_stage_code_qualifier: '20',
124
+ transport_mode_name_code: '30'
125
+ )
126
+ # Delivery Note Mode
127
+ body.segment Eancom::Edifact::CPS.new(
128
+ hierarchical_structure_level_identifier: '1'
129
+ )
130
+
131
+ body.segment Eancom::Edifact::PAC.new(
132
+ package_quantity: '1'
133
+ )
134
+
135
+ body.segment Eancom::Edifact::CPS.new(
136
+ hierarchical_structure_level_identifier: '2',
137
+ hierarchical_structure_parent_identifier: '1'
138
+ )
139
+
140
+ # Items
141
+ total_quantity = 0
142
+
143
+ items = message.items
144
+
145
+ items.each_with_index do |item, index|
146
+ total_quantity += item.quantity.to_i
147
+
148
+
149
+ body.segment Eancom::Edifact::LIN.new(
150
+ line_item_identifier_1: "#{index + 1}",
151
+ item_identifier: item.ean,
152
+ item_type_identification_code: 'SRV'
153
+ )
154
+
155
+ if additional_product_id = item.additional_product_id
156
+ additional_product_id.each do |id|
157
+ if additional_information = id.additional_information
158
+ body.segment Eancom::Edifact::PIA.new(
159
+ product_identifier_code_qualifier: '1',
160
+ item_identifier_1: additional_information.item_identifier_1,
161
+ item_type_identification_code_1: 'IN'
162
+ )
163
+ end
164
+ end
165
+ end
166
+
167
+ body.segment Eancom::Edifact::IMD.new(
168
+ description_format_code: 'C',
169
+ item_description_code: 'CU',
170
+ code_list_responsible_agency_code_1: '9'
171
+ )
172
+
173
+ body.segment Eancom::Edifact::QTY.new(
174
+ quantity_type_code_qualifier: '12',
175
+ quantity: "#{item.despatch_quantity.quantity}"
176
+ )
177
+
178
+ body.segment Eancom::Edifact::QTY.new(
179
+ quantity_type_code_qualifier: '59',
180
+ quantity: "#{item.despatch_quantity.quantity}"
181
+ )
182
+
183
+ if order_number = message.order_number
184
+ body.segment Eancom::Edifact::RFF.new(
185
+ reference_code_qualifier: 'ON',
186
+ reference_identifier: order_number.reference_identifier,
187
+ document_line_identifier: "#{(index + 1) * 10}"
188
+ )
189
+ end
190
+ end
191
+
192
+ body.segment Eancom::Edifact::UNT.new(
193
+ number_of_segments_in_message: "#{document.total_segments + 2}",
194
+ message_reference_number: '1'
195
+ )
196
+ end
197
+ end
198
+
199
+ document.footer do |footer|
200
+ footer.segment Eancom::Edifact::UNZ.new(
201
+ interchange_control_count: '1',
202
+ interchange_control_reference: "#{config.header.interchange_control_reference}"
203
+ )
204
+ end
205
+ end
@@ -1,106 +1,141 @@
1
- Eancom::Definition.create(name: 'd96a', type: :desadv) do |document, config|
2
- document.envelope do |envelope|
3
- envelope.segment "UNA:+.? '"
4
- envelope.segment "UNB" do |segment|
5
- segment.composite "UNOC:3"
6
- segment.composite "#{config.sender_iln}:14"
7
- segment.composite "#{config.receiver_iln}:14"
8
- segment.composite Time.now.strftime("%y%m%d:%H%M")
9
- segment.composite "#{config.build_id}"
10
- segment.composite
11
- segment.composite "DESADV"
12
- segment.composite
13
- segment.composite
14
- segment.composite "EANCOM"
15
- end
1
+ Eancom::Definition.create(name: 'D96A', type: :desadv) 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: 'DESADV',
16
+ interchange_agreement_identifier: 'EANCOM'
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
+ )
16
27
  end
17
28
 
18
- document.message "UHN" do |message|
19
-
20
- # Message ID
21
- message.composite "1" # Message ID
22
- message.composite "DESADV:D:96A:UN:EAN005"
23
-
24
- message.segment "BGM" do |segment|
25
- segment.composite "351"
26
- segment.composite "#{config.delivery_note_id}"
27
- segment.composite "9"
28
- end
29
+ document.body do |body|
30
+ body.segment Eancom::Edifact::BGM.new(
31
+ document_name_code: '351',
32
+ document_identifier: config.body.document_identifier,
33
+ message_function_code: '9'
34
+ )
29
35
 
30
36
  # Document Date
31
- message.segment "DTM" do |segment|
32
- segment.composite "137:#{Time.now.strftime("%Y%m%d")}:102"
33
- end
37
+ body.segment Eancom::Edifact::DTM.new(
38
+ type: '137',
39
+ date_time: config.body.document_message_date_time,
40
+ format: '102'
41
+ )
34
42
 
35
43
  # Shipping Date
36
- message.segment "DTM" do |segment|
37
- segment.composite "11:#{Time.now.strftime("%Y%m%d")}:102"
38
- end
44
+ body.segment Eancom::Edifact::DTM.new(
45
+ type: '11',
46
+ date_time: config.body.despatch_date_and_or_time,
47
+ format: '102'
48
+ )
39
49
 
40
50
  # Order Reference
41
- message.segment "RFF" do |segment|
42
- segment.composite "VN:#{config.order_id}"
43
- end
51
+ body.segment Eancom::Edifact::RFF.new(
52
+ reference_code_qualifier: 'VN',
53
+ reference_identifier: config.body.document_identifier
54
+ )
44
55
 
45
56
  # Sender ILN
46
- message.segment "NAD" do |segment|
47
- segment.composite "SU"
48
- segment.composite "#{config.sender_iln}::9"
49
- end
57
+ body.segment Eancom::Edifact::NAD.new(
58
+ party_function_code_qualifier: 'SU',
59
+ party_identifier: config.header.interchange_sender_identification,
60
+ code_list_responsible_agancy_code_1: '9'
61
+ )
50
62
 
51
63
  # Manufacturer ILN
52
- message.segment "NAD" do |segment|
53
- segment.composite "MF"
54
- segment.composite "#{config.sender_iln}::9"
55
- end
64
+ body.segment Eancom::Edifact::NAD.new(
65
+ party_function_code_qualifier: 'MF',
66
+ party_identifier: config.header.interchange_sender_identification,
67
+ code_list_responsible_agancy_code_1: '9'
68
+ )
56
69
 
57
70
  # Reciver ILN
58
- message.segment "NAD" do |segment|
59
- segment.composite "BY"
60
- segment.composite "#{config.receiver_iln}::9"
61
- end
71
+ body.segment Eancom::Edifact::NAD.new(
72
+ party_function_code_qualifier: 'BY',
73
+ party_identifier: config.header.interchange_recipient_identification,
74
+ code_list_responsible_agancy_code_1: '9'
75
+ )
62
76
 
63
77
  # Destination ILN
64
- message.segment "NAD" do |segment|
65
- segment.composite "DP"
66
- segment.composite "#{config.receiver_iln}::9"
67
- end
78
+ body.segment Eancom::Edifact::NAD.new(
79
+ party_function_code_qualifier: 'DP',
80
+ party_identifier: config.header.interchange_recipient_identification,
81
+ code_list_responsible_agancy_code_1: '9'
82
+ )
68
83
 
69
84
  # Final Recipient ILN
70
- message.segment "NAD" do |segment|
71
- segment.composite "UC"
72
- segment.composite "#{config.receiver_iln}::9"
73
- end
85
+ body.segment Eancom::Edifact::NAD.new(
86
+ party_function_code_qualifier: 'UC',
87
+ party_identifier: config.header.interchange_recipient_identification,
88
+ code_list_responsible_agancy_code_1: '9'
89
+ )
74
90
 
75
91
  # Delivery Note Mode
76
- message.segment "CPS" do |segment|
77
- segment.composite "1"
78
- end
92
+ body.segment Eancom::Edifact::CPS.new(
93
+ hierarchical_structure_level_identifier: '1'
94
+ )
79
95
 
80
96
  # Items
81
97
  total_quantity = 0
82
- config.items.each_with_index do |item, index|
98
+
99
+ items = config.body.items
100
+
101
+ items.each_with_index do |item, index|
83
102
  total_quantity += item.quantity.to_i
84
103
 
85
- message.segment "LIN" do |segment|
86
- segment.composite "#{index+1}"
87
- segment.composite
88
- segment.composite "#{item.ean}:EN"
89
- end
104
+ body.segment Eancom::Edifact::LIN.new(
105
+ line_item_identifier_1: "#{index + 1}",
106
+ item_identifier: item.ean,
107
+ item_type_identification_code: 'SRV'
108
+ )
90
109
 
91
- message.segment "QTY" do |segment|
92
- segment.composite "12:#{item.quantity}:PCE"
93
- end
110
+ body.segment Eancom::Edifact::QTY.new(
111
+ quantity_type_code_qualifier: '12',
112
+ quantity: "#{item.quantity}"
113
+ )
94
114
  end
95
115
 
96
116
  # Total Quantity
97
- message.segment "CNT" do |segment|
98
- segment.composite "1:#{total_quantity}"
99
- end
117
+ body.segment Eancom::Edifact::CNT.new(
118
+ control_total_type_code_quantifier: '1',
119
+ control_total_value: "#{total_quantity}"
120
+ )
100
121
 
101
122
  # Position Count
102
- message.segment "CNT" do |segment|
103
- segment.composite "2:#{config.items.count}"
104
- end
123
+ body.segment Eancom::Edifact::CNT.new(
124
+ control_total_type_code_quantifier: '2',
125
+ control_total_value: "#{items.count}"
126
+ )
105
127
  end
128
+
129
+ document.footer do |footer|
130
+ footer.segment Eancom::Edifact::UNT.new(
131
+ number_of_segments_in_message: "#{document.total_segments}",
132
+ message_reference_number: '1'
133
+ )
134
+
135
+ footer.segment Eancom::Edifact::UNZ.new(
136
+ interchange_control_count: '1',
137
+ interchange_control_reference: "#{config.body.document_identifier}"
138
+ )
139
+ end
140
+
106
141
  end
@@ -0,0 +1,236 @@
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
+ },
36
+ description: "Allowance or Charge code qualifier",
37
+ required: true
38
+ )
39
+ allowance_or_charge_code_qualifier.add(:allowance_or_charge_code_qualifier, data)
40
+
41
+ structure << allowance_or_charge_code_qualifier
42
+ #==============================================================================
43
+ # Allowance/Charge information
44
+ #==============================================================================
45
+ allowance_charge_information = Eancom::Edifact::Composite.new()
46
+
47
+ data = Eancom::Edifact::Data.new(
48
+ type: String,
49
+ length: 0..35,
50
+ dictionary: nil,
51
+ description: "Allowance or charge identifier",
52
+ required: false
53
+ )
54
+ allowance_charge_information.add(:allowance_or_charge_identifier, data)
55
+
56
+ data = Eancom::Edifact::Data.new(
57
+ type: String,
58
+ length: 0..3,
59
+ dictionary: {
60
+ '64' =>{
61
+ description: 'Special agreement',
62
+ identifier: 'special_agreement',
63
+ },
64
+ '69' =>{
65
+ description: 'Charge for a customer specific finish',
66
+ identifier: 'charge_for_a_customer_specific_finisch',
67
+ },
68
+ '64E' =>{
69
+ description: 'Yearly turnover allowance/charge',
70
+ identifier: 'yearly_turnover_allowance_charge',
71
+ },
72
+ },
73
+ description: "Allowance or charge identification code",
74
+ required: false
75
+ )
76
+ allowance_charge_information.add(:allowance_or_charge_identification_code, data)
77
+
78
+ data = Eancom::Edifact::Data.new(
79
+ type: String,
80
+ length: 0..3,
81
+ dictionary: {
82
+ '1' => {
83
+ description: 'Bill back',
84
+ identifier: 'bill_back',
85
+ },
86
+ '2' => {
87
+ description: 'Off invoice',
88
+ identifier: 'off_invoice',
89
+ },
90
+ '5' => {
91
+ description: 'Charge to be paid by vendor',
92
+ identifier: 'charge_to_be_paid_by_vendor',
93
+ },
94
+ '6' => {
95
+ description: 'Charge to be paid by customer',
96
+ identifier: 'charge_to_be_paid_by_customer',
97
+ },
98
+ },
99
+ description: "Settlement mean code",
100
+ required: false
101
+ )
102
+ allowance_charge_information.add(:settlement_mean_code, data)
103
+
104
+ data = Eancom::Edifact::Data.new(
105
+ type: String,
106
+ length: 0..3,
107
+ dictionary: {
108
+ '1' => {
109
+ description: 'First step of calculation',
110
+ identifier: 'first_step_of_calculation',
111
+ },
112
+ '2' => {
113
+ description: 'Second step of calculation',
114
+ identifier: 'second_step_of_calculation',
115
+ },
116
+ '3' => {
117
+ description: 'Third step of calculation',
118
+ identifier: 'third_step_of_calculation',
119
+ },
120
+ '4' => {
121
+ description: 'Forth step of calculation',
122
+ identifier: 'forth_step_of_calculation',
123
+ },
124
+ '5' => {
125
+ description: 'Fith step of calculation',
126
+ identifier: 'fith_step_of_calculation',
127
+ },
128
+ '6' => {
129
+ description: 'Sixth step of calculation',
130
+ identifier: 'sixth_step_of_calculation',
131
+ },
132
+ '7' => {
133
+ description: 'Seventh step of calculation',
134
+ identifier: 'seventh_step_of_calculation',
135
+ },
136
+ '8' => {
137
+ description: 'Eighth step of calculation',
138
+ identifier: 'eighth_step_of_calculation',
139
+ },
140
+ '9' => {
141
+ description: 'Ninth step of calculation',
142
+ identifier: 'ninth_step_of_calculation',
143
+ },
144
+ },
145
+ description: "Calculation sequence code",
146
+ required: false
147
+ )
148
+ allowance_charge_information.add(:calculation_sequence_code, data)
149
+
150
+ structure << allowance_charge_information
151
+ #==============================================================================
152
+ # Special Services identification
153
+ #==============================================================================
154
+ special_services_identification = Eancom::Edifact::Composite.new()
155
+
156
+ data = Eancom::Edifact::Data.new(
157
+ type: String,
158
+ length: 1..3,
159
+ dictionary: {
160
+ 'AJ' => {
161
+ description: 'Adjustments',
162
+ identifier: 'adjustments'
163
+ },
164
+ 'CAC' => {
165
+ description: 'Cash Discount',
166
+ identifier: 'cash_discount'
167
+ },
168
+ 'AEK' => {
169
+ description: 'Cash on delivery service',
170
+ identifier: 'cash_on_delivery_service'
171
+ },
172
+ 'EAB' => {
173
+ description: 'Early payment allowance',
174
+ identifier: 'early_payment_allowance'
175
+ },
176
+ 'FC' => {
177
+ description: 'Freight charge',
178
+ identifier: 'freght_charge'
179
+ },
180
+ 'FI' => {
181
+ description: 'Finance charge',
182
+ identifier: 'finance_charge'
183
+ },
184
+ 'HD' => {
185
+ description: 'Handling',
186
+ identifier: 'handling'
187
+ },
188
+ 'QD' => {
189
+ description: 'Quantity discount',
190
+ identifier: 'quantity_discount'
191
+ },
192
+ 'X40' => {
193
+ description: 'Allowance/charge regulated by law',
194
+ identifier: 'allowance_charge_regulated_by_law'
195
+ },
196
+ },
197
+ description: "Special service description_code",
198
+ required: false
199
+ )
200
+ special_services_identification.add(:special_service_description_code, data)
201
+
202
+ data = Eancom::Edifact::Data.new(
203
+ type: String,
204
+ length: 0..17,
205
+ description: "Code list identification code",
206
+ required: false
207
+ )
208
+ special_services_identification.add(:code_list_identification_code, data)
209
+
210
+ data = Eancom::Edifact::Data.new(
211
+ type: String,
212
+ length: 0..3,
213
+ dictionary: {
214
+ '9' => {
215
+ description: 'GS1',
216
+ identifier: 'gs1'
217
+ }
218
+ },
219
+ description: "Code list responsible agency code",
220
+ required: false
221
+ )
222
+ special_services_identification.add(:code_list_responsible_agency_code, data)
223
+
224
+ data = Eancom::Edifact::Data.new(
225
+ type: String,
226
+ length: 0..3,
227
+ dictionary: nil,
228
+ description: "Special service description",
229
+ required: false
230
+ )
231
+ special_services_identification.add(:special_service_description_1, data)
232
+ special_services_identification.add(:special_service_description_2, data)
233
+
234
+ structure << special_services_identification
235
+ #==============================================================================
236
+ Eancom.register_structure(tag: 'ALC', structure: structure)