eancom 0.1.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 +190 -5
- data/.gitlab-ci.yml +25 -0
- data/.ruby-version +1 -0
- data/Gemfile.lock +22 -18
- data/README.md +46 -0
- data/bin/console +3 -2
- data/definitions/desadv/d01b.rb +251 -0
- data/definitions/desadv/d96a.rb +208 -87
- 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 +328 -0
- data/definitions/segments/ali.rb +93 -0
- data/definitions/segments/bgm.rb +395 -0
- data/definitions/segments/cav.rb +122 -0
- data/definitions/segments/cci.rb +136 -0
- data/definitions/segments/cdi.rb +39 -0
- data/definitions/segments/cnt.rb +82 -0
- data/definitions/segments/cps.rb +76 -0
- data/definitions/segments/cta.rb +89 -0
- data/definitions/segments/cux.rb +174 -0
- data/definitions/segments/dgs.rb +34 -0
- data/definitions/segments/doc.rb +45 -0
- data/definitions/segments/dtm.rb +243 -0
- data/definitions/segments/efi.rb +67 -0
- data/definitions/segments/eqd.rb +37 -0
- data/definitions/segments/ftx.rb +165 -0
- data/definitions/segments/gin.rb +113 -0
- data/definitions/segments/imd.rb +360 -0
- data/definitions/segments/inv.rb +94 -0
- data/definitions/segments/lin.rb +133 -0
- data/definitions/segments/loc.rb +137 -0
- data/definitions/segments/mea.rb +189 -0
- data/definitions/segments/moa.rb +228 -0
- data/definitions/segments/nad.rb +314 -0
- data/definitions/segments/pac.rb +262 -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 +152 -0
- data/definitions/segments/pia.rb +501 -0
- data/definitions/segments/pri.rb +208 -0
- data/definitions/segments/qty.rb +293 -0
- data/definitions/segments/rff.rb +210 -0
- data/definitions/segments/rte.rb +52 -0
- data/definitions/segments/tax.rb +266 -0
- data/definitions/segments/tdt.rb +278 -0
- data/definitions/segments/tod.rb +64 -0
- data/definitions/segments/tru.rb +34 -0
- data/definitions/segments/una.rb +85 -0
- data/definitions/segments/unb.rb +284 -0
- data/definitions/segments/unh.rb +183 -0
- data/definitions/segments/uns.rb +40 -0
- data/definitions/segments/unt.rb +48 -0
- data/definitions/segments/unz.rb +48 -0
- data/definitions/slsrpt/d01b.rb +206 -0
- data/definitions/slsrpt/d96a.rb +199 -0
- data/eancom.gemspec +2 -1
- data/lib/eancom.rb +61 -16
- data/lib/eancom/definition.rb +1 -1
- data/lib/eancom/edifact.rb +60 -13
- data/lib/eancom/edifact/body.rb +63 -0
- data/lib/eancom/edifact/composite.rb +38 -0
- data/lib/eancom/edifact/data.rb +108 -0
- data/lib/eancom/edifact/document.rb +43 -11
- data/lib/eancom/edifact/document_element.rb +26 -0
- data/lib/eancom/edifact/footer.rb +7 -0
- data/lib/eancom/edifact/header.rb +15 -0
- data/lib/eancom/edifact/item.rb +40 -0
- data/lib/eancom/edifact/message.rb +24 -16
- data/lib/eancom/edifact/segment.rb +131 -12
- data/lib/eancom/edifact/segments/ajt.rb +32 -0
- data/lib/eancom/edifact/segments/alc.rb +61 -0
- data/lib/eancom/edifact/segments/ali.rb +50 -0
- data/lib/eancom/edifact/segments/bgm.rb +46 -0
- data/lib/eancom/edifact/segments/cav.rb +47 -0
- data/lib/eancom/edifact/segments/cci.rb +53 -0
- data/lib/eancom/edifact/segments/cdi.rb +30 -0
- data/lib/eancom/edifact/segments/cnt.rb +40 -0
- data/lib/eancom/edifact/segments/cps.rb +33 -0
- data/lib/eancom/edifact/segments/cta.rb +30 -0
- data/lib/eancom/edifact/segments/cux.rb +60 -0
- 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 +47 -0
- 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 +63 -0
- data/lib/eancom/edifact/segments/gin.rb +45 -0
- data/lib/eancom/edifact/segments/imd.rb +69 -0
- data/lib/eancom/edifact/segments/inv.rb +43 -0
- data/lib/eancom/edifact/segments/lin.rb +47 -0
- data/lib/eancom/edifact/segments/loc.rb +46 -0
- data/lib/eancom/edifact/segments/mea.rb +54 -0
- data/lib/eancom/edifact/segments/moa.rb +45 -0
- data/lib/eancom/edifact/segments/nad.rb +112 -0
- data/lib/eancom/edifact/segments/pac.rb +56 -0
- 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/pgi.rb +45 -0
- data/lib/eancom/edifact/segments/pia.rb +108 -0
- data/lib/eancom/edifact/segments/pri.rb +53 -0
- data/lib/eancom/edifact/segments/qty.rb +44 -0
- data/lib/eancom/edifact/segments/rff.rb +47 -0
- data/lib/eancom/edifact/segments/rte.rb +33 -0
- data/lib/eancom/edifact/segments/tax.rb +78 -0
- data/lib/eancom/edifact/segments/tdt.rb +57 -0
- 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 +52 -0
- data/lib/eancom/edifact/segments/unb.rb +68 -0
- data/lib/eancom/edifact/segments/unh.rb +50 -0
- data/lib/eancom/edifact/segments/uns.rb +32 -0
- data/lib/eancom/edifact/segments/unt.rb +28 -0
- data/lib/eancom/edifact/segments/unz.rb +28 -0
- data/lib/eancom/edifact/structure.rb +90 -0
- data/lib/eancom/factory.rb +9 -8
- data/lib/eancom/parser.rb +7 -0
- data/lib/eancom/parser/document.rb +60 -0
- data/lib/eancom/parser/segment.rb +71 -0
- data/lib/eancom/version.rb +1 -1
- data/pricat.json +1 -0
- metadata +141 -9
- data/lib/eancom/edifact/element.rb +0 -16
- data/lib/eancom/edifact/envelope.rb +0 -24
data/definitions/desadv/d96a.rb
CHANGED
@@ -1,106 +1,227 @@
|
|
1
|
-
Eancom::Definition.create(name: '
|
2
|
-
document.
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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: config.header.application_reference,
|
16
|
+
interchange_agreement_identifier: config.header.interchange_agreement_identifier
|
17
|
+
)
|
18
|
+
|
19
|
+
header.segment Eancom::Edifact::UNH.new(
|
20
|
+
message_reference_number: config.header.message_reference_number,
|
21
|
+
message_type: config.header.message_type,
|
22
|
+
message_version_number: config.header.message_version_number,
|
23
|
+
message_release_number: config.header.message_release_number,
|
24
|
+
controlling_agency: config.header.controlling_agency,
|
25
|
+
association_assigned_code: config.header.association_assigned_code
|
26
|
+
)
|
16
27
|
end
|
17
28
|
|
18
|
-
document.
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
# Order Reference
|
41
|
-
message.segment "RFF" do |segment|
|
42
|
-
segment.composite "VN:#{config.order_id}"
|
43
|
-
end
|
29
|
+
document.body do |body|
|
30
|
+
messages = config.body.messages
|
31
|
+
messages.each do |message|
|
32
|
+
body.segment Eancom::Edifact::BGM.new(
|
33
|
+
document_name_code: message.document_name_code,
|
34
|
+
document_identifier: message.document_identifier,
|
35
|
+
message_function_code: message.message_function_code
|
36
|
+
)
|
37
|
+
|
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
|
44
50
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
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
|
50
63
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
segment.composite "#{config.sender_iln}::9"
|
55
|
-
end
|
64
|
+
references = message.references
|
65
|
+
references.each_with_index do |rff, index|
|
66
|
+
next unless index == 0
|
56
67
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
62
75
|
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
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
|
68
89
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
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
|
74
103
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
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
|
79
117
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
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
|
84
131
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|
+
)
|
89
144
|
end
|
90
145
|
|
91
|
-
|
92
|
-
|
146
|
+
# Delivery Note Mode
|
147
|
+
body.segment Eancom::Edifact::CPS.new(
|
148
|
+
hierarchical_structure_level_identifier: message.hierarchical_structure_level_identifier
|
149
|
+
)
|
150
|
+
|
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
|
93
176
|
end
|
94
177
|
end
|
178
|
+
end
|
95
179
|
|
96
|
-
|
97
|
-
|
98
|
-
|
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
|
99
215
|
end
|
100
216
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
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
|
220
|
+
)
|
221
|
+
|
222
|
+
footer.segment Eancom::Edifact::UNZ.new(
|
223
|
+
interchange_control_count: messages.size.to_s,
|
224
|
+
interchange_control_reference: config.header.interchange_control_reference.to_s
|
225
|
+
)
|
105
226
|
end
|
106
227
|
end
|
@@ -0,0 +1,559 @@
|
|
1
|
+
Eancom::Definition.create(name: 'D01B', type: :invoic) 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
|
+
messages.each do |message|
|
33
|
+
body.segment Eancom::Edifact::BGM.new(
|
34
|
+
document_name_code: message.document_name_code,
|
35
|
+
document_identifier: message.document_identifier,
|
36
|
+
message_function_code: message.message_function_code
|
37
|
+
)
|
38
|
+
|
39
|
+
date_time_messages = message.date_time_messages
|
40
|
+
date_time_messages.each_with_index do |dtm, index|
|
41
|
+
next unless index == 0
|
42
|
+
|
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
|
+
|
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
|
+
free_texts = message.free_texts
|
65
|
+
|
66
|
+
free_texts.each do |free_text|
|
67
|
+
free_text_function_code = if free_text.free_text_function_code.nil?
|
68
|
+
''
|
69
|
+
else
|
70
|
+
free_text.free_text_function_code
|
71
|
+
end
|
72
|
+
free_text_value_code = if free_text.free_text_value_code.nil?
|
73
|
+
''
|
74
|
+
else
|
75
|
+
free_text.free_text_value_code
|
76
|
+
end
|
77
|
+
code_list_identification_code = if free_text.code_list_identification_code.nil?
|
78
|
+
''
|
79
|
+
else
|
80
|
+
free_text.code_list_identification_code
|
81
|
+
end
|
82
|
+
structure = Eancom.find_structure(tag: 'FTX')
|
83
|
+
body.segment Eancom::Edifact::FTX.new(
|
84
|
+
text_subject_code_qualifier: free_text.text_subject_code_qualifier,
|
85
|
+
free_text_function_code: free_text_function_code,
|
86
|
+
free_text_value_code: free_text_value_code,
|
87
|
+
code_list_identification_code: code_list_identification_code,
|
88
|
+
free_text_value_1: free_text.free_text_value_1
|
89
|
+
)
|
90
|
+
end
|
91
|
+
|
92
|
+
references = message.references
|
93
|
+
references.each_with_index do |rff, index|
|
94
|
+
next unless index == 0
|
95
|
+
|
96
|
+
structure = Eancom.find_structure(tag: 'RFF')
|
97
|
+
key = rff.identifier.intern.to_sym
|
98
|
+
body.segment Eancom::Edifact::RFF.new(
|
99
|
+
reference_code_qualifier: structure.dictionary_lookup(:reference_code_qualifier, rff.identifier),
|
100
|
+
reference_identifier: rff[key].reference_identifier
|
101
|
+
)
|
102
|
+
end
|
103
|
+
|
104
|
+
date_time_messages.each_with_index do |dtm, index|
|
105
|
+
next unless index == 2
|
106
|
+
|
107
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
108
|
+
key = dtm.identifier.intern.to_sym
|
109
|
+
body.segment Eancom::Edifact::DTM.new(
|
110
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
111
|
+
date_time: dtm[key].date_time,
|
112
|
+
format: '102'
|
113
|
+
)
|
114
|
+
end
|
115
|
+
|
116
|
+
references.each_with_index do |rff, index|
|
117
|
+
next unless index == 1
|
118
|
+
|
119
|
+
structure = Eancom.find_structure(tag: 'RFF')
|
120
|
+
key = rff.identifier.intern.to_sym
|
121
|
+
body.segment Eancom::Edifact::RFF.new(
|
122
|
+
reference_code_qualifier: structure.dictionary_lookup(:reference_code_qualifier, rff.identifier),
|
123
|
+
reference_identifier: rff[key].reference_identifier
|
124
|
+
)
|
125
|
+
end
|
126
|
+
|
127
|
+
date_time_messages.each_with_index do |dtm, index|
|
128
|
+
next unless index == 3
|
129
|
+
|
130
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
131
|
+
key = dtm.identifier.intern.to_sym
|
132
|
+
body.segment Eancom::Edifact::DTM.new(
|
133
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
134
|
+
date_time: dtm[key].date_time,
|
135
|
+
format: '102'
|
136
|
+
)
|
137
|
+
end
|
138
|
+
|
139
|
+
references.each_with_index do |rff, index|
|
140
|
+
next unless index == 2
|
141
|
+
|
142
|
+
structure = Eancom.find_structure(tag: 'RFF')
|
143
|
+
key = rff.identifier.intern.to_sym
|
144
|
+
body.segment Eancom::Edifact::RFF.new(
|
145
|
+
reference_code_qualifier: structure.dictionary_lookup(:reference_code_qualifier, rff.identifier),
|
146
|
+
reference_identifier: rff[key].reference_identifier
|
147
|
+
)
|
148
|
+
end
|
149
|
+
|
150
|
+
date_time_messages.each_with_index do |dtm, index|
|
151
|
+
next unless index == 4
|
152
|
+
|
153
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
154
|
+
key = dtm.identifier.intern.to_sym
|
155
|
+
body.segment Eancom::Edifact::DTM.new(
|
156
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
157
|
+
date_time: dtm[key].date_time,
|
158
|
+
format: '102'
|
159
|
+
)
|
160
|
+
end
|
161
|
+
|
162
|
+
nads = message.nads
|
163
|
+
nads.each_with_index do |nad, index|
|
164
|
+
next unless index == 0
|
165
|
+
|
166
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
167
|
+
key = nad.identifier.intern.to_sym
|
168
|
+
body.segment Eancom::Edifact::NAD.new(
|
169
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
170
|
+
party_identifier: nad[key].party_identifier,
|
171
|
+
code_list_responsible_agency_code_1: '9',
|
172
|
+
name_and_address_description_1: nad[key].name_and_address_description_1
|
173
|
+
)
|
174
|
+
end
|
175
|
+
|
176
|
+
nads.each_with_index do |nad, index|
|
177
|
+
next unless index == 1
|
178
|
+
|
179
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
180
|
+
key = nad.identifier.intern.to_sym
|
181
|
+
body.segment Eancom::Edifact::NAD.new(
|
182
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
183
|
+
party_identifier: nad[key].party_identifier,
|
184
|
+
code_list_responsible_agency_code_1: '9',
|
185
|
+
name_and_address_description_1: nad[key].name_and_address_description_1
|
186
|
+
)
|
187
|
+
end
|
188
|
+
|
189
|
+
references.each_with_index do |rff, index|
|
190
|
+
next unless index == 3
|
191
|
+
|
192
|
+
structure = Eancom.find_structure(tag: 'RFF')
|
193
|
+
key = rff.identifier.intern.to_sym
|
194
|
+
body.segment Eancom::Edifact::RFF.new(
|
195
|
+
reference_code_qualifier: structure.dictionary_lookup(:reference_code_qualifier, rff.identifier),
|
196
|
+
reference_identifier: rff[key].reference_identifier
|
197
|
+
)
|
198
|
+
end
|
199
|
+
|
200
|
+
references.each_with_index do |rff, index|
|
201
|
+
next unless index == 4
|
202
|
+
|
203
|
+
structure = Eancom.find_structure(tag: 'RFF')
|
204
|
+
key = rff.identifier.intern.to_sym
|
205
|
+
body.segment Eancom::Edifact::RFF.new(
|
206
|
+
reference_code_qualifier: structure.dictionary_lookup(:reference_code_qualifier, rff.identifier),
|
207
|
+
reference_identifier: rff[key].reference_identifier
|
208
|
+
)
|
209
|
+
end
|
210
|
+
|
211
|
+
nads.each_with_index do |nad, index|
|
212
|
+
next unless index == 2
|
213
|
+
|
214
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
215
|
+
key = nad.identifier.intern.to_sym
|
216
|
+
body.segment Eancom::Edifact::NAD.new(
|
217
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
218
|
+
party_identifier: nad[key].party_identifier,
|
219
|
+
code_list_responsible_agency_code_1: '9',
|
220
|
+
name_and_address_description_1: nad[key].name_and_address_description_1
|
221
|
+
)
|
222
|
+
end
|
223
|
+
|
224
|
+
nads.each_with_index do |nad, index|
|
225
|
+
next unless index == 3
|
226
|
+
|
227
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
228
|
+
key = nad.identifier.intern.to_sym
|
229
|
+
body.segment Eancom::Edifact::NAD.new(
|
230
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
231
|
+
party_identifier: nad[key].party_identifier,
|
232
|
+
code_list_responsible_agency_code_1: '9',
|
233
|
+
name_and_address_description_1: nad[key].name_and_address_description_1
|
234
|
+
)
|
235
|
+
end
|
236
|
+
|
237
|
+
if taxes = message.taxes
|
238
|
+
taxes.each do |tax|
|
239
|
+
next unless tax = tax.tax
|
240
|
+
|
241
|
+
structure = Eancom.find_structure(tag: 'TAX')
|
242
|
+
body.segment Eancom::Edifact::TAX.new(
|
243
|
+
duty_or_tax_or_fee_function_code_qualifier: structure.dictionary_lookup(
|
244
|
+
:duty_or_tax_or_fee_function_code_qualifier, tax.duty_or_tax_or_fee_function_code_qualifier
|
245
|
+
),
|
246
|
+
duty_or_tax_or_fee_name_code: structure.dictionary_lookup(:duty_or_tax_or_fee_name_code,
|
247
|
+
tax.duty_or_tax_or_fee_name_code),
|
248
|
+
duty_or_tax_or_fee_account_code: tax.duty_or_tax_or_fee_account_code,
|
249
|
+
duty_tax_fee_rate_code: tax.duty_tax_fee_rate_code,
|
250
|
+
code_list_identification_code_3: tax.code_list_identification_code_3,
|
251
|
+
code_list_responsibility_agency_code_3: tax.code_list_responsibility_agency_code_3,
|
252
|
+
code_list_responsibility_agency_code_4: '9',
|
253
|
+
duty_or_tax_or_fee_category_code: 'S'
|
254
|
+
)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
structure = Eancom.find_structure(tag: 'CUX')
|
259
|
+
body.segment Eancom::Edifact::CUX.new(
|
260
|
+
currency_usage_code_qualifier_1: structure.dictionary_lookup(:currency_usage_code_qualifier_1,
|
261
|
+
message.currency.currency_usage_code_qualifier_1),
|
262
|
+
currency_identification_code_1: message.currency.currency_identification_code_1,
|
263
|
+
currency_type_code_qualifier_1: structure.dictionary_lookup(:currency_type_code_qualifier_1,
|
264
|
+
message.currency.currency_type_code_qualifier_1)
|
265
|
+
)
|
266
|
+
if allowances_or_charges = message.allowances_or_charges
|
267
|
+
|
268
|
+
allowances_or_charges.each do |allowance_or_charge|
|
269
|
+
allowance_or_charge_identifier = if allowance_or_charge.allowance_or_charge_identifier.nil?
|
270
|
+
''
|
271
|
+
else
|
272
|
+
allowance_or_charge.allowance_or_charge
|
273
|
+
end
|
274
|
+
allowance_or_charge_identification_code = if allowance_or_charge.allowance_or_charge_identification_code.nil?
|
275
|
+
''
|
276
|
+
else
|
277
|
+
allowance_or_charge.allowance_or_charge_identification_code
|
278
|
+
end
|
279
|
+
settlement_mean_code = if allowance_or_charge.settlement_mean_code.nil?
|
280
|
+
''
|
281
|
+
else
|
282
|
+
allowance_or_charge.settlement_mean_code
|
283
|
+
end
|
284
|
+
structure = Eancom.find_structure(tag: 'ALC')
|
285
|
+
body.segment Eancom::Edifact::ALC.new(
|
286
|
+
allowance_or_charge_code_qualifier: structure.dictionary_lookup(:allowance_or_charge_code_qualifier,
|
287
|
+
allowance_or_charge.allowance_or_charge_code_qualifier),
|
288
|
+
allowance_or_charge_identifier: allowance_or_charge_identifier,
|
289
|
+
allowance_or_charge_identification_code: allowance_or_charge_identification_code,
|
290
|
+
settlement_mean_code: settlement_mean_code,
|
291
|
+
special_service_description_code: structure.dictionary_lookup(:special_service_description_code,
|
292
|
+
allowance_or_charge.special_service_description_code)
|
293
|
+
)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
monetary_amounts = message.monetary_amounts
|
298
|
+
monetary_amounts.each do |amount|
|
299
|
+
monetary_amount = if amount.monetary_amount.nil?
|
300
|
+
''
|
301
|
+
else
|
302
|
+
amount.monetary_amount
|
303
|
+
end
|
304
|
+
structure = Eancom.find_structure(tag: 'MOA')
|
305
|
+
body.segment Eancom::Edifact::MOA.new(
|
306
|
+
monetary_amount_type_code_qualifier: structure.dictionary_lookup(:monetary_amount_type_code_qualifier,
|
307
|
+
amount.monetary_amount_type_code_qualifier),
|
308
|
+
monetary_amount: monetary_amount
|
309
|
+
)
|
310
|
+
end
|
311
|
+
|
312
|
+
items = message.items
|
313
|
+
|
314
|
+
items.each_with_index do |item, index|
|
315
|
+
structure = Eancom.find_structure(tag: 'LIN')
|
316
|
+
body.segment Eancom::Edifact::LIN.new(
|
317
|
+
line_item_identifier_1: (index + 1).to_s,
|
318
|
+
item_identifier: item.ean,
|
319
|
+
item_type_identification_code: structure.dictionary_lookup(:item_type_identification_code,
|
320
|
+
item.item_type_identification_code)
|
321
|
+
)
|
322
|
+
if additional_product_id = item.additional_product_id
|
323
|
+
additional_product_id.each do |id|
|
324
|
+
next unless additional_information = id.additional_information
|
325
|
+
|
326
|
+
structure = Eancom.find_structure(tag: 'PIA')
|
327
|
+
body.segment Eancom::Edifact::PIA.new(
|
328
|
+
product_identifier_code_qualifier: structure.dictionary_lookup(:product_identifier_code_qualifier,
|
329
|
+
additional_information.product_identifier_code_qualifier),
|
330
|
+
item_identifier_1: additional_information.item_identifier_1,
|
331
|
+
item_type_identification_code_1: structure.dictionary_lookup(:item_type_identification_code_1,
|
332
|
+
additional_information.item_type_identification_code_1)
|
333
|
+
)
|
334
|
+
end
|
335
|
+
end
|
336
|
+
|
337
|
+
if item_descriptions = item.item_descriptions
|
338
|
+
item_descriptions.each do |description|
|
339
|
+
structure = Eancom.find_structure(tag: 'IMD')
|
340
|
+
body.segment Eancom::Edifact::IMD.new(
|
341
|
+
description_format_code: structure.dictionary_lookup(:description_format_code,
|
342
|
+
description.description_format_code),
|
343
|
+
item_characteristic_code: structure.dictionary_lookup(:item_characteristic_code,
|
344
|
+
description.item_characteristic_code),
|
345
|
+
item_description_code: description.item_description_code,
|
346
|
+
code_list_identification_code_1: description.item_description_code,
|
347
|
+
code_list_responsible_agency_code_1: description.item_description_code,
|
348
|
+
item_description_1: description.item_description_1
|
349
|
+
)
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
353
|
+
quantities = item.quantities
|
354
|
+
quantities.each_with_index do |qty, index|
|
355
|
+
structure = Eancom.find_structure(tag: 'QTY')
|
356
|
+
key = qty.identifier.intern.to_sym
|
357
|
+
body.segment Eancom::Edifact::QTY.new(
|
358
|
+
quantity_type_code_qualifier: structure.dictionary_lookup(:quantity_type_code_qualifier, qty.identifier),
|
359
|
+
quantity: qty[key].quantity,
|
360
|
+
measurement_unit_code: structure.dictionary_lookup(:measurement_unit_code, qty.measurement_unit_code)
|
361
|
+
)
|
362
|
+
end
|
363
|
+
|
364
|
+
monetary_amounts = item.monetary_amounts
|
365
|
+
|
366
|
+
monetary_amounts.each_with_index do |amount, index|
|
367
|
+
if index == 0
|
368
|
+
monetary_amount = if amount.monetary_amount.nil?
|
369
|
+
''
|
370
|
+
else
|
371
|
+
amount.monetary_amount
|
372
|
+
end
|
373
|
+
structure = Eancom.find_structure(tag: 'MOA')
|
374
|
+
body.segment Eancom::Edifact::MOA.new(
|
375
|
+
monetary_amount_type_code_qualifier: structure.dictionary_lookup(:monetary_amount_type_code_qualifier,
|
376
|
+
amount.monetary_amount_type_code_qualifier),
|
377
|
+
monetary_amount: monetary_amount
|
378
|
+
)
|
379
|
+
else
|
380
|
+
next
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
prices = item.prices
|
385
|
+
prices.each do |price|
|
386
|
+
next unless price = price.price
|
387
|
+
|
388
|
+
structure = Eancom.find_structure(tag: 'PRI')
|
389
|
+
body.segment Eancom::Edifact::PRI.new(
|
390
|
+
price_code_qualifier: structure.dictionary_lookup(:price_code_qualifier, price.price_code_qualifier),
|
391
|
+
price_amount: price.price_amount,
|
392
|
+
price_type_code: structure.dictionary_lookup(:price_type_code, price.price_type_code),
|
393
|
+
price_specification_code: structure.dictionary_lookup(:price_specification_code,
|
394
|
+
price.price_specification_code)
|
395
|
+
)
|
396
|
+
end
|
397
|
+
|
398
|
+
references = item.references
|
399
|
+
references.each_with_index do |rff, index|
|
400
|
+
structure = Eancom.find_structure(tag: 'RFF')
|
401
|
+
key = rff.identifier.intern.to_sym
|
402
|
+
body.segment Eancom::Edifact::RFF.new(
|
403
|
+
reference_code_qualifier: structure.dictionary_lookup(:reference_code_qualifier, rff.identifier),
|
404
|
+
reference_identifier: rff[key].reference_identifier
|
405
|
+
)
|
406
|
+
end
|
407
|
+
|
408
|
+
date_time_messages = item.date_time_messages
|
409
|
+
date_time_messages.each_with_index do |dtm, index|
|
410
|
+
key = dtm.identifier.intern.to_sym
|
411
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
412
|
+
body.segment Eancom::Edifact::DTM.new(
|
413
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
414
|
+
date_time: dtm[key].date_time,
|
415
|
+
format: '102'
|
416
|
+
)
|
417
|
+
end
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
document.footer do |footer|
|
422
|
+
footer.segment Eancom::Edifact::UNS.new(
|
423
|
+
section_identification: 'S'
|
424
|
+
)
|
425
|
+
messages = config.body.messages
|
426
|
+
|
427
|
+
messages.each do |message|
|
428
|
+
items = message.items
|
429
|
+
control_total_value = 0
|
430
|
+
|
431
|
+
items.each_with_index do |item, index|
|
432
|
+
quantities = item.quantities
|
433
|
+
quantities.each do |qty|
|
434
|
+
key = qty.identifier.intern.to_sym
|
435
|
+
control_total_value += qty[key].quantity.to_i
|
436
|
+
end
|
437
|
+
next unless index == items.size - 1
|
438
|
+
|
439
|
+
counts = item.counts
|
440
|
+
counts.each_with_index do |cnt, index|
|
441
|
+
structure = Eancom.find_structure(tag: 'CNT')
|
442
|
+
footer.segment Eancom::Edifact::CNT.new(
|
443
|
+
control_total_type_code_quantifier: structure.dictionary_lookup(:control_total_type_code_quantifier,
|
444
|
+
cnt.control_total_type_code_quantifier),
|
445
|
+
control_total_value: (control_total_value - 1).to_s
|
446
|
+
)
|
447
|
+
end
|
448
|
+
end
|
449
|
+
|
450
|
+
items = message.items
|
451
|
+
items.each do |item|
|
452
|
+
monetary_amounts = item.monetary_amounts
|
453
|
+
|
454
|
+
monetary_amount = 0
|
455
|
+
monetary_amounts.each_with_index do |amount, index|
|
456
|
+
next unless index >= items.size - 4 && index <= items.size - 2
|
457
|
+
|
458
|
+
monetary_amount = if amount.monetary_amount.nil?
|
459
|
+
''
|
460
|
+
else
|
461
|
+
amount.monetary_amount
|
462
|
+
end
|
463
|
+
structure = Eancom.find_structure(tag: 'MOA')
|
464
|
+
footer.segment Eancom::Edifact::MOA.new(
|
465
|
+
monetary_amount_type_code_qualifier: structure.dictionary_lookup(:monetary_amount_type_code_qualifier,
|
466
|
+
amount.monetary_amount_type_code_qualifier),
|
467
|
+
monetary_amount: monetary_amount
|
468
|
+
)
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
472
|
+
if taxes = message.taxes
|
473
|
+
taxes.each do |tax|
|
474
|
+
next unless tax = tax.tax
|
475
|
+
|
476
|
+
structure = Eancom.find_structure(tag: 'TAX')
|
477
|
+
footer.segment Eancom::Edifact::TAX.new(
|
478
|
+
duty_or_tax_or_fee_function_code_qualifier: '7',
|
479
|
+
duty_or_tax_or_fee_name_code: structure.dictionary_lookup(:duty_or_tax_or_fee_name_code,
|
480
|
+
tax.duty_or_tax_or_fee_name_code),
|
481
|
+
duty_or_tax_or_fee_account_code: tax.duty_or_tax_or_fee_account_code,
|
482
|
+
duty_tax_fee_rate_code: tax.duty_tax_fee_rate_code,
|
483
|
+
code_list_identification_code_3: tax.code_list_identification_code_3,
|
484
|
+
code_list_responsibility_agency_code_3: tax.code_list_responsibility_agency_code_3,
|
485
|
+
code_list_responsibility_agency_code_4: '9',
|
486
|
+
duty_or_tax_or_fee_category_code: 'S'
|
487
|
+
)
|
488
|
+
end
|
489
|
+
end
|
490
|
+
|
491
|
+
items.each do |item|
|
492
|
+
monetary_amounts = item.monetary_amounts
|
493
|
+
|
494
|
+
monetary_amount = 0
|
495
|
+
monetary_amounts.each_with_index do |amount, index|
|
496
|
+
next unless index == items.size - 1
|
497
|
+
|
498
|
+
monetary_amount = if amount.monetary_amount.nil?
|
499
|
+
''
|
500
|
+
else
|
501
|
+
amount.monetary_amount
|
502
|
+
end
|
503
|
+
structure = Eancom.find_structure(tag: 'MOA')
|
504
|
+
footer.segment Eancom::Edifact::MOA.new(
|
505
|
+
monetary_amount_type_code_qualifier: structure.dictionary_lookup(:monetary_amount_type_code_qualifier,
|
506
|
+
amount.monetary_amount_type_code_qualifier),
|
507
|
+
monetary_amount: monetary_amount
|
508
|
+
)
|
509
|
+
end
|
510
|
+
end
|
511
|
+
next unless allowances_or_charges = message.allowances_or_charges
|
512
|
+
|
513
|
+
allowances_or_charges.each do |allowance_or_charge|
|
514
|
+
allowance_or_charge_identifier = if allowance_or_charge.allowance_or_charge_identifier.nil?
|
515
|
+
''
|
516
|
+
else
|
517
|
+
allowance_or_charge.allowance_or_charge_identifier
|
518
|
+
end
|
519
|
+
structure = Eancom.find_structure(tag: 'ALC')
|
520
|
+
footer.segment Eancom::Edifact::ALC.new(
|
521
|
+
allowance_or_charge_code_qualifier: structure.dictionary_lookup(:allowance_or_charge_code_qualifier,
|
522
|
+
allowance_or_charge.allowance_or_charge_code_qualifier),
|
523
|
+
allowance_or_charge_identifier: allowance_or_charge_identifier,
|
524
|
+
allowance_or_charge_identification_code: '64'
|
525
|
+
)
|
526
|
+
end
|
527
|
+
|
528
|
+
items.each do |item|
|
529
|
+
monetary_amounts = item.monetary_amounts
|
530
|
+
|
531
|
+
monetary_amount = 0
|
532
|
+
monetary_amounts.each_with_index do |amount, index|
|
533
|
+
next unless index == items.size
|
534
|
+
|
535
|
+
monetary_amount = if amount.monetary_amount.nil?
|
536
|
+
''
|
537
|
+
else
|
538
|
+
amount.monetary_amount
|
539
|
+
end
|
540
|
+
structure = Eancom.find_structure(tag: 'MOA')
|
541
|
+
footer.segment Eancom::Edifact::MOA.new(
|
542
|
+
monetary_amount_type_code_qualifier: structure.dictionary_lookup(:monetary_amount_type_code_qualifier,
|
543
|
+
amount.monetary_amount_type_code_qualifier),
|
544
|
+
monetary_amount: monetary_amount
|
545
|
+
)
|
546
|
+
end
|
547
|
+
end
|
548
|
+
end
|
549
|
+
footer.segment Eancom::Edifact::UNT.new(
|
550
|
+
number_of_segments_in_message: (document.total_segments + 2).to_s,
|
551
|
+
message_reference_number: config.header.message_reference_number
|
552
|
+
)
|
553
|
+
footer.segment Eancom::Edifact::UNZ.new(
|
554
|
+
interchange_control_count: messages.size.to_s,
|
555
|
+
interchange_control_reference: config.header.interchange_control_reference
|
556
|
+
)
|
557
|
+
end
|
558
|
+
end
|
559
|
+
end
|