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,64 @@
|
|
1
|
+
tag = 'PAT'
|
2
|
+
Eancom.register_segment(tag: tag, klass: Eancom::Edifact::PAT)
|
3
|
+
|
4
|
+
structure = Eancom::Edifact::Structure.new(tag: tag)
|
5
|
+
#==============================================================================
|
6
|
+
# Tag #
|
7
|
+
#==============================================================================
|
8
|
+
tag = Eancom::Edifact::Composite.new
|
9
|
+
data = Eancom::Edifact::Data.new(
|
10
|
+
type: String,
|
11
|
+
length: 1..3,
|
12
|
+
dictionary: nil,
|
13
|
+
description: 'Message Header',
|
14
|
+
required: true
|
15
|
+
)
|
16
|
+
tag.add(:tag, data)
|
17
|
+
|
18
|
+
structure << tag
|
19
|
+
|
20
|
+
delivery_or_transport_terms_function_code = Eancom::Edifact::Composite.new
|
21
|
+
data = Eancom::Edifact::Data.new(
|
22
|
+
type: String,
|
23
|
+
length: 1..3,
|
24
|
+
dictionary: {
|
25
|
+
'3' => {
|
26
|
+
description: 'Price and despatch condition',
|
27
|
+
identification: 'price_and_despatch_condition'
|
28
|
+
},
|
29
|
+
'5' => {
|
30
|
+
description: 'Transport condition',
|
31
|
+
identification: 'transport_condition'
|
32
|
+
},
|
33
|
+
'6' => {
|
34
|
+
description: 'Delivery condition',
|
35
|
+
identification: 'delivery_condition'
|
36
|
+
},
|
37
|
+
'10E' => {
|
38
|
+
description: 'Delivered by supplier (GS1 Temorary Code)',
|
39
|
+
identification: 'delivered_by_supplier_gs1'
|
40
|
+
}
|
41
|
+
},
|
42
|
+
description: 'Delivery or transport terms function code',
|
43
|
+
required: false
|
44
|
+
)
|
45
|
+
delivery_or_transport_terms_function_code.add(:delivery_or_transport_terms_function_code, data)
|
46
|
+
|
47
|
+
structure << delivery_or_transport_terms_function_code
|
48
|
+
|
49
|
+
#==============================================================================
|
50
|
+
# TERMS OF DELIVERY OR TRANSPORT #
|
51
|
+
#==============================================================================
|
52
|
+
delivery_or_transport_terms_description_code = Eancom::Edifact::Composite.new
|
53
|
+
data = Eancom::Edifact::Data.new(
|
54
|
+
type: String,
|
55
|
+
length: 1..3,
|
56
|
+
dictionary: nil,
|
57
|
+
description: 'Delivery or transport terms description code',
|
58
|
+
required: false
|
59
|
+
)
|
60
|
+
delivery_or_transport_terms_description_code.add(:delivery_or_transport_terms_description_code, data)
|
61
|
+
|
62
|
+
structure << delivery_or_transport_terms_description_code
|
63
|
+
#==============================================================================
|
64
|
+
Eancom.register_structure(tag: 'TOD', structure: structure)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
tag = 'TRU'
|
2
|
+
Eancom.register_segment(tag: tag, klass: Eancom::Edifact::TRU)
|
3
|
+
|
4
|
+
structure = Eancom::Edifact::Structure.new(tag: tag)
|
5
|
+
#==============================================================================
|
6
|
+
# Tag #
|
7
|
+
#==============================================================================
|
8
|
+
tag = Eancom::Edifact::Composite.new
|
9
|
+
data = Eancom::Edifact::Data.new(
|
10
|
+
type: String,
|
11
|
+
length: 3,
|
12
|
+
dictionary: nil,
|
13
|
+
description: 'Message Header',
|
14
|
+
required: true
|
15
|
+
)
|
16
|
+
tag.add(:tag, data)
|
17
|
+
|
18
|
+
structure << tag
|
19
|
+
#==============================================================================
|
20
|
+
# Object identifier
|
21
|
+
#==============================================================================
|
22
|
+
object_identifier = Eancom::Edifact::Composite.new
|
23
|
+
data = Eancom::Edifact::Data.new(
|
24
|
+
type: String,
|
25
|
+
length: 1..35,
|
26
|
+
dictionary: nil,
|
27
|
+
description: 'Object identifier',
|
28
|
+
required: true
|
29
|
+
)
|
30
|
+
object_identifier.add(:object_identifier, data)
|
31
|
+
|
32
|
+
structure << object_identifier
|
33
|
+
#==============================================================================
|
34
|
+
Eancom.register_structure(tag: 'TRU', structure: structure)
|
data/definitions/segments/una.rb
CHANGED
@@ -6,7 +6,7 @@ structure = Eancom::Edifact::Structure.new(tag: tag)
|
|
6
6
|
composite = Eancom::Edifact::Composite.new()
|
7
7
|
data = Eancom::Edifact::Data.new(
|
8
8
|
type: String,
|
9
|
-
length: 3,
|
9
|
+
length: 1..3,
|
10
10
|
dictionary: nil,
|
11
11
|
description: "Service String Advice",
|
12
12
|
required: true
|
@@ -17,7 +17,7 @@ structure << composite
|
|
17
17
|
composite = Eancom::Edifact::Composite.new()
|
18
18
|
data = Eancom::Edifact::Data.new(
|
19
19
|
type: String,
|
20
|
-
length: 1,
|
20
|
+
length: 0..1,
|
21
21
|
dictionary: nil,
|
22
22
|
description: "Component data element separator",
|
23
23
|
required: true
|
@@ -28,7 +28,7 @@ structure << composite
|
|
28
28
|
composite = Eancom::Edifact::Composite.new()
|
29
29
|
data = Eancom::Edifact::Data.new(
|
30
30
|
type: String,
|
31
|
-
length: 1,
|
31
|
+
length: 0..1,
|
32
32
|
dictionary: nil,
|
33
33
|
description: "Data element separator",
|
34
34
|
required: true
|
@@ -39,7 +39,7 @@ structure << composite
|
|
39
39
|
composite = Eancom::Edifact::Composite.new()
|
40
40
|
data = Eancom::Edifact::Data.new(
|
41
41
|
type: String,
|
42
|
-
length: 1,
|
42
|
+
length: 0..1,
|
43
43
|
dictionary: nil,
|
44
44
|
description: "Decimal notation",
|
45
45
|
required: true
|
@@ -50,7 +50,7 @@ structure << composite
|
|
50
50
|
composite = Eancom::Edifact::Composite.new()
|
51
51
|
data = Eancom::Edifact::Data.new(
|
52
52
|
type: String,
|
53
|
-
length: 1,
|
53
|
+
length: 0..1,
|
54
54
|
dictionary: nil,
|
55
55
|
description: "Release character",
|
56
56
|
required: true
|
@@ -61,7 +61,7 @@ structure << composite
|
|
61
61
|
composite = Eancom::Edifact::Composite.new()
|
62
62
|
data = Eancom::Edifact::Data.new(
|
63
63
|
type: String,
|
64
|
-
length: 1,
|
64
|
+
length: 0..1,
|
65
65
|
dictionary: nil,
|
66
66
|
description: "Reserved for future use",
|
67
67
|
required: true
|
@@ -72,7 +72,7 @@ structure << composite
|
|
72
72
|
composite = Eancom::Edifact::Composite.new()
|
73
73
|
data = Eancom::Edifact::Data.new(
|
74
74
|
type: String,
|
75
|
-
length: 1,
|
75
|
+
length: 0..1,
|
76
76
|
dictionary: nil,
|
77
77
|
description: "Segment terminator",
|
78
78
|
required: true
|
@@ -80,6 +80,6 @@ data = Eancom::Edifact::Data.new(
|
|
80
80
|
composite.add(:una6, data)
|
81
81
|
structure << composite
|
82
82
|
|
83
|
-
Eancom.register_structure(tag:
|
83
|
+
Eancom.register_structure(tag: tag, structure: structure)
|
84
84
|
|
85
85
|
|
data/definitions/segments/unb.rb
CHANGED
@@ -8,7 +8,7 @@ structure = Eancom::Edifact::Structure.new(tag: tag)
|
|
8
8
|
tag = Eancom::Edifact::Composite.new()
|
9
9
|
data = Eancom::Edifact::Data.new(
|
10
10
|
type: String,
|
11
|
-
length: 3,
|
11
|
+
length: 1..3,
|
12
12
|
dictionary: nil,
|
13
13
|
description: "Interchange Header",
|
14
14
|
required: true
|
@@ -44,7 +44,7 @@ syntax_dictionary = {
|
|
44
44
|
}
|
45
45
|
data = Eancom::Edifact::Data.new(
|
46
46
|
type: String,
|
47
|
-
length: 4,
|
47
|
+
length: 1..4,
|
48
48
|
dictionary: syntax_dictionary,
|
49
49
|
description: "Syntax identifier.",
|
50
50
|
required: true
|
@@ -154,7 +154,7 @@ date_and_time_of_preparation.add(:date, data)
|
|
154
154
|
|
155
155
|
data = Eancom::Edifact::Data.new(
|
156
156
|
type: String,
|
157
|
-
length: 4,
|
157
|
+
length: 1..4,
|
158
158
|
dictionary: nil,
|
159
159
|
description: "Time (HHMM)",
|
160
160
|
required: true
|
@@ -193,7 +193,7 @@ recipient_reference.add(:recipient_reference, data)
|
|
193
193
|
|
194
194
|
data = Eancom::Edifact::Data.new(
|
195
195
|
type: String,
|
196
|
-
length: 2,
|
196
|
+
length: 1..2,
|
197
197
|
dictionary: nil,
|
198
198
|
description: "Recipient reference/password qualifier.",
|
199
199
|
required: false
|
data/definitions/segments/unh.rb
CHANGED
@@ -38,8 +38,33 @@ message_identifier = Eancom::Edifact::Composite.new()
|
|
38
38
|
data = Eancom::Edifact::Data.new(
|
39
39
|
type: String,
|
40
40
|
length: 1..6,
|
41
|
-
dictionary:
|
42
|
-
|
41
|
+
dictionary: {
|
42
|
+
'ORDERS' => {
|
43
|
+
description: 'Purchase order message'
|
44
|
+
},
|
45
|
+
'SLSRPT' => {
|
46
|
+
description: 'Sales data report message'
|
47
|
+
},
|
48
|
+
'DESADV' => {
|
49
|
+
description: 'Despatch advice message'
|
50
|
+
},
|
51
|
+
'INVRPT' => {
|
52
|
+
description: 'Inventory report message'
|
53
|
+
},
|
54
|
+
'PRICAT' => {
|
55
|
+
description: 'Price catalogue message'
|
56
|
+
},
|
57
|
+
'ORDRSP' => {
|
58
|
+
description: 'Orders report message'
|
59
|
+
},
|
60
|
+
'INVOIC' => {
|
61
|
+
description: 'Invoice message'
|
62
|
+
},
|
63
|
+
'RETANN' => {
|
64
|
+
description: 'Announcement for returns message'
|
65
|
+
}
|
66
|
+
},
|
67
|
+
description: 'Message Type',
|
43
68
|
required: true
|
44
69
|
)
|
45
70
|
message_identifier.add(:message_type, data)
|
@@ -69,6 +94,9 @@ data = Eancom::Edifact::Data.new(
|
|
69
94
|
},
|
70
95
|
'96A' => {
|
71
96
|
description: 'Release 96A'
|
97
|
+
},
|
98
|
+
'UN' => {
|
99
|
+
description: 'UN/CEFACT'
|
72
100
|
}
|
73
101
|
},
|
74
102
|
description: 'Message release number',
|
@@ -82,6 +110,9 @@ data = Eancom::Edifact::Data.new(
|
|
82
110
|
dictionary: {
|
83
111
|
'UN' => {
|
84
112
|
description: 'UN/CEFACT'
|
113
|
+
},
|
114
|
+
'EN' => {
|
115
|
+
description: 'Default value'
|
85
116
|
}
|
86
117
|
},
|
87
118
|
description: 'Controlling agency',
|
@@ -92,15 +123,49 @@ message_identifier.add(:controlling_agency, data)
|
|
92
123
|
data = Eancom::Edifact::Data.new(
|
93
124
|
type: String,
|
94
125
|
length: 1..6,
|
95
|
-
dictionary:
|
126
|
+
dictionary: {
|
127
|
+
'EAN001' => {
|
128
|
+
description: 'GS1 version control number (GS1 Permanent Code)'
|
129
|
+
},
|
130
|
+
'EAN011' => {
|
131
|
+
description: 'GS1 version control number (GS1 Permanent Code)'
|
132
|
+
},
|
133
|
+
'EAN003' => {
|
134
|
+
description: 'GS1 version control number (GS1 Permanent Code)'
|
135
|
+
},
|
136
|
+
'EAN004' => {
|
137
|
+
description: 'GS1 version control number (GS1 Permanent Code)'
|
138
|
+
},
|
139
|
+
'EAN005' => {
|
140
|
+
description: 'GS1 version control number (GS1 Permanent Code)'
|
141
|
+
},
|
142
|
+
'EAN006' => {
|
143
|
+
description: 'GS1 version control number (GS1 Permanent Code)'
|
144
|
+
},
|
145
|
+
'EAN007' => {
|
146
|
+
description: 'GS1 version control number (GS1 Permanent Code)'
|
147
|
+
},
|
148
|
+
'EAN008' => {
|
149
|
+
description: 'GS1 version control number (GS1 Permanent Code)'
|
150
|
+
},
|
151
|
+
'EAN009' => {
|
152
|
+
description: 'GS1 version control number (GS1 Permanent Code)'
|
153
|
+
},
|
154
|
+
'EAN010' => {
|
155
|
+
description: 'GS1 version control number (GS1 Code)'
|
156
|
+
},
|
157
|
+
'GDSN23' => {
|
158
|
+
description: 'GDSN version 2.3 (GS1 Permanent Code)'
|
159
|
+
}
|
160
|
+
},
|
96
161
|
description: 'Association assigned code',
|
97
|
-
required:
|
162
|
+
required: false
|
98
163
|
)
|
99
164
|
message_identifier.add(:association_assigned_code, data)
|
100
165
|
|
101
166
|
structure << message_identifier
|
102
167
|
#==============================================================================
|
103
|
-
# Code list directory version number #
|
168
|
+
# Code list directory version number #
|
104
169
|
#==============================================================================
|
105
170
|
code_list_directory_version_number = Eancom::Edifact::Composite.new()
|
106
171
|
|
data/definitions/segments/uns.rb
CHANGED
@@ -8,7 +8,7 @@ structure = Eancom::Edifact::Structure.new(tag: tag)
|
|
8
8
|
tag = Eancom::Edifact::Composite.new()
|
9
9
|
data = Eancom::Edifact::Data.new(
|
10
10
|
type: String,
|
11
|
-
length: 3,
|
11
|
+
length: 1..3,
|
12
12
|
dictionary: nil,
|
13
13
|
description: "Message Header",
|
14
14
|
required: true
|
@@ -23,7 +23,7 @@ section_identification = Eancom::Edifact::Composite.new()
|
|
23
23
|
|
24
24
|
data = Eancom::Edifact::Data.new(
|
25
25
|
type: String,
|
26
|
-
length: 1,
|
26
|
+
length: 0..1,
|
27
27
|
dictionary: {
|
28
28
|
'S' => {
|
29
29
|
description: 'Detail/summary section separation',
|
data/definitions/segments/unt.rb
CHANGED
@@ -8,7 +8,7 @@ structure = Eancom::Edifact::Structure.new(tag: tag)
|
|
8
8
|
tag = Eancom::Edifact::Composite.new()
|
9
9
|
data = Eancom::Edifact::Data.new(
|
10
10
|
type: String,
|
11
|
-
length: 3,
|
11
|
+
length: 1..3,
|
12
12
|
dictionary: nil,
|
13
13
|
description: "Message Header",
|
14
14
|
required: true
|
@@ -38,7 +38,7 @@ data = Eancom::Edifact::Data.new(
|
|
38
38
|
type: String,
|
39
39
|
length: 1..14,
|
40
40
|
dictionary: nil,
|
41
|
-
description: "
|
41
|
+
description: "Message reference number",
|
42
42
|
required: true
|
43
43
|
)
|
44
44
|
message_reference_number.add(:message_reference_number, data)
|
data/definitions/slsrpt/d01b.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
Eancom::Definition.create(name: 'D01B', type: :slsrpt) 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',
|
7
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
15
|
)
|
16
16
|
|
17
17
|
header.segment Eancom::Edifact::UNH.new(
|
@@ -25,178 +25,182 @@ Eancom::Definition.create(name: 'D01B', type: :slsrpt) do |document, config|
|
|
25
25
|
end
|
26
26
|
|
27
27
|
document.body do |body|
|
28
|
-
|
29
|
-
# Messages
|
30
28
|
messages = config.body.messages
|
31
29
|
|
32
30
|
messages.each do |message|
|
33
|
-
|
31
|
+
code_list_identification_code = if message.code_list_identification_code.nil?
|
32
|
+
''
|
33
|
+
else
|
34
|
+
message.code_list_identification_code
|
35
|
+
end
|
34
36
|
body.segment Eancom::Edifact::BGM.new(
|
35
|
-
document_name_code:
|
36
|
-
code_list_identification_code:
|
37
|
+
document_name_code: message.document_name_code,
|
38
|
+
code_list_identification_code: code_list_identification_code,
|
37
39
|
code_list_responsible_agency_code: '9',
|
38
40
|
document_identifier: message.document_identifier,
|
39
|
-
message_function_code:
|
41
|
+
message_function_code: message.message_function_code
|
40
42
|
)
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
date_time_messages = message.date_time_messages
|
45
|
+
date_time_messages.each_with_index do |dtm, index|
|
46
|
+
next unless index == 0
|
47
|
+
|
48
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
49
|
+
key = dtm.identifier.intern.to_sym
|
50
|
+
body.segment Eancom::Edifact::DTM.new(
|
51
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
52
|
+
date_time: dtm[key].date_time,
|
53
|
+
format: '102'
|
54
|
+
)
|
55
|
+
end
|
56
|
+
|
57
|
+
date_time_messages.each_with_index do |dtm, index|
|
58
|
+
next unless index == 1
|
48
59
|
|
49
|
-
|
50
|
-
|
60
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
61
|
+
key = dtm.identifier.intern.to_sym
|
51
62
|
body.segment Eancom::Edifact::DTM.new(
|
52
|
-
type:
|
53
|
-
date_time: date_time,
|
63
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
64
|
+
date_time: dtm[key].date_time,
|
54
65
|
format: '102'
|
55
66
|
)
|
56
67
|
end
|
57
68
|
|
58
|
-
|
59
|
-
|
69
|
+
date_time_messages.each_with_index do |dtm, index|
|
70
|
+
next unless index == 2
|
71
|
+
|
72
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
73
|
+
key = dtm.identifier.intern.to_sym
|
60
74
|
body.segment Eancom::Edifact::DTM.new(
|
61
|
-
type:
|
62
|
-
date_time: date_time,
|
75
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
76
|
+
date_time: dtm[key].date_time,
|
63
77
|
format: '102'
|
64
78
|
)
|
65
79
|
end
|
66
80
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
supplier.code_list_responsible_agancy_code_1
|
74
|
-
)
|
75
|
-
else
|
76
|
-
'9'
|
77
|
-
end
|
81
|
+
nads = message.nads
|
82
|
+
nads.each_with_index do |nad, index|
|
83
|
+
next unless index == 0
|
84
|
+
|
85
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
86
|
+
key = nad.identifier.intern.to_sym
|
78
87
|
body.segment Eancom::Edifact::NAD.new(
|
79
|
-
party_function_code_qualifier:
|
80
|
-
party_identifier:
|
81
|
-
|
88
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
89
|
+
party_identifier: nad[key].party_identifier,
|
90
|
+
code_list_responsible_agency_code_1: '9'
|
82
91
|
)
|
83
92
|
end
|
84
93
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
:code_list_responsible_agancy_code_1,
|
91
|
-
buyer.code_list_responsible_agancy_code_1
|
92
|
-
)
|
93
|
-
else
|
94
|
-
'9'
|
95
|
-
end
|
94
|
+
nads.each_with_index do |nad, index|
|
95
|
+
next unless index == 1
|
96
|
+
|
97
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
98
|
+
key = nad.identifier.intern.to_sym
|
96
99
|
body.segment Eancom::Edifact::NAD.new(
|
97
|
-
party_function_code_qualifier:
|
98
|
-
party_identifier:
|
99
|
-
|
100
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
101
|
+
party_identifier: nad[key].party_identifier,
|
102
|
+
code_list_responsible_agency_code_1: '9'
|
100
103
|
)
|
101
104
|
end
|
102
105
|
|
103
106
|
# Reference Currency
|
104
107
|
if currency = message.currency
|
108
|
+
structure = Eancom.find_structure(tag: 'CUX')
|
105
109
|
body.segment Eancom::Edifact::CUX.new(
|
106
110
|
currency_identification_code_1: currency.currency_identification_code_1,
|
107
|
-
currency_type_code_qualifier_1:
|
108
|
-
|
111
|
+
currency_type_code_qualifier_1: structure.dictionary_lookup(:currency_type_code_qualifier_1,
|
112
|
+
currency.currency_type_code_qualifier_1),
|
113
|
+
currency_usage_code_qualifier_1: structure.dictionary_lookup(:currency_usage_code_qualifier_1,
|
114
|
+
currency.currency_usage_code_qualifier_1)
|
115
|
+
)
|
116
|
+
end
|
117
|
+
|
118
|
+
# Location
|
119
|
+
if location = message.location
|
120
|
+
structure = Eancom.find_structure(tag: 'LOC')
|
121
|
+
body.segment Eancom::Edifact::LOC.new(
|
122
|
+
code_list_identification_code: location.code_list_identification_code,
|
123
|
+
code_list_responsible_agency_code: structure.dictionary_lookup(:code_list_responsible_agency_code, location.code_list_responsible_agency_code),
|
124
|
+
location_function_qualifier: structure.dictionary_lookup(:location_function_qualifier, location.location_function_qualifier),
|
125
|
+
location_name_code: location.location_name_code
|
126
|
+
)
|
127
|
+
end
|
128
|
+
|
129
|
+
# Sales Date
|
130
|
+
date_time_messages.each_with_index do |dtm, index|
|
131
|
+
next unless index == 3
|
132
|
+
|
133
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
134
|
+
key = dtm.identifier.intern.to_sym
|
135
|
+
body.segment Eancom::Edifact::DTM.new(
|
136
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
137
|
+
date_time: dtm[key].date_time,
|
138
|
+
format: '102'
|
109
139
|
)
|
110
140
|
end
|
111
141
|
|
112
|
-
|
113
|
-
|
114
|
-
message.
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
142
|
+
total_quantity = 0
|
143
|
+
|
144
|
+
items = message.items
|
145
|
+
|
146
|
+
items.each_with_index do |item, index|
|
147
|
+
total_quantity += item.quantity.to_i
|
148
|
+
|
149
|
+
structure = Eancom.find_structure(tag: 'LIN')
|
150
|
+
body.segment Eancom::Edifact::LIN.new(
|
151
|
+
line_item_identifier_1: (index + 1).to_s,
|
152
|
+
item_identifier: item.ean,
|
153
|
+
item_type_identification_code: structure.dictionary_lookup(:item_type_identification_code, item.item_type_identification_code)
|
154
|
+
)
|
155
|
+
|
156
|
+
references = item.references
|
157
|
+
references.each_with_index do |rff, index|
|
158
|
+
structure = Eancom.find_structure(tag: 'RFF')
|
159
|
+
key = rff.identifier.intern.to_sym
|
160
|
+
body.segment Eancom::Edifact::RFF.new(
|
161
|
+
reference_code_qualifier: structure.dictionary_lookup(:reference_code_qualifier, rff.identifier),
|
162
|
+
reference_identifier: rff[key].reference_identifier
|
131
163
|
)
|
132
164
|
end
|
133
165
|
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
166
|
+
prices = item.prices
|
167
|
+
prices.each do |price|
|
168
|
+
next unless price = price.price
|
169
|
+
|
170
|
+
structure = Eancom.find_structure(tag: 'PRI')
|
171
|
+
body.segment Eancom::Edifact::PRI.new(
|
172
|
+
price_amount: price.price_amount,
|
173
|
+
price_code_qualifier: structure.dictionary_lookup(:price_code_qualifier, price.price_code_qualifier),
|
174
|
+
price_specification_code: structure.dictionary_lookup(:price_specification_code,
|
175
|
+
price.price_specification_code),
|
176
|
+
price_type_code: price.price_type_code
|
140
177
|
)
|
141
178
|
end
|
142
179
|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
body.segment Eancom::Edifact::
|
148
|
-
|
149
|
-
|
150
|
-
item_type_identification_code: 'SRV'
|
180
|
+
qty = item.quantities
|
181
|
+
qty.each_with_index do |qty, index|
|
182
|
+
structure = Eancom.find_structure(tag: 'QTY')
|
183
|
+
key = qty.identifier.intern.to_sym
|
184
|
+
body.segment Eancom::Edifact::QTY.new(
|
185
|
+
quantity_type_code_qualifier: structure.dictionary_lookup(:quantity_type_code_qualifier, qty.identifier),
|
186
|
+
quantity: qty[key].quantity
|
151
187
|
)
|
152
|
-
|
153
|
-
if transaction_reference_number = item.transaction_reference_number
|
154
|
-
body.segment Eancom::Edifact::RFF.new(
|
155
|
-
reference_code_qualifier: 'TN',
|
156
|
-
reference_identifier: transaction_reference_number.reference_identifier
|
157
|
-
)
|
158
|
-
end
|
159
|
-
|
160
|
-
prices = item.prices
|
161
|
-
prices.each do |price_group|
|
162
|
-
if price = price_group.price
|
163
|
-
structure = Eancom.find_structure(tag: 'PRI')
|
164
|
-
body.segment Eancom::Edifact::PRI.new(
|
165
|
-
price_amount: price.price_amount,
|
166
|
-
price_code_qualifier: structure.dictionary_lookup(:price_code_qualifier, price.price_code_qualifier),
|
167
|
-
price_specification_code: structure.dictionary_lookup(:price_specification_code, price.price_specification_code),
|
168
|
-
price_type_code: price.price_type_code
|
169
|
-
)
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
# Quantity
|
174
|
-
if statistical_sales_quantitiy = item.statistical_sales_quantitiy
|
175
|
-
body.segment Eancom::Edifact::QTY.new(
|
176
|
-
quantity_type_code_qualifier: '153',
|
177
|
-
quantity: statistical_sales_quantitiy.quantity
|
178
|
-
)
|
179
|
-
end
|
180
188
|
end
|
181
189
|
end
|
182
190
|
|
183
|
-
|
184
|
-
body.segment Eancom::Edifact::UNS.new(
|
185
|
-
section_identification: 'S'
|
186
|
-
)
|
187
|
-
|
188
191
|
body.segment Eancom::Edifact::UNT.new(
|
189
|
-
number_of_segments_in_message:
|
190
|
-
message_reference_number: config.header.message_reference_number
|
192
|
+
number_of_segments_in_message: (document.total_segments + 2).to_s,
|
193
|
+
message_reference_number: config.header.message_reference_number
|
191
194
|
)
|
192
195
|
end
|
196
|
+
end
|
193
197
|
|
194
|
-
|
198
|
+
document.footer do |footer|
|
199
|
+
messages = config.body.messages
|
195
200
|
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
end
|
201
|
+
footer.segment Eancom::Edifact::UNZ.new(
|
202
|
+
interchange_control_count: messages.size.to_s,
|
203
|
+
interchange_control_reference: config.header.interchange_control_reference.to_s
|
204
|
+
)
|
201
205
|
end
|
202
206
|
end
|