eancom 1.6.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +7 -4
- data/.gitlab-ci.yml +11 -13
- data/.ruby-version +1 -1
- data/Gemfile +2 -4
- data/Gemfile.lock +21 -103
- data/README.md +46 -0
- data/definitions/desadv/d01b.rb +134 -87
- data/definitions/desadv/d96a.rb +145 -82
- data/definitions/invoic/d01b.rb +559 -0
- data/definitions/invoic/d96a.rb +389 -0
- data/definitions/invrpt/d01b.rb +134 -0
- data/definitions/invrpt/d96a.rb +125 -0
- data/definitions/orders/d01b.rb +182 -0
- data/definitions/orders/d96b.rb +198 -0
- data/definitions/ordrsp/d01b.rb +251 -0
- data/definitions/ordrsp/d96b.rb +226 -0
- data/definitions/pricat/d01b.rb +225 -0
- data/definitions/pricat/d96b.rb +207 -0
- data/definitions/retann/d01b.rb +172 -0
- data/definitions/retann/d96b.rb +221 -0
- data/definitions/segments/ajt.rb +47 -0
- data/definitions/segments/alc.rb +128 -36
- data/definitions/segments/bgm.rb +122 -2
- data/definitions/segments/cdi.rb +39 -0
- data/definitions/segments/cnt.rb +4 -0
- data/definitions/segments/cta.rb +89 -0
- data/definitions/segments/cux.rb +9 -2
- data/definitions/segments/dgs.rb +34 -0
- data/definitions/segments/doc.rb +45 -0
- data/definitions/segments/dtm.rb +75 -20
- data/definitions/segments/efi.rb +67 -0
- data/definitions/segments/eqd.rb +37 -0
- data/definitions/segments/ftx.rb +22 -8
- data/definitions/segments/gin.rb +113 -0
- data/definitions/segments/imd.rb +9 -13
- data/definitions/segments/inv.rb +94 -0
- data/definitions/segments/lin.rb +24 -4
- data/definitions/segments/loc.rb +52 -4
- data/definitions/segments/moa.rb +86 -2
- data/definitions/segments/nad.rb +69 -9
- data/definitions/segments/pac.rb +12 -0
- data/definitions/segments/pat.rb +171 -0
- data/definitions/segments/pcd.rb +9 -92
- data/definitions/segments/pci.rb +110 -0
- data/definitions/segments/pgi.rb +7 -3
- data/definitions/segments/pia.rb +21 -29
- data/definitions/segments/pri.rb +25 -13
- data/definitions/segments/qty.rb +204 -2
- data/definitions/segments/rff.rb +49 -13
- data/definitions/segments/rte.rb +52 -0
- data/definitions/segments/tax.rb +17 -10
- data/definitions/segments/tdt.rb +24 -0
- data/definitions/segments/tod.rb +64 -0
- data/definitions/segments/tru.rb +34 -0
- data/definitions/segments/una.rb +8 -8
- data/definitions/segments/unb.rb +4 -7
- data/definitions/segments/unh.rb +70 -5
- data/definitions/segments/uns.rb +2 -2
- data/definitions/segments/unt.rb +2 -2
- data/definitions/slsrpt/d01b.rb +132 -128
- data/definitions/slsrpt/d96a.rb +132 -129
- data/eancom.gemspec +5 -8
- data/lib/eancom/edifact/body.rb +37 -18
- data/lib/eancom/edifact/document.rb +20 -16
- data/lib/eancom/edifact/footer.rb +1 -0
- data/lib/eancom/edifact/item.rb +1 -1
- data/lib/eancom/edifact/message.rb +7 -39
- data/lib/eancom/edifact/segment.rb +9 -11
- data/lib/eancom/edifact/segments/ajt.rb +32 -0
- data/lib/eancom/edifact/segments/ali.rb +2 -4
- data/lib/eancom/edifact/segments/bgm.rb +4 -3
- data/lib/eancom/edifact/segments/cdi.rb +30 -0
- data/lib/eancom/edifact/segments/cnt.rb +8 -1
- data/lib/eancom/edifact/segments/cps.rb +4 -1
- data/lib/eancom/edifact/segments/cta.rb +30 -0
- data/lib/eancom/edifact/segments/cux.rb +1 -1
- data/lib/eancom/edifact/segments/dgs.rb +31 -0
- data/lib/eancom/edifact/segments/doc.rb +30 -0
- data/lib/eancom/edifact/segments/dtm.rb +10 -6
- data/lib/eancom/edifact/segments/efi.rb +38 -0
- data/lib/eancom/edifact/segments/eqd.rb +30 -0
- data/lib/eancom/edifact/segments/ftx.rb +2 -2
- data/lib/eancom/edifact/segments/gin.rb +45 -0
- data/lib/eancom/edifact/segments/imd.rb +1 -1
- data/lib/eancom/edifact/segments/inv.rb +43 -0
- data/lib/eancom/edifact/segments/lin.rb +7 -4
- data/lib/eancom/edifact/segments/loc.rb +8 -9
- data/lib/eancom/edifact/segments/mea.rb +1 -0
- data/lib/eancom/edifact/segments/moa.rb +3 -3
- data/lib/eancom/edifact/segments/nad.rb +11 -6
- data/lib/eancom/edifact/segments/pac.rb +3 -1
- data/lib/eancom/edifact/segments/pat.rb +37 -0
- data/lib/eancom/edifact/segments/pcd.rb +6 -17
- data/lib/eancom/edifact/segments/pci.rb +40 -0
- data/lib/eancom/edifact/segments/pia.rb +1 -0
- data/lib/eancom/edifact/segments/pri.rb +0 -1
- data/lib/eancom/edifact/segments/qty.rb +9 -5
- data/lib/eancom/edifact/segments/rff.rb +8 -2
- data/lib/eancom/edifact/segments/rte.rb +33 -0
- data/lib/eancom/edifact/segments/tax.rb +7 -1
- data/lib/eancom/edifact/segments/tdt.rb +4 -1
- data/lib/eancom/edifact/segments/tod.rb +33 -0
- data/lib/eancom/edifact/segments/tru.rb +31 -0
- data/lib/eancom/edifact/segments/una.rb +2 -1
- data/lib/eancom/edifact/segments/unb.rb +4 -5
- data/lib/eancom/edifact/segments/unh.rb +6 -4
- data/lib/eancom/edifact/segments/uns.rb +4 -1
- data/lib/eancom/edifact/structure.rb +0 -1
- data/lib/eancom/edifact.rb +15 -4
- data/lib/eancom/factory.rb +1 -1
- data/lib/eancom/parser/document.rb +3 -16
- data/lib/eancom/parser/segment.rb +9 -10
- data/lib/eancom/version.rb +1 -3
- data/lib/eancom.rb +3 -1
- data/pricat.json +1 -0
- metadata +45 -51
- data/.rubocop.yml +0 -2
- data/.tool-versions +0 -1
- data/definitions/segments/qvr.rb +0 -140
- data/lib/eancom/edifact/location.rb +0 -56
- data/lib/eancom/edifact/segments/qvr.rb +0 -50
data/definitions/desadv/d96a.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
Eancom::Definition.create(name: 'D96A', type: :desadv) do |document, config|
|
4
2
|
document.header do |header|
|
3
|
+
header.segment Eancom::Edifact::UNA.new
|
4
|
+
|
5
5
|
header.segment Eancom::Edifact::UNB.new(
|
6
|
-
syntax_identifier: '
|
7
|
-
syntax_version_number: '
|
6
|
+
syntax_identifier: 'UNOC',
|
7
|
+
syntax_version_number: '3',
|
8
8
|
interchange_sender_identification: config.header.interchange_sender_identification,
|
9
|
-
sender_identifiction_code_qualifier:
|
9
|
+
sender_identifiction_code_qualifier: '14',
|
10
10
|
interchange_recipient_identification: config.header.interchange_recipient_identification,
|
11
|
-
recipient_identifiction_code_qualifier:
|
11
|
+
recipient_identifiction_code_qualifier: '14',
|
12
12
|
date: config.header.date,
|
13
13
|
time: config.header.time,
|
14
|
-
interchange_control_reference: config.header.interchange_control_reference
|
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
|
15
17
|
)
|
16
18
|
|
17
19
|
header.segment Eancom::Edifact::UNH.new(
|
@@ -26,92 +28,124 @@ Eancom::Definition.create(name: 'D96A', type: :desadv) do |document, config|
|
|
26
28
|
|
27
29
|
document.body do |body|
|
28
30
|
messages = config.body.messages
|
29
|
-
|
30
31
|
messages.each do |message|
|
31
32
|
body.segment Eancom::Edifact::BGM.new(
|
32
|
-
document_name_code:
|
33
|
+
document_name_code: message.document_name_code,
|
33
34
|
document_identifier: message.document_identifier,
|
34
|
-
message_function_code:
|
35
|
+
message_function_code: message.message_function_code
|
35
36
|
)
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
date_time: message.document_message_date_time.date_time,
|
41
|
-
format: '102'
|
42
|
-
)
|
38
|
+
date_time_messages = message.date_time_messages
|
39
|
+
date_time_messages.each_with_index do |dtm, index|
|
40
|
+
next unless index == 0
|
43
41
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
43
|
+
key = dtm.identifier.intern.to_sym
|
44
|
+
body.segment Eancom::Edifact::DTM.new(
|
45
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
46
|
+
date_time: dtm[key].date_time,
|
47
|
+
format: '102'
|
48
|
+
)
|
49
|
+
end
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
date_time_messages = message.date_time_messages
|
52
|
+
date_time_messages.each_with_index do |dtm, index|
|
53
|
+
next unless index == 1
|
54
|
+
|
55
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
56
|
+
key = dtm.identifier.intern.to_sym
|
57
|
+
body.segment Eancom::Edifact::DTM.new(
|
58
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
59
|
+
date_time: dtm[key].date_time,
|
60
|
+
format: '102'
|
56
61
|
)
|
57
62
|
end
|
58
63
|
|
59
|
-
|
64
|
+
references = message.references
|
65
|
+
references.each_with_index do |rff, index|
|
66
|
+
next unless index == 0
|
67
|
+
|
68
|
+
structure = Eancom.find_structure(tag: 'RFF')
|
69
|
+
key = rff.identifier.intern.to_sym
|
60
70
|
body.segment Eancom::Edifact::RFF.new(
|
61
|
-
reference_code_qualifier:
|
62
|
-
reference_identifier:
|
71
|
+
reference_code_qualifier: structure.dictionary_lookup(:reference_code_qualifier, rff.identifier),
|
72
|
+
reference_identifier: rff[key].reference_identifier
|
63
73
|
)
|
64
74
|
end
|
65
75
|
|
66
|
-
|
67
|
-
|
76
|
+
# Sender ILN
|
77
|
+
nads = message.nads
|
78
|
+
nads.each_with_index do |nad, index|
|
79
|
+
next unless index == 0
|
80
|
+
|
81
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
82
|
+
key = nad.identifier.intern.to_sym
|
68
83
|
body.segment Eancom::Edifact::NAD.new(
|
69
|
-
party_function_code_qualifier:
|
70
|
-
party_identifier:
|
71
|
-
|
84
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
85
|
+
party_identifier: nad[key].party_identifier,
|
86
|
+
code_list_responsible_agency_code_1: '9'
|
72
87
|
)
|
73
|
-
|
74
88
|
end
|
75
89
|
|
76
|
-
|
77
|
-
|
90
|
+
# Manufacturer ILN
|
91
|
+
nads = message.nads
|
92
|
+
nads.each_with_index do |nad, index|
|
93
|
+
next unless index == 1
|
94
|
+
|
95
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
96
|
+
key = nad.identifier.intern.to_sym
|
78
97
|
body.segment Eancom::Edifact::NAD.new(
|
79
|
-
party_function_code_qualifier:
|
80
|
-
party_identifier:
|
81
|
-
|
98
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
99
|
+
party_identifier: nad[key].party_identifier,
|
100
|
+
code_list_responsible_agency_code_1: '9'
|
82
101
|
)
|
83
102
|
end
|
84
103
|
|
85
104
|
# Reciver ILN
|
86
|
-
|
105
|
+
nads = message.nads
|
106
|
+
nads.each_with_index do |nad, index|
|
107
|
+
next unless index == 2
|
108
|
+
|
109
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
110
|
+
key = nad.identifier.intern.to_sym
|
87
111
|
body.segment Eancom::Edifact::NAD.new(
|
88
|
-
party_function_code_qualifier:
|
89
|
-
party_identifier:
|
90
|
-
|
112
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
113
|
+
party_identifier: nad[key].party_identifier,
|
114
|
+
code_list_responsible_agency_code_1: '9'
|
91
115
|
)
|
92
116
|
end
|
93
117
|
|
94
|
-
#
|
95
|
-
|
118
|
+
# Destination ILN
|
119
|
+
nads = message.nads
|
120
|
+
nads.each_with_index do |nad, index|
|
121
|
+
next unless index == 3
|
122
|
+
|
123
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
124
|
+
key = nad.identifier.intern.to_sym
|
96
125
|
body.segment Eancom::Edifact::NAD.new(
|
97
|
-
party_function_code_qualifier:
|
98
|
-
party_identifier:
|
99
|
-
|
126
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
127
|
+
party_identifier: nad[key].party_identifier,
|
128
|
+
code_list_responsible_agency_code_1: '9'
|
100
129
|
)
|
101
130
|
end
|
102
131
|
|
103
132
|
# Final Recipient ILN
|
104
|
-
|
133
|
+
nads = message.nads
|
134
|
+
nads.each_with_index do |nad, index|
|
135
|
+
next unless index == 4
|
136
|
+
|
137
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
138
|
+
key = nad.identifier.intern.to_sym
|
105
139
|
body.segment Eancom::Edifact::NAD.new(
|
106
|
-
party_function_code_qualifier:
|
107
|
-
party_identifier:
|
108
|
-
|
140
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
141
|
+
party_identifier: nad[key].party_identifier,
|
142
|
+
code_list_responsible_agency_code_1: '9'
|
109
143
|
)
|
110
144
|
end
|
111
145
|
|
112
146
|
# Delivery Note Mode
|
113
147
|
body.segment Eancom::Edifact::CPS.new(
|
114
|
-
hierarchical_structure_level_identifier:
|
148
|
+
hierarchical_structure_level_identifier: message.hierarchical_structure_level_identifier
|
115
149
|
)
|
116
150
|
|
117
151
|
# Items
|
@@ -119,45 +153,74 @@ Eancom::Definition.create(name: 'D96A', type: :desadv) do |document, config|
|
|
119
153
|
|
120
154
|
items = message.items
|
121
155
|
|
122
|
-
items.each_with_index do |item,
|
123
|
-
|
124
|
-
total_quantity += dispatch_quantity.quantity.to_i
|
156
|
+
items.each_with_index do |item, index|
|
157
|
+
total_quantity += item.quantity.to_i
|
125
158
|
|
159
|
+
structure = Eancom.find_structure(tag: 'LIN')
|
126
160
|
body.segment Eancom::Edifact::LIN.new(
|
127
|
-
line_item_identifier_1:
|
161
|
+
line_item_identifier_1: (index + 1).to_s,
|
128
162
|
item_identifier: item.ean,
|
129
|
-
item_type_identification_code:
|
163
|
+
item_type_identification_code: structure.dictionary_lookup(:item_type_identification_code,
|
164
|
+
item.item_type_identification_code)
|
130
165
|
)
|
131
166
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
167
|
+
quantities = item.quantities
|
168
|
+
quantities.each_with_index do |qty, index|
|
169
|
+
structure = Eancom.find_structure(tag: 'QTY')
|
170
|
+
key = qty.identifier.intern.to_sym
|
171
|
+
body.segment Eancom::Edifact::QTY.new(
|
172
|
+
quantity_type_code_qualifier: structure.dictionary_lookup(:quantity_type_code_qualifier, qty.identifier),
|
173
|
+
quantity: qty[key].quantity
|
174
|
+
)
|
175
|
+
end
|
137
176
|
end
|
177
|
+
end
|
178
|
+
end
|
138
179
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
180
|
+
document.footer do |footer|
|
181
|
+
messages = config.body.messages
|
182
|
+
messages.each do |message|
|
183
|
+
items = message.items
|
184
|
+
control_total_value = 0
|
185
|
+
|
186
|
+
items.each_with_index do |item, index|
|
187
|
+
quantities = item.quantities
|
188
|
+
quantities.each do |qty|
|
189
|
+
key = qty.identifier.intern.to_sym
|
190
|
+
control_total_value += qty[key].quantity.to_i
|
191
|
+
end
|
192
|
+
next unless index == 1
|
193
|
+
counts = item.counts
|
194
|
+
counts.each_with_index do |cnt, cnt_index|
|
195
|
+
next unless cnt_index == 0
|
196
|
+
structure = Eancom.find_structure(tag: 'CNT')
|
197
|
+
footer.segment Eancom::Edifact::CNT.new(
|
198
|
+
control_total_type_code_quantifier: structure.dictionary_lookup(:control_total_type_code_quantifier,
|
199
|
+
cnt.control_total_type_code_quantifier),
|
200
|
+
control_total_value: control_total_value.to_s
|
201
|
+
)
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
counts.each_with_index do |cnt, cnt_index|
|
206
|
+
next unless cnt_index == 1
|
207
|
+
structure = Eancom.find_structure(tag: 'CNT')
|
208
|
+
footer.segment Eancom::Edifact::CNT.new(
|
209
|
+
control_total_type_code_quantifier: structure.dictionary_lookup(:control_total_type_code_quantifier,
|
210
|
+
cnt.control_total_type_code_quantifier),
|
211
|
+
control_total_value: items.count.to_s
|
212
|
+
)
|
213
|
+
end
|
214
|
+
end
|
150
215
|
end
|
151
216
|
|
152
|
-
|
153
|
-
number_of_segments_in_message:
|
154
|
-
message_reference_number: config.header.
|
217
|
+
footer.segment Eancom::Edifact::UNT.new(
|
218
|
+
number_of_segments_in_message: document.total_segments.to_s,
|
219
|
+
message_reference_number: config.header.message_reference_number
|
155
220
|
)
|
156
|
-
end
|
157
221
|
|
158
|
-
document.footer do |footer|
|
159
222
|
footer.segment Eancom::Edifact::UNZ.new(
|
160
|
-
interchange_control_count:
|
223
|
+
interchange_control_count: messages.size.to_s,
|
161
224
|
interchange_control_reference: config.header.interchange_control_reference.to_s
|
162
225
|
)
|
163
226
|
end
|