eancom 1.6.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +7 -4
- data/.gitlab-ci.yml +11 -13
- data/.ruby-version +1 -1
- data/Gemfile +2 -4
- data/Gemfile.lock +21 -103
- data/README.md +46 -0
- data/definitions/desadv/d01b.rb +134 -87
- data/definitions/desadv/d96a.rb +145 -82
- data/definitions/invoic/d01b.rb +559 -0
- data/definitions/invoic/d96a.rb +389 -0
- data/definitions/invrpt/d01b.rb +134 -0
- data/definitions/invrpt/d96a.rb +125 -0
- data/definitions/orders/d01b.rb +182 -0
- data/definitions/orders/d96b.rb +198 -0
- data/definitions/ordrsp/d01b.rb +251 -0
- data/definitions/ordrsp/d96b.rb +226 -0
- data/definitions/pricat/d01b.rb +225 -0
- data/definitions/pricat/d96b.rb +207 -0
- data/definitions/retann/d01b.rb +172 -0
- data/definitions/retann/d96b.rb +221 -0
- data/definitions/segments/ajt.rb +47 -0
- data/definitions/segments/alc.rb +128 -36
- data/definitions/segments/bgm.rb +122 -2
- data/definitions/segments/cdi.rb +39 -0
- data/definitions/segments/cnt.rb +4 -0
- data/definitions/segments/cta.rb +89 -0
- data/definitions/segments/cux.rb +9 -2
- data/definitions/segments/dgs.rb +34 -0
- data/definitions/segments/doc.rb +45 -0
- data/definitions/segments/dtm.rb +75 -20
- data/definitions/segments/efi.rb +67 -0
- data/definitions/segments/eqd.rb +37 -0
- data/definitions/segments/ftx.rb +22 -8
- data/definitions/segments/gin.rb +113 -0
- data/definitions/segments/imd.rb +9 -13
- data/definitions/segments/inv.rb +94 -0
- data/definitions/segments/lin.rb +24 -4
- data/definitions/segments/loc.rb +52 -4
- data/definitions/segments/moa.rb +86 -2
- data/definitions/segments/nad.rb +69 -9
- data/definitions/segments/pac.rb +12 -0
- data/definitions/segments/pat.rb +171 -0
- data/definitions/segments/pcd.rb +9 -92
- data/definitions/segments/pci.rb +110 -0
- data/definitions/segments/pgi.rb +7 -3
- data/definitions/segments/pia.rb +21 -29
- data/definitions/segments/pri.rb +25 -13
- data/definitions/segments/qty.rb +204 -2
- data/definitions/segments/rff.rb +49 -13
- data/definitions/segments/rte.rb +52 -0
- data/definitions/segments/tax.rb +17 -10
- data/definitions/segments/tdt.rb +24 -0
- data/definitions/segments/tod.rb +64 -0
- data/definitions/segments/tru.rb +34 -0
- data/definitions/segments/una.rb +8 -8
- data/definitions/segments/unb.rb +4 -7
- data/definitions/segments/unh.rb +70 -5
- data/definitions/segments/uns.rb +2 -2
- data/definitions/segments/unt.rb +2 -2
- data/definitions/slsrpt/d01b.rb +132 -128
- data/definitions/slsrpt/d96a.rb +132 -129
- data/eancom.gemspec +5 -8
- data/lib/eancom/edifact/body.rb +37 -18
- data/lib/eancom/edifact/document.rb +20 -16
- data/lib/eancom/edifact/footer.rb +1 -0
- data/lib/eancom/edifact/item.rb +1 -1
- data/lib/eancom/edifact/message.rb +7 -39
- data/lib/eancom/edifact/segment.rb +9 -11
- data/lib/eancom/edifact/segments/ajt.rb +32 -0
- data/lib/eancom/edifact/segments/ali.rb +2 -4
- data/lib/eancom/edifact/segments/bgm.rb +4 -3
- data/lib/eancom/edifact/segments/cdi.rb +30 -0
- data/lib/eancom/edifact/segments/cnt.rb +8 -1
- data/lib/eancom/edifact/segments/cps.rb +4 -1
- data/lib/eancom/edifact/segments/cta.rb +30 -0
- data/lib/eancom/edifact/segments/cux.rb +1 -1
- data/lib/eancom/edifact/segments/dgs.rb +31 -0
- data/lib/eancom/edifact/segments/doc.rb +30 -0
- data/lib/eancom/edifact/segments/dtm.rb +10 -6
- data/lib/eancom/edifact/segments/efi.rb +38 -0
- data/lib/eancom/edifact/segments/eqd.rb +30 -0
- data/lib/eancom/edifact/segments/ftx.rb +2 -2
- data/lib/eancom/edifact/segments/gin.rb +45 -0
- data/lib/eancom/edifact/segments/imd.rb +1 -1
- data/lib/eancom/edifact/segments/inv.rb +43 -0
- data/lib/eancom/edifact/segments/lin.rb +7 -4
- data/lib/eancom/edifact/segments/loc.rb +8 -9
- data/lib/eancom/edifact/segments/mea.rb +1 -0
- data/lib/eancom/edifact/segments/moa.rb +3 -3
- data/lib/eancom/edifact/segments/nad.rb +11 -6
- data/lib/eancom/edifact/segments/pac.rb +3 -1
- data/lib/eancom/edifact/segments/pat.rb +37 -0
- data/lib/eancom/edifact/segments/pcd.rb +6 -17
- data/lib/eancom/edifact/segments/pci.rb +40 -0
- data/lib/eancom/edifact/segments/pia.rb +1 -0
- data/lib/eancom/edifact/segments/pri.rb +0 -1
- data/lib/eancom/edifact/segments/qty.rb +9 -5
- data/lib/eancom/edifact/segments/rff.rb +8 -2
- data/lib/eancom/edifact/segments/rte.rb +33 -0
- data/lib/eancom/edifact/segments/tax.rb +7 -1
- data/lib/eancom/edifact/segments/tdt.rb +4 -1
- data/lib/eancom/edifact/segments/tod.rb +33 -0
- data/lib/eancom/edifact/segments/tru.rb +31 -0
- data/lib/eancom/edifact/segments/una.rb +2 -1
- data/lib/eancom/edifact/segments/unb.rb +4 -5
- data/lib/eancom/edifact/segments/unh.rb +6 -4
- data/lib/eancom/edifact/segments/uns.rb +4 -1
- data/lib/eancom/edifact/structure.rb +0 -1
- data/lib/eancom/edifact.rb +15 -4
- data/lib/eancom/factory.rb +1 -1
- data/lib/eancom/parser/document.rb +3 -16
- data/lib/eancom/parser/segment.rb +9 -10
- data/lib/eancom/version.rb +1 -3
- data/lib/eancom.rb +3 -1
- data/pricat.json +1 -0
- metadata +45 -51
- data/.rubocop.yml +0 -2
- data/.tool-versions +0 -1
- data/definitions/segments/qvr.rb +0 -140
- data/lib/eancom/edifact/location.rb +0 -56
- data/lib/eancom/edifact/segments/qvr.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37e80db4ce2849be0d078d6cc80719f660f401b0a3f3141953af97568487a6b7
|
4
|
+
data.tar.gz: d95843f6ca45bc82ad47d49a1f5843d137f07626d6e230d04627a9e548cec48a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e4de3651ecc8acbe7beaf5e1f2d0a8f60d0fd1bc036af2a139c8d328bfae568585494298f555d1472fe06f0e7e0bda8324bce2e72f99e2fd9fea6c4bc0b009c
|
7
|
+
data.tar.gz: 020572b6a835b381c3d1519fcdf4445c53f5cc82722ca56882451e4d6bed7c39f3a61405f71c83740712060cc3eed1890ade00b0c79440ff991e666bc1c9ebba
|
data/.gitignore
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
### macOS ###
|
21
21
|
# General
|
22
|
-
|
22
|
+
.DS_Store
|
23
23
|
.AppleDouble
|
24
24
|
.LSOverride
|
25
25
|
|
@@ -49,7 +49,6 @@ Temporary Items
|
|
49
49
|
*.rbc
|
50
50
|
capybara-*.html
|
51
51
|
.rspec
|
52
|
-
.rspec_status
|
53
52
|
/db/*.sqlite3
|
54
53
|
/db/*.sqlite3-journal
|
55
54
|
/public/system
|
@@ -163,7 +162,7 @@ build-iPhoneSimulator/
|
|
163
162
|
|
164
163
|
### Ruby Patch ###
|
165
164
|
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
166
|
-
.rubocop-https?--*
|
165
|
+
# .rubocop-https?--*
|
167
166
|
|
168
167
|
### Vim ###
|
169
168
|
# Swap
|
@@ -190,4 +189,8 @@ tags
|
|
190
189
|
# Coc configuration directory
|
191
190
|
.vim
|
192
191
|
|
193
|
-
#
|
192
|
+
# Ignore Gemfile.lock
|
193
|
+
Gemfile.lock
|
194
|
+
|
195
|
+
# Rspec
|
196
|
+
.rspec_status
|
data/.gitlab-ci.yml
CHANGED
@@ -1,27 +1,25 @@
|
|
1
|
-
variables:
|
2
|
-
RUBY_DOCKER_IMAGE: eu.gcr.io/fadendaten-staging/ruby:3.0.2-alpine-dev
|
3
|
-
|
4
1
|
include:
|
5
|
-
- project: fadendaten/
|
6
|
-
file:
|
2
|
+
- project: fadendaten/meta
|
3
|
+
file: gitlab-ci.base.yml
|
4
|
+
|
7
5
|
|
8
6
|
stages:
|
9
7
|
- pre-test
|
10
|
-
- lint
|
11
8
|
- test
|
12
9
|
|
13
10
|
Cache assets:
|
14
11
|
stage: pre-test
|
15
|
-
extends: .cache_assets
|
16
|
-
|
17
|
-
pronto:
|
18
|
-
stage: pre-test
|
19
|
-
extends: .pronto:fadendaten
|
12
|
+
extends: .cache_assets
|
20
13
|
|
21
14
|
rspec:
|
22
15
|
stage: test
|
23
|
-
|
24
|
-
|
16
|
+
cache:
|
17
|
+
key: ${CI_PROJECT_NAME}-bundle-cache
|
18
|
+
paths:
|
19
|
+
- vendor/ruby
|
20
|
+
policy: pull
|
21
|
+
image: ruby:3.0.0
|
22
|
+
before_script:
|
25
23
|
- bundle check --path=vendor || bundle install --path=vendor --jobs=$(nproc)
|
26
24
|
script:
|
27
25
|
- bundle exec rspec spec/
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.0.0
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,69 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
eancom (1.
|
4
|
+
eancom (1.0.1)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
coderay (1.1.2)
|
13
|
-
diff-lcs (1.3)
|
14
|
-
docile (1.4.0)
|
15
|
-
faraday (1.10.0)
|
16
|
-
faraday-em_http (~> 1.0)
|
17
|
-
faraday-em_synchrony (~> 1.0)
|
18
|
-
faraday-excon (~> 1.1)
|
19
|
-
faraday-httpclient (~> 1.0)
|
20
|
-
faraday-multipart (~> 1.0)
|
21
|
-
faraday-net_http (~> 1.0)
|
22
|
-
faraday-net_http_persistent (~> 1.0)
|
23
|
-
faraday-patron (~> 1.0)
|
24
|
-
faraday-rack (~> 1.0)
|
25
|
-
faraday-retry (~> 1.0)
|
26
|
-
ruby2_keywords (>= 0.0.4)
|
27
|
-
faraday-em_http (1.0.0)
|
28
|
-
faraday-em_synchrony (1.0.0)
|
29
|
-
faraday-excon (1.1.0)
|
30
|
-
faraday-httpclient (1.0.1)
|
31
|
-
faraday-multipart (1.0.3)
|
32
|
-
multipart-post (>= 1.2, < 3)
|
33
|
-
faraday-net_http (1.0.1)
|
34
|
-
faraday-net_http_persistent (1.2.0)
|
35
|
-
faraday-patron (1.0.0)
|
36
|
-
faraday-rack (1.0.0)
|
37
|
-
faraday-retry (1.0.3)
|
38
|
-
gitlab (4.18.0)
|
39
|
-
httparty (~> 0.18)
|
40
|
-
terminal-table (>= 1.5.1)
|
41
|
-
httparty (0.20.0)
|
42
|
-
mime-types (~> 3.0)
|
43
|
-
multi_xml (>= 0.5.2)
|
9
|
+
coderay (1.1.3)
|
10
|
+
diff-lcs (1.4.4)
|
11
|
+
docile (1.3.5)
|
44
12
|
method_source (0.9.2)
|
45
|
-
mime-types (3.4.1)
|
46
|
-
mime-types-data (~> 3.2015)
|
47
|
-
mime-types-data (3.2022.0105)
|
48
|
-
multi_xml (0.6.0)
|
49
|
-
multipart-post (2.1.1)
|
50
|
-
octokit (4.22.0)
|
51
|
-
faraday (>= 0.9)
|
52
|
-
sawyer (~> 0.8.0, >= 0.5.3)
|
53
|
-
parallel (1.22.1)
|
54
|
-
parser (3.1.2.0)
|
55
|
-
ast (~> 2.4.1)
|
56
|
-
pronto (0.11.0)
|
57
|
-
gitlab (~> 4.4, >= 4.4.0)
|
58
|
-
httparty (>= 0.13.7)
|
59
|
-
octokit (~> 4.7, >= 4.7.0)
|
60
|
-
rainbow (>= 2.2, < 4.0)
|
61
|
-
rexml (~> 3.2)
|
62
|
-
rugged (>= 0.23.0, < 1.1.0)
|
63
|
-
thor (>= 0.20.3, < 2.0)
|
64
|
-
pronto-rubocop (0.11.1)
|
65
|
-
pronto (~> 0.11.0)
|
66
|
-
rubocop (>= 0.63.1, < 2.0)
|
67
13
|
pry (0.12.2)
|
68
14
|
coderay (~> 1.1.0)
|
69
15
|
method_source (~> 0.9.0)
|
@@ -72,69 +18,41 @@ GEM
|
|
72
18
|
pry-remote (0.1.8)
|
73
19
|
pry (~> 0.9)
|
74
20
|
slop (~> 3.0)
|
75
|
-
public_suffix (4.0.7)
|
76
|
-
rainbow (3.1.1)
|
77
21
|
rake (12.3.3)
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
rspec-
|
82
|
-
|
83
|
-
rspec-
|
84
|
-
rspec-
|
85
|
-
rspec-support (~> 3.9.1)
|
86
|
-
rspec-expectations (3.9.0)
|
22
|
+
rspec (3.10.0)
|
23
|
+
rspec-core (~> 3.10.0)
|
24
|
+
rspec-expectations (~> 3.10.0)
|
25
|
+
rspec-mocks (~> 3.10.0)
|
26
|
+
rspec-core (3.10.1)
|
27
|
+
rspec-support (~> 3.10.0)
|
28
|
+
rspec-expectations (3.10.1)
|
87
29
|
diff-lcs (>= 1.2.0, < 2.0)
|
88
|
-
rspec-support (~> 3.
|
89
|
-
rspec-mocks (3.
|
30
|
+
rspec-support (~> 3.10.0)
|
31
|
+
rspec-mocks (3.10.2)
|
90
32
|
diff-lcs (>= 1.2.0, < 2.0)
|
91
|
-
rspec-support (~> 3.
|
92
|
-
rspec-support (3.
|
93
|
-
|
94
|
-
parallel (~> 1.10)
|
95
|
-
parser (>= 3.1.0.0)
|
96
|
-
rainbow (>= 2.2.2, < 4.0)
|
97
|
-
regexp_parser (>= 1.8, < 3.0)
|
98
|
-
rexml (>= 3.2.5, < 4.0)
|
99
|
-
rubocop-ast (>= 1.17.0, < 2.0)
|
100
|
-
ruby-progressbar (~> 1.7)
|
101
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
102
|
-
rubocop-ast (1.18.0)
|
103
|
-
parser (>= 3.1.1.0)
|
104
|
-
ruby-progressbar (1.11.0)
|
105
|
-
ruby2_keywords (0.0.5)
|
106
|
-
rugged (1.0.1)
|
107
|
-
sawyer (0.8.2)
|
108
|
-
addressable (>= 2.3.5)
|
109
|
-
faraday (> 0.8, < 2.0)
|
110
|
-
simplecov (0.22.0)
|
33
|
+
rspec-support (~> 3.10.0)
|
34
|
+
rspec-support (3.10.2)
|
35
|
+
simplecov (0.21.2)
|
111
36
|
docile (~> 1.1)
|
112
37
|
simplecov-html (~> 0.11)
|
113
38
|
simplecov_json_formatter (~> 0.1)
|
114
39
|
simplecov-html (0.12.3)
|
115
|
-
simplecov_json_formatter (0.1.
|
40
|
+
simplecov_json_formatter (0.1.2)
|
116
41
|
slop (3.6.0)
|
117
|
-
|
118
|
-
unicode-display_width (>= 1.1.1, < 3)
|
119
|
-
thor (1.2.1)
|
120
|
-
timecop (0.9.1)
|
121
|
-
unicode-display_width (2.1.0)
|
42
|
+
timecop (0.9.4)
|
122
43
|
|
123
44
|
PLATFORMS
|
124
45
|
ruby
|
125
46
|
|
126
47
|
DEPENDENCIES
|
127
48
|
eancom!
|
128
|
-
pronto
|
129
|
-
pronto-rubocop
|
130
49
|
pry
|
131
50
|
pry-nav
|
132
51
|
pry-remote
|
133
|
-
rake
|
134
|
-
rspec
|
135
|
-
rubocop
|
52
|
+
rake (~> 12.0)
|
53
|
+
rspec (~> 3.0)
|
136
54
|
simplecov
|
137
55
|
timecop
|
138
56
|
|
139
57
|
BUNDLED WITH
|
140
|
-
2.2.
|
58
|
+
2.2.11
|
data/README.md
CHANGED
@@ -1,2 +1,48 @@
|
|
1
1
|
# Eancom
|
2
2
|
|
3
|
+
This software translates EDI to JSON messages.
|
4
|
+
The following message types are supported:
|
5
|
+
|
6
|
+
* ORDRSP
|
7
|
+
* PRICAT
|
8
|
+
* ORDERS
|
9
|
+
* DESADV
|
10
|
+
* INVOIC
|
11
|
+
* SLSRPT
|
12
|
+
* RETANN
|
13
|
+
|
14
|
+
It will be expanded into a fully fledged gem later on.
|
15
|
+
|
16
|
+
## Translate EDI to JSON messages
|
17
|
+
|
18
|
+
In order to translate EDI to JSON messages, open the terminal and type in the following commands within the project structure.
|
19
|
+
|
20
|
+
* `bin/console`<br/>
|
21
|
+
Opens the console.
|
22
|
+
* `edi_file = File.open('filepath')`<br/>
|
23
|
+
Opens the EDI file that needs to be translated.
|
24
|
+
* `json = Eancom::Parser::Document.new(file: edi_file).parse.to_json`<br/>
|
25
|
+
Translates the EDI file to a JSON file and stores it under the name json.
|
26
|
+
|
27
|
+
## Translate JSON to EDI messages
|
28
|
+
|
29
|
+
Similarily, in order to translate JSON to EDI messages, open the terminal and type the following commands within the project structure.
|
30
|
+
|
31
|
+
* `bin/console`<br/>
|
32
|
+
Opens the console.
|
33
|
+
* `json_file = File.open('filepath')`<br/>
|
34
|
+
Opens the EDI file that needs to be translated.
|
35
|
+
* `edi = Eancom::Factory.new(json: json_file.read).build.to_s`<br/>
|
36
|
+
Translates the JSON file to a EDI file and stores it under the name edi.
|
37
|
+
|
38
|
+
## Supported message formats
|
39
|
+
|
40
|
+
The GS1 standard contains many different messaging formats. Two of the most popular ones are the D96A and the D01B formats, both of which are implemented in this translator. The main difference between them is how the messages are structured, not what kind of segments or descriptions they contain. Please respect the structure defined by these formats. Otherwise the translator may reject your file.
|
41
|
+
|
42
|
+
## Usage
|
43
|
+
|
44
|
+
You can add this gem to your project by either installing it using `bundle install prime-eancom` or by adding `gem "prime-eancom", "~> 0.1.0"` to your Gemfile. If you choose the latter option, go to your projects file structure within the terminal, type `bundle install` and hit `enter`. The prime-eancom now serenely inhabits your project.
|
45
|
+
|
46
|
+
## Testing
|
47
|
+
|
48
|
+
The prime-eancom is being tested with `rspec`. If you wan't to run the tests, go to the projects file structure within the terminal, type `rspec` and hit `enter`. You can also use `bundle exec rspec spec/` if the former option doesn't work.
|
data/definitions/desadv/d01b.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
Eancom::Definition.create(name: 'D01B', type: :desadv) do |document, config|
|
4
2
|
document.header do |header|
|
5
3
|
header.segment Eancom::Edifact::UNA.new
|
@@ -14,8 +12,8 @@ Eancom::Definition.create(name: 'D01B', type: :desadv) do |document, config|
|
|
14
12
|
date: config.header.date,
|
15
13
|
time: config.header.time,
|
16
14
|
interchange_control_reference: config.header.interchange_control_reference,
|
17
|
-
application_reference:
|
18
|
-
interchange_agreement_identifier:
|
15
|
+
application_reference: config.header.application_reference,
|
16
|
+
interchange_agreement_identifier: config.header.interchange_agreement_identifier,
|
19
17
|
test_indicator: '0'
|
20
18
|
)
|
21
19
|
|
@@ -35,106 +33,130 @@ Eancom::Definition.create(name: 'D01B', type: :desadv) do |document, config|
|
|
35
33
|
|
36
34
|
messages.each do |message|
|
37
35
|
body.segment Eancom::Edifact::BGM.new(
|
38
|
-
document_name_code:
|
36
|
+
document_name_code: message.document_name_code,
|
39
37
|
document_identifier: message.document_identifier,
|
40
|
-
message_function_code:
|
38
|
+
message_function_code: message.message_function_code
|
41
39
|
)
|
42
40
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
date_time: message.document_message_date_time.date_time,
|
47
|
-
format: '204'
|
48
|
-
)
|
41
|
+
date_time_messages = message.date_time_messages
|
42
|
+
date_time_messages.each_with_index do |dtm, index|
|
43
|
+
next unless index == 0
|
49
44
|
|
50
|
-
|
51
|
-
|
45
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
46
|
+
key = dtm.identifier.intern.to_sym
|
52
47
|
body.segment Eancom::Edifact::DTM.new(
|
53
|
-
type:
|
54
|
-
date_time: date_time,
|
48
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
49
|
+
date_time: dtm[key].date_time,
|
55
50
|
format: '204'
|
56
51
|
)
|
57
52
|
end
|
58
53
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
54
|
+
date_time_messages.each_with_index do |dtm, index|
|
55
|
+
next unless index == 1
|
56
|
+
|
57
|
+
structure = Eancom.find_structure(tag: 'DTM')
|
58
|
+
key = dtm.identifier.intern.to_sym
|
59
|
+
body.segment Eancom::Edifact::DTM.new(
|
60
|
+
type: structure.dictionary_lookup(:type, dtm.identifier),
|
61
|
+
date_time: dtm[key].date_time,
|
62
|
+
format: '204'
|
64
63
|
)
|
65
64
|
end
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
66
|
+
references = message.references
|
67
|
+
references.each_with_index do |rff, index|
|
68
|
+
next unless index == 0
|
69
|
+
structure = Eancom.find_structure(tag: 'RFF')
|
70
|
+
key = rff.identifier.intern.to_sym
|
71
|
+
body.segment Eancom::Edifact::RFF.new(
|
72
|
+
reference_code_qualifier: structure.dictionary_lookup(:reference_code_qualifier, rff.identifier),
|
73
|
+
reference_identifier: rff[key].reference_identifier
|
73
74
|
)
|
74
75
|
end
|
75
76
|
|
76
77
|
# Supplier
|
77
|
-
|
78
|
+
nads = message.nads
|
79
|
+
nads.each_with_index do |nad, index|
|
80
|
+
next unless index == 0
|
81
|
+
|
82
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
83
|
+
key = nad.identifier.intern.to_sym
|
78
84
|
body.segment Eancom::Edifact::NAD.new(
|
79
|
-
party_function_code_qualifier:
|
80
|
-
party_identifier:
|
81
|
-
|
85
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
86
|
+
party_identifier: nad[key].party_identifier,
|
87
|
+
code_list_responsible_agency_code_1: '9'
|
82
88
|
)
|
83
89
|
end
|
84
90
|
|
85
91
|
# Manufacturer ILN
|
86
|
-
|
92
|
+
nads = message.nads
|
93
|
+
nads.each_with_index do |nad, index|
|
94
|
+
next unless index == 1
|
95
|
+
|
96
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
97
|
+
key = nad.identifier.intern.to_sym
|
87
98
|
body.segment Eancom::Edifact::NAD.new(
|
88
|
-
party_function_code_qualifier:
|
89
|
-
party_identifier:
|
90
|
-
|
99
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
100
|
+
party_identifier: nad[key].party_identifier,
|
101
|
+
code_list_responsible_agency_code_1: '9'
|
91
102
|
)
|
92
103
|
end
|
93
104
|
|
94
|
-
|
95
|
-
|
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
|
96
111
|
body.segment Eancom::Edifact::NAD.new(
|
97
|
-
party_function_code_qualifier:
|
98
|
-
party_identifier:
|
99
|
-
|
100
|
-
city_name:
|
101
|
-
party_name_1:
|
102
|
-
postal_identification_code:
|
103
|
-
street_and_number_1:
|
104
|
-
country_name_code:
|
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
|
+
city_name: nad[key].city_name,
|
116
|
+
party_name_1: nad[key].party_name_1,
|
117
|
+
postal_identification_code: nad[key].postal_identification_code,
|
118
|
+
street_and_number_1: nad[key].street_and_number_1,
|
119
|
+
country_name_code: nad[key].country_name_code
|
105
120
|
)
|
106
121
|
end
|
107
122
|
|
108
123
|
# Ultimate consignee
|
109
|
-
|
124
|
+
nads = message.nads
|
125
|
+
nads.each_with_index do |nad, index|
|
126
|
+
next unless index == 3
|
127
|
+
|
128
|
+
structure = Eancom.find_structure(tag: 'NAD')
|
129
|
+
key = nad.identifier.intern.to_sym
|
110
130
|
body.segment Eancom::Edifact::NAD.new(
|
111
|
-
party_function_code_qualifier:
|
112
|
-
party_identifier:
|
113
|
-
|
114
|
-
city_name:
|
115
|
-
party_name_1:
|
116
|
-
postal_identification_code:
|
117
|
-
street_and_number_1:
|
118
|
-
country_name_code:
|
131
|
+
party_function_code_qualifier: structure.dictionary_lookup(:party_function_code_qualifier, nad.identifier),
|
132
|
+
party_identifier: nad[key].party_identifier,
|
133
|
+
code_list_responsible_agency_code_1: '9',
|
134
|
+
city_name: nad[key].city_name,
|
135
|
+
party_name_1: nad[key].party_name_1,
|
136
|
+
postal_identification_code: nad[key].postal_identification_code,
|
137
|
+
street_and_number_1: nad[key].street_and_number_1,
|
138
|
+
country_name_code: nad[key].country_name_code
|
119
139
|
)
|
120
140
|
end
|
121
141
|
|
142
|
+
structure = Eancom.find_structure(tag: 'TDT')
|
143
|
+
qualifier = structure.dictionary_lookup(:transport_stage_code_qualifier, message.transport_stage_code_qualifier)
|
122
144
|
body.segment Eancom::Edifact::TDT.new(
|
123
|
-
transport_stage_code_qualifier:
|
124
|
-
transport_mode_name_code:
|
145
|
+
transport_stage_code_qualifier: qualifier,
|
146
|
+
transport_mode_name_code: message.transport_mode_name_code
|
125
147
|
)
|
126
|
-
#
|
148
|
+
# CPS can remain hardcoded.
|
127
149
|
body.segment Eancom::Edifact::CPS.new(
|
128
150
|
hierarchical_structure_level_identifier: '1'
|
129
151
|
)
|
130
152
|
|
131
153
|
body.segment Eancom::Edifact::PAC.new(
|
132
|
-
package_quantity:
|
154
|
+
package_quantity: message.package_quantity
|
133
155
|
)
|
134
156
|
|
135
157
|
body.segment Eancom::Edifact::CPS.new(
|
136
158
|
hierarchical_structure_level_identifier: '2',
|
137
|
-
hierarchical_structure_parent_identifier:
|
159
|
+
hierarchical_structure_parent_identifier: message.hierarchical_structure_parent_identifier
|
138
160
|
)
|
139
161
|
|
140
162
|
# Items
|
@@ -145,59 +167,84 @@ Eancom::Definition.create(name: 'D01B', type: :desadv) do |document, config|
|
|
145
167
|
items.each_with_index do |item, index|
|
146
168
|
total_quantity += item.quantity.to_i
|
147
169
|
|
170
|
+
structure = Eancom.find_structure(tag: 'LIN')
|
148
171
|
body.segment Eancom::Edifact::LIN.new(
|
149
|
-
line_item_identifier_1:
|
172
|
+
line_item_identifier_1: (index + 1).to_s,
|
150
173
|
item_identifier: item.ean,
|
151
|
-
item_type_identification_code:
|
174
|
+
item_type_identification_code: structure.dictionary_lookup(:item_type_identification_code, item.item_type_identification_code)
|
152
175
|
)
|
153
176
|
|
154
177
|
if additional_product_id = item.additional_product_id
|
155
178
|
additional_product_id.each do |id|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
179
|
+
next unless additional_information = id.additional_information
|
180
|
+
|
181
|
+
structure = Eancom.find_structure(tag: 'PIA')
|
182
|
+
body.segment Eancom::Edifact::PIA.new(
|
183
|
+
product_identifier_code_qualifier: structure.dictionary_lookup(:product_identifier_code_qualifier, additional_information.product_identifier_code_qualifier),
|
184
|
+
item_identifier_1: additional_information.item_identifier_1,
|
185
|
+
item_type_identification_code_1: structure.dictionary_lookup(:item_type_identification_code_1,
|
186
|
+
additional_information.item_type_identification_code_1)
|
187
|
+
)
|
163
188
|
end
|
164
189
|
end
|
165
190
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
191
|
+
item_descriptions = item.item_descriptions
|
192
|
+
item_descriptions.each do |description|
|
193
|
+
structure = Eancom.find_structure(tag: 'IMD')
|
194
|
+
body.segment Eancom::Edifact::IMD.new(
|
195
|
+
description_format_code: structure.dictionary_lookup(:description_format_code,
|
196
|
+
description.description_format_code),
|
197
|
+
item_description_code: structure.dictionary_lookup(:item_description_code,
|
198
|
+
description.item_description_code),
|
199
|
+
code_list_responsible_agency_code_1: structure.dictionary_lookup(:code_list_responsible_agency_code_1, description.code_list_responsible_agency_code_1)
|
200
|
+
)
|
201
|
+
end
|
171
202
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
203
|
+
quantities = item.quantities
|
204
|
+
quantities.each_with_index do |qty, index|
|
205
|
+
next unless index == 0
|
206
|
+
structure = Eancom.find_structure(tag: 'QTY')
|
207
|
+
key = qty.identifier.intern.to_sym
|
208
|
+
body.segment Eancom::Edifact::QTY.new(
|
209
|
+
quantity_type_code_qualifier: structure.dictionary_lookup(:quantity_type_code_qualifier, qty.identifier),
|
210
|
+
quantity: qty[key].quantity.to_s
|
211
|
+
)
|
212
|
+
end
|
213
|
+
|
214
|
+
quantities.each_with_index do |qty, index|
|
215
|
+
next unless index == 1
|
216
|
+
structure = Eancom.find_structure(tag: 'QTY')
|
217
|
+
key = qty.identifier.intern.to_sym
|
218
|
+
body.segment Eancom::Edifact::QTY.new(
|
219
|
+
quantity_type_code_qualifier: structure.dictionary_lookup(:quantity_type_code_qualifier, qty.identifier),
|
220
|
+
quantity: qty[key].quantity.to_s
|
221
|
+
)
|
222
|
+
end
|
176
223
|
|
177
|
-
body.segment Eancom::Edifact::QTY.new(
|
178
|
-
quantity_type_code_qualifier: '59',
|
179
|
-
quantity: item.despatch_quantity.quantity.to_s
|
180
|
-
)
|
181
224
|
|
182
|
-
|
225
|
+
references = item.references
|
226
|
+
references.each_with_index do |rff, index|
|
227
|
+
structure = Eancom.find_structure(tag: 'RFF')
|
228
|
+
key = rff.identifier.intern.to_sym
|
183
229
|
body.segment Eancom::Edifact::RFF.new(
|
184
|
-
reference_code_qualifier:
|
185
|
-
reference_identifier:
|
186
|
-
document_line_identifier:
|
230
|
+
reference_code_qualifier: structure.dictionary_lookup(:reference_code_qualifier, rff.identifier),
|
231
|
+
reference_identifier: rff[key].reference_identifier,
|
232
|
+
document_line_identifier: rff[key].document_line_identifier
|
187
233
|
)
|
188
234
|
end
|
189
235
|
end
|
190
236
|
|
191
237
|
body.segment Eancom::Edifact::UNT.new(
|
192
238
|
number_of_segments_in_message: (document.total_segments + 2).to_s,
|
193
|
-
message_reference_number:
|
239
|
+
message_reference_number: config.header.message_reference_number
|
194
240
|
)
|
195
241
|
end
|
196
242
|
end
|
197
243
|
|
244
|
+
messages = config.body.messages
|
198
245
|
document.footer do |footer|
|
199
246
|
footer.segment Eancom::Edifact::UNZ.new(
|
200
|
-
interchange_control_count:
|
247
|
+
interchange_control_count: messages.size.to_s,
|
201
248
|
interchange_control_reference: config.header.interchange_control_reference.to_s
|
202
249
|
)
|
203
250
|
end
|