eancom 1.6.2 → 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 +208 -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 -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 +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
@@ -0,0 +1,226 @@
|
|
1
|
+
Eancom::Definition.create(name: 'D96A', type: :ordrsp) 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
|
+
test_indicator: nil
|
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
|
+
messages = config.body.messages
|
32
|
+
|
33
|
+
messages.each do |message|
|
34
|
+
structure = Eancom.find_structure(tag: 'BGM')
|
35
|
+
body.segment Eancom::Edifact::BGM.new(
|
36
|
+
document_name_code: message.document_name_code,
|
37
|
+
document_identifier: message.document_identifier,
|
38
|
+
message_function_code: message.message_function_code
|
39
|
+
)
|
40
|
+
|
41
|
+
date_time_messages = message.date_time_messages
|
42
|
+
date_time_messages.each_with_index do |dtm, index|
|
43
|
+
next unless index == 0
|
44
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
45
|
+
key = dtm.identifier.intern.to_sym
|
46
|
+
body.segment Eancom::Edifact::DTM.new(
|
47
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
48
|
+
date_time: dtm[key].date_time,
|
49
|
+
format: '102'
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
references = message.references
|
54
|
+
references.each_with_index do |rff, index|
|
55
|
+
next unless index == 0
|
56
|
+
structure = Eancom.find_structure(tag: 'RFF')
|
57
|
+
key = rff.identifier.intern.to_sym
|
58
|
+
body.segment Eancom::Edifact::RFF.new(
|
59
|
+
reference_code_qualifier: structure.dictionary_lookup(:reference_code_qualifier, rff.identifier),
|
60
|
+
reference_identifier: rff[key].reference_identifier
|
61
|
+
)
|
62
|
+
end
|
63
|
+
|
64
|
+
date_time_messages.each_with_index do |dtm, index|
|
65
|
+
next unless index == 1
|
66
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
67
|
+
key = dtm.identifier.intern.to_sym
|
68
|
+
body.segment Eancom::Edifact::DTM.new(
|
69
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
70
|
+
date_time: dtm[key].date_time,
|
71
|
+
format: '102'
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
nads = message.nads
|
76
|
+
nads.each_with_index do |nad, index|
|
77
|
+
next unless index == 0
|
78
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
79
|
+
key = nad.identifier.intern.to_sym
|
80
|
+
body.segment Eancom::Edifact::NAD.new(
|
81
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
82
|
+
party_identifier: nad[key].party_identifier,
|
83
|
+
code_list_responsible_agency_code_1: '9'
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
structure = Eancom.find_structure(tag: 'CTA')
|
88
|
+
body.segment Eancom::Edifact::CTA.new(
|
89
|
+
contact_function_code: structure.dictionary_lookup(:contact_function_code, message.contact_function_code)
|
90
|
+
)
|
91
|
+
|
92
|
+
nads.each_with_index do |nad, index|
|
93
|
+
next unless index == 1
|
94
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
95
|
+
key = nad.identifier.intern.to_sym
|
96
|
+
body.segment Eancom::Edifact::NAD.new(
|
97
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
98
|
+
party_identifier: nad[key].party_identifier,
|
99
|
+
code_list_responsible_agency_code_1: '9'
|
100
|
+
)
|
101
|
+
end
|
102
|
+
|
103
|
+
nads.each_with_index do |nad, index|
|
104
|
+
next unless index == 2
|
105
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
106
|
+
key = nad.identifier.intern.to_sym
|
107
|
+
body.segment Eancom::Edifact::NAD.new(
|
108
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
109
|
+
party_identifier: nad[key].party_identifier,
|
110
|
+
code_list_responsible_agency_code_1: '9'
|
111
|
+
)
|
112
|
+
end
|
113
|
+
|
114
|
+
structure = Eancom.find_structure(tag: 'CTA')
|
115
|
+
body.segment Eancom::Edifact::CTA.new(
|
116
|
+
contact_function_code: structure.dictionary_lookup(:contact_function_code, message.contact_function_code)
|
117
|
+
)
|
118
|
+
|
119
|
+
structure = Eancom.find_structure(tag: 'CUX')
|
120
|
+
body.segment Eancom::Edifact::CUX.new(
|
121
|
+
currency_usage_code_qualifier_1: structure.dictionary_lookup(:currency_usage_code_qualifier_1, message.currency.currency_usage_code_qualifier_1),
|
122
|
+
currency_identification_code_1: message.currency.currency_identification_code_1
|
123
|
+
)
|
124
|
+
|
125
|
+
total_quantity = 0
|
126
|
+
|
127
|
+
items = message.items
|
128
|
+
|
129
|
+
items.each_with_index do |item, index|
|
130
|
+
total_quantity += item.quantity.to_i
|
131
|
+
|
132
|
+
structure = Eancom.find_structure(tag: 'LIN')
|
133
|
+
body.segment Eancom::Edifact::LIN.new(
|
134
|
+
line_item_identifier_1: (index + 1).to_s,
|
135
|
+
item_identifier: item.ean,
|
136
|
+
action_request_notification_description_code: item.action_request_notification_description_code,
|
137
|
+
item_type_identification_code: structure.dictionary_lookup(:item_type_identification_code, item.item_type_identification_code)
|
138
|
+
)
|
139
|
+
|
140
|
+
qty = item.quantities
|
141
|
+
qty.each_with_index do |qty, index|
|
142
|
+
next unless index == 0
|
143
|
+
structure = Eancom.find_structure(tag: 'QTY')
|
144
|
+
key = qty.identifier.intern.to_sym
|
145
|
+
body.segment Eancom::Edifact::QTY.new(
|
146
|
+
quantity_type_code_qualifier: structure.dictionary_lookup(:quantity_type_code_qualifier, qty.identifier),
|
147
|
+
quantity: qty[key].quantity,
|
148
|
+
measurement_unit_code: structure.dictionary_lookup(:measurement_unit_code, qty.measurement_unit_code)
|
149
|
+
)
|
150
|
+
end
|
151
|
+
|
152
|
+
qty.each_with_index do |qty, index|
|
153
|
+
next unless index == 1
|
154
|
+
structure = Eancom.find_structure(tag: 'QTY')
|
155
|
+
key = qty.identifier.intern.to_sym
|
156
|
+
body.segment Eancom::Edifact::QTY.new(
|
157
|
+
quantity_type_code_qualifier: structure.dictionary_lookup(:quantity_type_code_qualifier, qty.identifier),
|
158
|
+
quantity: qty[key].quantity,
|
159
|
+
measurement_unit_code: structure.dictionary_lookup(:measurement_unit_code, qty.measurement_unit_code)
|
160
|
+
)
|
161
|
+
end
|
162
|
+
|
163
|
+
date_time_messages = item.date_time_messages
|
164
|
+
date_time_messages.each_with_index do |dtm, index|
|
165
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
166
|
+
key = dtm.identifier.intern.to_sym
|
167
|
+
body.segment Eancom::Edifact::DTM.new(
|
168
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
169
|
+
date_time: dtm[key].date_time,
|
170
|
+
format: '102'
|
171
|
+
)
|
172
|
+
end
|
173
|
+
|
174
|
+
prices = item.prices
|
175
|
+
prices.each do |price|
|
176
|
+
next unless price = price.price
|
177
|
+
|
178
|
+
structure = Eancom.find_structure(tag: 'PRI')
|
179
|
+
body.segment Eancom::Edifact::PRI.new(
|
180
|
+
price_code_qualifier: structure.dictionary_lookup(:price_code_qualifier,
|
181
|
+
price.price_code_qualifier),
|
182
|
+
price_amount: price.price_amount,
|
183
|
+
price_type_code: structure.dictionary_lookup(:price_type_code, price.price_type_code),
|
184
|
+
price_specification_code: structure.dictionary_lookup(:price_specification_code,
|
185
|
+
price.price_specification_code)
|
186
|
+
)
|
187
|
+
end
|
188
|
+
|
189
|
+
structure = Eancom.find_structure(tag: 'CUX')
|
190
|
+
body.segment Eancom::Edifact::CUX.new(
|
191
|
+
currency_usage_code_qualifier_1: structure.dictionary_lookup(:currency_usage_code_qualifier_1, message.currency.currency_usage_code_qualifier_1),
|
192
|
+
currency_identification_code_1: message.currency.currency_identification_code_1,
|
193
|
+
currency_type_code_qualifier_1: message.currency.currency_type_code_qualifier_1
|
194
|
+
)
|
195
|
+
|
196
|
+
references = item.references
|
197
|
+
references.each_with_index do |rff, index|
|
198
|
+
next unless index == 0
|
199
|
+
structure = Eancom.find_structure(tag: 'RFF')
|
200
|
+
key = rff.identifier.intern.to_sym
|
201
|
+
body.segment Eancom::Edifact::RFF.new(
|
202
|
+
reference_code_qualifier: structure.dictionary_lookup(:reference_code_qualifier, rff.identifier),
|
203
|
+
reference_identifier: rff[key].reference_identifier,
|
204
|
+
document_line_identifier: rff[key].document_line_identifier
|
205
|
+
)
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
document.footer do |footer|
|
212
|
+
messages = config.body.messages
|
213
|
+
|
214
|
+
footer.segment Eancom::Edifact::UNS.new(
|
215
|
+
section_identification: 'S'
|
216
|
+
)
|
217
|
+
footer.segment Eancom::Edifact::UNT.new(
|
218
|
+
number_of_segments_in_message: (document.total_segments + 2).to_s,
|
219
|
+
message_reference_number: config.header.message_reference_number
|
220
|
+
)
|
221
|
+
footer.segment Eancom::Edifact::UNZ.new(
|
222
|
+
interchange_control_count: messages.size.to_s,
|
223
|
+
interchange_control_reference: config.header.interchange_control_reference.to_s
|
224
|
+
)
|
225
|
+
end
|
226
|
+
end
|
@@ -0,0 +1,225 @@
|
|
1
|
+
Eancom::Definition.create(name: 'D01B', type: :pricat) 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
|
+
test_indicator: nil
|
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
|
+
messages = config.body.messages
|
32
|
+
|
33
|
+
messages.each do |message|
|
34
|
+
body.segment Eancom::Edifact::BGM.new(
|
35
|
+
document_name_code: message.document_name_code,
|
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
|
+
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
|
+
nads = message.nads
|
52
|
+
nads.each_with_index do |nad, index|
|
53
|
+
next unless index == 0
|
54
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
55
|
+
key = nad.identifier.intern.to_sym
|
56
|
+
body.segment Eancom::Edifact::NAD.new(
|
57
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
58
|
+
party_identifier: nad[key].party_identifier,
|
59
|
+
code_list_responsible_agency_code_1: '9'
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
nads.each_with_index do |nad, index|
|
64
|
+
next unless index == 1
|
65
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
66
|
+
key = nad.identifier.intern.to_sym
|
67
|
+
body.segment Eancom::Edifact::NAD.new(
|
68
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
69
|
+
party_identifier: nad[key].party_identifier,
|
70
|
+
code_list_responsible_agency_code_1: '9'
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
structure = Eancom.find_structure(tag: 'CUX')
|
75
|
+
body.segment Eancom::Edifact::CUX.new(
|
76
|
+
currency_usage_code_qualifier_1: structure.dictionary_lookup(:currency_usage_code_qualifier_1, message.currency.currency_usage_code_qualifier_1),
|
77
|
+
currency_identification_code_1: message.currency.currency_identification_code_1,
|
78
|
+
currency_type_code_qualifier_1: structure.dictionary_lookup(:currency_type_code_qualifier_1,
|
79
|
+
message.currency.currency_type_code_qualifier_1)
|
80
|
+
)
|
81
|
+
|
82
|
+
structure = Eancom.find_structure(tag: 'PGI')
|
83
|
+
body.segment Eancom::Edifact::PGI.new(
|
84
|
+
product_group_type_code: structure.dictionary_lookup(:product_group_type_code, message.product_group_identifier)
|
85
|
+
)
|
86
|
+
|
87
|
+
total_quantity = 0
|
88
|
+
|
89
|
+
items = message.items
|
90
|
+
items.each_with_index do |item, index|
|
91
|
+
total_quantity += item.quantity.to_i
|
92
|
+
|
93
|
+
structure = Eancom.find_structure(tag: 'LIN')
|
94
|
+
body.segment Eancom::Edifact::LIN.new(
|
95
|
+
line_item_identifier_1: (index + 1).to_s,
|
96
|
+
item_identifier: item.ean,
|
97
|
+
action_request_notification_description_code: item.action_request_notification_description_code,
|
98
|
+
item_type_identification_code: structure.dictionary_lookup(:item_type_identification_code, item.item_type_identification_code),
|
99
|
+
sub_line_indicator_code: item.sub_line_indicator_code,
|
100
|
+
line_item_identifier_2: item.line_item_identifier_2
|
101
|
+
)
|
102
|
+
|
103
|
+
if additional_product_id = item.additional_product_id
|
104
|
+
additional_product_id.each do |id|
|
105
|
+
next unless additional_information = id.additional_information
|
106
|
+
|
107
|
+
structure = Eancom.find_structure(tag: 'PIA')
|
108
|
+
body.segment Eancom::Edifact::PIA.new(
|
109
|
+
product_identifier_code_qualifier: additional_information.product_identifier_code_qualifier,
|
110
|
+
item_identifier_1: additional_information.item_identifier_1,
|
111
|
+
item_type_identification_code_1: structure.dictionary_lookup(:item_type_identification_code_1,
|
112
|
+
additional_information.item_type_identification_code_1),
|
113
|
+
code_list_responsible_agency_code_1: additional_information.code_list_identification_code_1
|
114
|
+
)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
item_descriptions = item.item_descriptions
|
119
|
+
item_descriptions.each do |description|
|
120
|
+
structure = Eancom.find_structure(tag: 'IMD')
|
121
|
+
if description.item_description_code != ''
|
122
|
+
item_description_code = structure.dictionary_lookup(:item_description_code,
|
123
|
+
description.item_description_code)
|
124
|
+
else
|
125
|
+
item_description_code = ''
|
126
|
+
end
|
127
|
+
body.segment Eancom::Edifact::IMD.new(
|
128
|
+
description_format_code: structure.dictionary_lookup(:description_format_code,
|
129
|
+
description.description_format_code),
|
130
|
+
item_characteristic_code: structure.dictionary_lookup(:item_characteristic_code,
|
131
|
+
description.item_characteristic_code),
|
132
|
+
item_description_code: item_description_code,
|
133
|
+
code_list_identification_code_1: description.code_list_identification_code_1,
|
134
|
+
code_list_responsible_agency_code_1: structure.dictionary_lookup(:code_list_responsible_agency_code_1,
|
135
|
+
description.code_list_responsible_agency_code_1),
|
136
|
+
item_description_1: description.item_description_1,
|
137
|
+
language_name_code: description.language_name_code
|
138
|
+
)
|
139
|
+
end
|
140
|
+
|
141
|
+
date_time_messages = item.date_time_messages
|
142
|
+
date_time_messages.each_with_index do |dtm, index|
|
143
|
+
next unless index == 0
|
144
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
145
|
+
key = dtm.identifier.intern.to_sym
|
146
|
+
body.segment Eancom::Edifact::DTM.new(
|
147
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
148
|
+
date_time: dtm[key].date_time,
|
149
|
+
format: '102'
|
150
|
+
)
|
151
|
+
end
|
152
|
+
|
153
|
+
date_time_messages.each_with_index do |dtm, index|
|
154
|
+
next unless index == 1
|
155
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
156
|
+
key = dtm.identifier.intern.to_sym
|
157
|
+
body.segment Eancom::Edifact::DTM.new(
|
158
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
159
|
+
date_time: dtm[key].date_time,
|
160
|
+
format: '102'
|
161
|
+
)
|
162
|
+
end
|
163
|
+
|
164
|
+
if taxes = item.taxes
|
165
|
+
taxes.each do |tax|
|
166
|
+
next unless tax = tax.tax
|
167
|
+
|
168
|
+
structure = Eancom.find_structure(tag: 'TAX')
|
169
|
+
body.segment Eancom::Edifact::TAX.new(
|
170
|
+
duty_or_tax_or_fee_function_code_qualifier: '7',
|
171
|
+
duty_or_tax_or_fee_name_code: structure.dictionary_lookup(:duty_or_tax_or_fee_name_code,
|
172
|
+
tax.duty_or_tax_or_fee_name_code),
|
173
|
+
duty_or_tax_or_fee_account_code: tax.duty_or_tax_or_fee_account_code,
|
174
|
+
duty_tax_fee_rate_code: tax.duty_tax_fee_rate_code,
|
175
|
+
code_list_identification_code_3: tax.code_list_identification_code_3,
|
176
|
+
code_list_responsibility_agency_code_2: tax.code_list_responsibility_agency_code_2,
|
177
|
+
code_list_responsibility_agency_code_3: tax.code_list_responsibility_agency_code_3,
|
178
|
+
code_list_responsibility_agency_code_4: '21',
|
179
|
+
duty_or_tax_or_fee_category_code: structure.dictionary_lookup(:duty_or_tax_or_fee_category_code,
|
180
|
+
tax.duty_or_tax_or_fee_category_code)
|
181
|
+
)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
prices = item.prices
|
186
|
+
prices.each do |price|
|
187
|
+
next unless price = price.price
|
188
|
+
|
189
|
+
structure = Eancom.find_structure(tag: 'PRI')
|
190
|
+
body.segment Eancom::Edifact::PRI.new(
|
191
|
+
price_code_qualifier: structure.dictionary_lookup(:price_code_qualifier, price.price_code_qualifier),
|
192
|
+
price_amount: price.price_amount,
|
193
|
+
price_type_code: structure.dictionary_lookup(:price_type_code, price.price_type_code),
|
194
|
+
price_specification_code: structure.dictionary_lookup(:price_specification_code,
|
195
|
+
price.price_specification_code),
|
196
|
+
unit_price_basis_value: price.unit_price_basis_value,
|
197
|
+
measurment_unit_code: price.measurment_unit_code
|
198
|
+
)
|
199
|
+
end
|
200
|
+
|
201
|
+
qty = item.quantities
|
202
|
+
qty.each_with_index do |qty, index|
|
203
|
+
structure = Eancom.find_structure(tag: 'QTY')
|
204
|
+
key = qty.identifier.intern.to_sym
|
205
|
+
body.segment Eancom::Edifact::QTY.new(
|
206
|
+
quantity_type_code_qualifier: structure.dictionary_lookup(:quantity_type_code_qualifier, qty.identifier),
|
207
|
+
quantity: qty[key].quantity
|
208
|
+
)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
document.footer do |footer|
|
215
|
+
|
216
|
+
footer.segment Eancom::Edifact::UNT.new(
|
217
|
+
number_of_segments_in_message: (document.total_segments + 2).to_s,
|
218
|
+
message_reference_number: config.header.message_reference_number
|
219
|
+
)
|
220
|
+
footer.segment Eancom::Edifact::UNZ.new(
|
221
|
+
interchange_control_count: '1',
|
222
|
+
interchange_control_reference: config.header.interchange_control_reference
|
223
|
+
)
|
224
|
+
end
|
225
|
+
end
|
@@ -0,0 +1,207 @@
|
|
1
|
+
Eancom::Definition.create(name: 'D96A', type: :pricat) 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
|
+
test_indicator: nil
|
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
|
+
messages = config.body.messages
|
32
|
+
|
33
|
+
messages.each do |message|
|
34
|
+
body.segment Eancom::Edifact::BGM.new(
|
35
|
+
document_name_code: message.document_name_code,
|
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
|
+
date_time_messages.each_with_index do |dtm, index|
|
64
|
+
next unless index == 2
|
65
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
66
|
+
key = dtm.identifier.intern.to_sym
|
67
|
+
body.segment Eancom::Edifact::DTM.new(
|
68
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
69
|
+
date_time: dtm[key].date_time,
|
70
|
+
format: '102'
|
71
|
+
)
|
72
|
+
end
|
73
|
+
|
74
|
+
nads = message.nads
|
75
|
+
nads.each_with_index do |nad, index|
|
76
|
+
next unless index == 0
|
77
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
78
|
+
key = nad.identifier.intern.to_sym
|
79
|
+
body.segment Eancom::Edifact::NAD.new(
|
80
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
81
|
+
party_identifier: nad[key].party_identifier,
|
82
|
+
code_list_responsible_agency_code_1: '9'
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
nads.each_with_index do |nad, index|
|
87
|
+
next unless index == 1
|
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
|
+
if taxes = message.taxes
|
98
|
+
taxes.each do |tax|
|
99
|
+
next unless tax = tax.tax
|
100
|
+
|
101
|
+
structure = Eancom.find_structure(tag: 'TAX')
|
102
|
+
body.segment Eancom::Edifact::TAX.new(
|
103
|
+
duty_or_tax_or_fee_function_code_qualifier: '7',
|
104
|
+
duty_or_tax_or_fee_name_code: structure.dictionary_lookup(:duty_or_tax_or_fee_name_code,
|
105
|
+
tax.duty_or_tax_or_fee_name_code)
|
106
|
+
)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
structure = Eancom.find_structure(tag: 'CUX')
|
111
|
+
body.segment Eancom::Edifact::CUX.new(
|
112
|
+
currency_usage_code_qualifier_1: structure.dictionary_lookup(:currency_usage_code_qualifier_1, message.currency.currency_usage_code_qualifier_1),
|
113
|
+
currency_identification_code_1: message.currency.currency_identification_code_1,
|
114
|
+
currency_type_code_qualifier_1: structure.dictionary_lookup(:currency_type_code_qualifier_1,
|
115
|
+
message.currency.currency_type_code_qualifier_1)
|
116
|
+
)
|
117
|
+
|
118
|
+
structure = Eancom.find_structure(tag: 'PGI')
|
119
|
+
body.segment Eancom::Edifact::PGI.new(
|
120
|
+
product_group_type_code: structure.dictionary_lookup(:product_group_type_code, message.product_group_identifier)
|
121
|
+
)
|
122
|
+
|
123
|
+
total_quantity = 0
|
124
|
+
|
125
|
+
items = message.items
|
126
|
+
|
127
|
+
items.each_with_index do |item, index|
|
128
|
+
total_quantity += item.quantity.to_i
|
129
|
+
|
130
|
+
structure = Eancom.find_structure(tag: 'LIN')
|
131
|
+
body.segment Eancom::Edifact::LIN.new(
|
132
|
+
line_item_identifier_1: (index + 1).to_s,
|
133
|
+
item_identifier: item.ean,
|
134
|
+
action_request_notification_description_code: item.action_request_notification_description_code,
|
135
|
+
item_type_identification_code: structure.dictionary_lookup(:item_type_identification_code, item.item_type_identification_code),
|
136
|
+
sub_line_indicator_code: item.sub_line_indicator_code,
|
137
|
+
line_item_identifier_2: item.line_item_identifier_2
|
138
|
+
)
|
139
|
+
|
140
|
+
if additional_product_id = item.additional_product_id
|
141
|
+
additional_product_id.each do |id|
|
142
|
+
next unless additional_information = id.additional_information
|
143
|
+
|
144
|
+
structure = Eancom.find_structure(tag: 'PIA')
|
145
|
+
body.segment Eancom::Edifact::PIA.new(
|
146
|
+
product_identifier_code_qualifier: structure.dictionary_lookup(:product_identifier_code_qualifier, additional_information.product_identifier_code_qualifier),
|
147
|
+
item_identifier_1: additional_information.item_identifier_1,
|
148
|
+
item_type_identification_code_1: structure.dictionary_lookup(:item_type_identification_code_1,
|
149
|
+
additional_information.item_type_identification_code_1)
|
150
|
+
)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
item_descriptions = item.item_descriptions
|
155
|
+
item_descriptions.each do |description|
|
156
|
+
structure = Eancom.find_structure(tag: 'IMD')
|
157
|
+
body.segment Eancom::Edifact::IMD.new(
|
158
|
+
description_format_code: structure.dictionary_lookup(:description_format_code,
|
159
|
+
description.description_format_code),
|
160
|
+
item_characteristic_code: structure.dictionary_lookup(:item_characteristic_code,
|
161
|
+
description.item_characteristic_code),
|
162
|
+
item_description_code: description.item_description_code,
|
163
|
+
code_list_identification_code_1: description.code_list_identification_code_1,
|
164
|
+
item_description_1: description.item_description_1
|
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
|
+
)
|
176
|
+
end
|
177
|
+
|
178
|
+
prices = item.prices
|
179
|
+
prices.each do |price|
|
180
|
+
next unless price = price.price
|
181
|
+
|
182
|
+
structure = Eancom.find_structure(tag: 'PRI')
|
183
|
+
body.segment Eancom::Edifact::PRI.new(
|
184
|
+
price_code_qualifier: structure.dictionary_lookup(:price_code_qualifier, price.price_code_qualifier),
|
185
|
+
price_amount: price.price_amount,
|
186
|
+
price_type_code: structure.dictionary_lookup(:price_type_code, price.price_type_code),
|
187
|
+
price_specification_code: structure.dictionary_lookup(:price_specification_code,
|
188
|
+
price.price_specification_code)
|
189
|
+
)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
document.footer do |footer|
|
196
|
+
messages = config.body.messages
|
197
|
+
|
198
|
+
footer.segment Eancom::Edifact::UNT.new(
|
199
|
+
number_of_segments_in_message: (document.total_segments + 2).to_s,
|
200
|
+
message_reference_number: config.header.message_reference_number
|
201
|
+
)
|
202
|
+
footer.segment Eancom::Edifact::UNZ.new(
|
203
|
+
interchange_control_count: messages.size.to_s,
|
204
|
+
interchange_control_reference: config.header.interchange_control_reference.to_s
|
205
|
+
)
|
206
|
+
end
|
207
|
+
end
|