eancom 1.4.0 → 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 -3
- data/.gitlab-ci.yml +11 -13
- data/.ruby-version +1 -1
- data/Gemfile +2 -4
- data/Gemfile.lock +23 -103
- data/README.md +46 -0
- data/definitions/desadv/d01b.rb +139 -93
- data/definitions/desadv/d96a.rb +187 -101
- 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 +128 -0
- 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 +85 -1
- data/definitions/segments/efi.rb +67 -0
- data/definitions/segments/eqd.rb +37 -0
- data/definitions/segments/ftx.rb +24 -2
- data/definitions/segments/gin.rb +113 -0
- data/definitions/segments/imd.rb +5 -1
- data/definitions/segments/inv.rb +94 -0
- data/definitions/segments/lin.rb +23 -3
- 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 +72 -0
- data/definitions/segments/pci.rb +110 -0
- data/definitions/segments/pgi.rb +6 -2
- data/definitions/segments/pia.rb +21 -21
- data/definitions/segments/pri.rb +21 -1
- data/definitions/segments/qty.rb +219 -5
- data/definitions/segments/rff.rb +51 -7
- 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 +7 -7
- data/definitions/segments/unb.rb +4 -4
- 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 +104 -100
- data/definitions/slsrpt/d96a.rb +104 -99
- data/eancom.gemspec +5 -8
- data/lib/eancom/edifact/document.rb +2 -2
- data/lib/eancom/edifact/footer.rb +1 -0
- data/lib/eancom/edifact/segment.rb +2 -2
- 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 -3
- data/lib/eancom/edifact/segments/loc.rb +8 -5
- 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 +33 -0
- 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 +3 -0
- data/lib/eancom/edifact/structure.rb +0 -1
- data/lib/eancom/edifact.rb +15 -1
- data/lib/eancom/factory.rb +1 -1
- data/lib/eancom/parser/document.rb +2 -10
- data/lib/eancom/version.rb +1 -1
- data/lib/eancom.rb +3 -1
- data/pricat.json +1 -0
- metadata +51 -52
- data/.rspec_status +0 -225
- data/.rubocop.yml +0 -2
data/definitions/desadv/d96a.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Eancom::Definition.create(name: 'D96A', type: :desadv) do |document, config|
|
2
2
|
document.header do |header|
|
3
|
-
header.segment Eancom::Edifact::UNA.new
|
3
|
+
header.segment Eancom::Edifact::UNA.new
|
4
4
|
|
5
5
|
header.segment Eancom::Edifact::UNB.new(
|
6
6
|
syntax_identifier: 'UNOC',
|
@@ -12,8 +12,8 @@ Eancom::Definition.create(name: 'D96A', type: :desadv) do |document, config|
|
|
12
12
|
date: config.header.date,
|
13
13
|
time: config.header.time,
|
14
14
|
interchange_control_reference: config.header.interchange_control_reference,
|
15
|
-
application_reference:
|
16
|
-
interchange_agreement_identifier:
|
15
|
+
application_reference: config.header.application_reference,
|
16
|
+
interchange_agreement_identifier: config.header.interchange_agreement_identifier
|
17
17
|
)
|
18
18
|
|
19
19
|
header.segment Eancom::Edifact::UNH.new(
|
@@ -27,115 +27,201 @@ Eancom::Definition.create(name: 'D96A', type: :desadv) do |document, config|
|
|
27
27
|
end
|
28
28
|
|
29
29
|
document.body do |body|
|
30
|
-
body.
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
# Document Date
|
37
|
-
body.segment Eancom::Edifact::DTM.new(
|
38
|
-
type: '137',
|
39
|
-
date_time: config.body.document_message_date_time,
|
40
|
-
format: '102'
|
41
|
-
)
|
42
|
-
|
43
|
-
# Shipping Date
|
44
|
-
body.segment Eancom::Edifact::DTM.new(
|
45
|
-
type: '11',
|
46
|
-
date_time: config.body.despatch_date_and_or_time,
|
47
|
-
format: '102'
|
48
|
-
)
|
49
|
-
|
50
|
-
# Order Reference
|
51
|
-
body.segment Eancom::Edifact::RFF.new(
|
52
|
-
reference_code_qualifier: 'VN',
|
53
|
-
reference_identifier: config.body.document_identifier
|
54
|
-
)
|
55
|
-
|
56
|
-
# Sender ILN
|
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
|
-
)
|
62
|
-
|
63
|
-
# Manufacturer ILN
|
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
|
-
)
|
69
|
-
|
70
|
-
# Reciver ILN
|
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
|
-
)
|
76
|
-
|
77
|
-
# Destination ILN
|
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
|
-
)
|
83
|
-
|
84
|
-
# Final Recipient ILN
|
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
|
-
)
|
90
|
-
|
91
|
-
# Delivery Note Mode
|
92
|
-
body.segment Eancom::Edifact::CPS.new(
|
93
|
-
hierarchical_structure_level_identifier: '1'
|
94
|
-
)
|
95
|
-
|
96
|
-
# Items
|
97
|
-
total_quantity = 0
|
98
|
-
|
99
|
-
items = config.body.items
|
100
|
-
|
101
|
-
items.each_with_index do |item, index|
|
102
|
-
total_quantity += item.quantity.to_i
|
103
|
-
|
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'
|
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
|
+
document_identifier: message.document_identifier,
|
35
|
+
message_function_code: message.message_function_code
|
108
36
|
)
|
109
37
|
|
110
|
-
|
111
|
-
|
112
|
-
|
38
|
+
date_time_messages = message.date_time_messages
|
39
|
+
date_time_messages.each_with_index do |dtm, index|
|
40
|
+
next unless index == 0
|
41
|
+
|
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
|
+
|
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'
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
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
|
70
|
+
body.segment Eancom::Edifact::RFF.new(
|
71
|
+
reference_code_qualifier: structure.dictionary_lookup(:reference_code_qualifier, rff.identifier),
|
72
|
+
reference_identifier: rff[key].reference_identifier
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
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
|
83
|
+
body.segment Eancom::Edifact::NAD.new(
|
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'
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
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
|
97
|
+
body.segment Eancom::Edifact::NAD.new(
|
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'
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
# Reciver ILN
|
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
|
111
|
+
body.segment Eancom::Edifact::NAD.new(
|
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'
|
115
|
+
)
|
116
|
+
end
|
117
|
+
|
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
|
125
|
+
body.segment Eancom::Edifact::NAD.new(
|
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'
|
129
|
+
)
|
130
|
+
end
|
131
|
+
|
132
|
+
# Final Recipient ILN
|
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
|
139
|
+
body.segment Eancom::Edifact::NAD.new(
|
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'
|
143
|
+
)
|
144
|
+
end
|
145
|
+
|
146
|
+
# Delivery Note Mode
|
147
|
+
body.segment Eancom::Edifact::CPS.new(
|
148
|
+
hierarchical_structure_level_identifier: message.hierarchical_structure_level_identifier
|
113
149
|
)
|
114
|
-
end
|
115
150
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
151
|
+
# Items
|
152
|
+
total_quantity = 0
|
153
|
+
|
154
|
+
items = message.items
|
155
|
+
|
156
|
+
items.each_with_index do |item, index|
|
157
|
+
total_quantity += item.quantity.to_i
|
158
|
+
|
159
|
+
structure = Eancom.find_structure(tag: 'LIN')
|
160
|
+
body.segment Eancom::Edifact::LIN.new(
|
161
|
+
line_item_identifier_1: (index + 1).to_s,
|
162
|
+
item_identifier: item.ean,
|
163
|
+
item_type_identification_code: structure.dictionary_lookup(:item_type_identification_code,
|
164
|
+
item.item_type_identification_code)
|
165
|
+
)
|
166
|
+
|
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
|
176
|
+
end
|
177
|
+
end
|
127
178
|
end
|
128
179
|
|
129
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
|
215
|
+
end
|
216
|
+
|
130
217
|
footer.segment Eancom::Edifact::UNT.new(
|
131
|
-
number_of_segments_in_message:
|
132
|
-
message_reference_number:
|
218
|
+
number_of_segments_in_message: document.total_segments.to_s,
|
219
|
+
message_reference_number: config.header.message_reference_number
|
133
220
|
)
|
134
221
|
|
135
222
|
footer.segment Eancom::Edifact::UNZ.new(
|
136
|
-
interchange_control_count:
|
137
|
-
interchange_control_reference:
|
223
|
+
interchange_control_count: messages.size.to_s,
|
224
|
+
interchange_control_reference: config.header.interchange_control_reference.to_s
|
138
225
|
)
|
139
226
|
end
|
140
|
-
|
141
227
|
end
|