eancom 1.6.3 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -4
  3. data/.gitlab-ci.yml +11 -13
  4. data/.ruby-version +1 -1
  5. data/Gemfile +2 -4
  6. data/Gemfile.lock +21 -103
  7. data/README.md +46 -0
  8. data/definitions/desadv/d01b.rb +134 -87
  9. data/definitions/desadv/d96a.rb +145 -82
  10. data/definitions/invoic/d01b.rb +559 -0
  11. data/definitions/invoic/d96a.rb +389 -0
  12. data/definitions/invrpt/d01b.rb +134 -0
  13. data/definitions/invrpt/d96a.rb +125 -0
  14. data/definitions/orders/d01b.rb +182 -0
  15. data/definitions/orders/d96b.rb +198 -0
  16. data/definitions/ordrsp/d01b.rb +251 -0
  17. data/definitions/ordrsp/d96b.rb +226 -0
  18. data/definitions/pricat/d01b.rb +225 -0
  19. data/definitions/pricat/d96b.rb +207 -0
  20. data/definitions/retann/d01b.rb +172 -0
  21. data/definitions/retann/d96b.rb +221 -0
  22. data/definitions/segments/ajt.rb +47 -0
  23. data/definitions/segments/alc.rb +128 -36
  24. data/definitions/segments/bgm.rb +122 -2
  25. data/definitions/segments/cdi.rb +39 -0
  26. data/definitions/segments/cnt.rb +4 -0
  27. data/definitions/segments/cta.rb +89 -0
  28. data/definitions/segments/cux.rb +9 -2
  29. data/definitions/segments/dgs.rb +34 -0
  30. data/definitions/segments/doc.rb +45 -0
  31. data/definitions/segments/dtm.rb +75 -20
  32. data/definitions/segments/efi.rb +67 -0
  33. data/definitions/segments/eqd.rb +37 -0
  34. data/definitions/segments/ftx.rb +22 -8
  35. data/definitions/segments/gin.rb +113 -0
  36. data/definitions/segments/imd.rb +9 -13
  37. data/definitions/segments/inv.rb +94 -0
  38. data/definitions/segments/lin.rb +24 -4
  39. data/definitions/segments/loc.rb +52 -4
  40. data/definitions/segments/moa.rb +86 -2
  41. data/definitions/segments/nad.rb +69 -9
  42. data/definitions/segments/pac.rb +12 -0
  43. data/definitions/segments/pat.rb +171 -0
  44. data/definitions/segments/pcd.rb +9 -92
  45. data/definitions/segments/pci.rb +110 -0
  46. data/definitions/segments/pgi.rb +7 -3
  47. data/definitions/segments/pia.rb +21 -29
  48. data/definitions/segments/pri.rb +25 -13
  49. data/definitions/segments/qty.rb +204 -2
  50. data/definitions/segments/rff.rb +49 -13
  51. data/definitions/segments/rte.rb +52 -0
  52. data/definitions/segments/tax.rb +17 -10
  53. data/definitions/segments/tdt.rb +24 -0
  54. data/definitions/segments/tod.rb +64 -0
  55. data/definitions/segments/tru.rb +34 -0
  56. data/definitions/segments/una.rb +8 -8
  57. data/definitions/segments/unb.rb +4 -7
  58. data/definitions/segments/unh.rb +70 -5
  59. data/definitions/segments/uns.rb +2 -2
  60. data/definitions/segments/unt.rb +2 -2
  61. data/definitions/slsrpt/d01b.rb +132 -128
  62. data/definitions/slsrpt/d96a.rb +132 -129
  63. data/eancom.gemspec +5 -8
  64. data/lib/eancom/edifact/body.rb +37 -18
  65. data/lib/eancom/edifact/document.rb +20 -16
  66. data/lib/eancom/edifact/footer.rb +1 -0
  67. data/lib/eancom/edifact/item.rb +1 -1
  68. data/lib/eancom/edifact/message.rb +7 -39
  69. data/lib/eancom/edifact/segment.rb +9 -11
  70. data/lib/eancom/edifact/segments/ajt.rb +32 -0
  71. data/lib/eancom/edifact/segments/ali.rb +2 -4
  72. data/lib/eancom/edifact/segments/bgm.rb +4 -3
  73. data/lib/eancom/edifact/segments/cdi.rb +30 -0
  74. data/lib/eancom/edifact/segments/cnt.rb +8 -1
  75. data/lib/eancom/edifact/segments/cps.rb +4 -1
  76. data/lib/eancom/edifact/segments/cta.rb +30 -0
  77. data/lib/eancom/edifact/segments/cux.rb +1 -1
  78. data/lib/eancom/edifact/segments/dgs.rb +31 -0
  79. data/lib/eancom/edifact/segments/doc.rb +30 -0
  80. data/lib/eancom/edifact/segments/dtm.rb +10 -6
  81. data/lib/eancom/edifact/segments/efi.rb +38 -0
  82. data/lib/eancom/edifact/segments/eqd.rb +30 -0
  83. data/lib/eancom/edifact/segments/ftx.rb +2 -2
  84. data/lib/eancom/edifact/segments/gin.rb +45 -0
  85. data/lib/eancom/edifact/segments/imd.rb +1 -1
  86. data/lib/eancom/edifact/segments/inv.rb +43 -0
  87. data/lib/eancom/edifact/segments/lin.rb +7 -4
  88. data/lib/eancom/edifact/segments/loc.rb +8 -9
  89. data/lib/eancom/edifact/segments/mea.rb +1 -0
  90. data/lib/eancom/edifact/segments/moa.rb +3 -3
  91. data/lib/eancom/edifact/segments/nad.rb +11 -6
  92. data/lib/eancom/edifact/segments/pac.rb +3 -1
  93. data/lib/eancom/edifact/segments/pat.rb +37 -0
  94. data/lib/eancom/edifact/segments/pcd.rb +6 -17
  95. data/lib/eancom/edifact/segments/pci.rb +40 -0
  96. data/lib/eancom/edifact/segments/pia.rb +1 -0
  97. data/lib/eancom/edifact/segments/pri.rb +0 -1
  98. data/lib/eancom/edifact/segments/qty.rb +9 -5
  99. data/lib/eancom/edifact/segments/rff.rb +8 -2
  100. data/lib/eancom/edifact/segments/rte.rb +33 -0
  101. data/lib/eancom/edifact/segments/tax.rb +7 -1
  102. data/lib/eancom/edifact/segments/tdt.rb +4 -1
  103. data/lib/eancom/edifact/segments/tod.rb +33 -0
  104. data/lib/eancom/edifact/segments/tru.rb +31 -0
  105. data/lib/eancom/edifact/segments/una.rb +2 -1
  106. data/lib/eancom/edifact/segments/unb.rb +4 -5
  107. data/lib/eancom/edifact/segments/unh.rb +6 -4
  108. data/lib/eancom/edifact/segments/uns.rb +4 -1
  109. data/lib/eancom/edifact/structure.rb +0 -1
  110. data/lib/eancom/edifact.rb +15 -4
  111. data/lib/eancom/factory.rb +1 -1
  112. data/lib/eancom/parser/document.rb +3 -16
  113. data/lib/eancom/parser/segment.rb +9 -10
  114. data/lib/eancom/version.rb +1 -3
  115. data/lib/eancom.rb +3 -1
  116. data/pricat.json +1 -0
  117. metadata +45 -51
  118. data/.rubocop.yml +0 -2
  119. data/.tool-versions +0 -1
  120. data/definitions/segments/qvr.rb +0 -140
  121. data/lib/eancom/edifact/location.rb +0 -56
  122. data/lib/eancom/edifact/segments/qvr.rb +0 -50
@@ -2,7 +2,7 @@ module Eancom
2
2
  module Edifact
3
3
  class UNS < Segment
4
4
  TAG = 'UNS'.freeze
5
- TYPE = :body.freeze
5
+ TYPE = :header.freeze
6
6
 
7
7
  def initialize(
8
8
  tag: nil,
@@ -14,6 +14,9 @@ module Eancom
14
14
  super(tag: tag || TAG)
15
15
  end
16
16
 
17
+ '''
18
+ Why is line 22 commented?
19
+ '''
17
20
  def to_json_hash
18
21
  hash = {}
19
22
  # hash.merge!(section_identification: find_identifier(:section_identification)) if @section_identification
@@ -68,7 +68,6 @@ module Eancom
68
68
  return k
69
69
  end
70
70
  end
71
- value
72
71
  else
73
72
  value
74
73
  end
@@ -3,7 +3,6 @@ require 'eancom/edifact/segment'
3
3
  require 'eancom/edifact/document_element'
4
4
  require 'eancom/edifact/header'
5
5
  require 'eancom/edifact/message'
6
- require 'eancom/edifact/location'
7
6
  require 'eancom/edifact/item'
8
7
  require 'eancom/edifact/body'
9
8
  require 'eancom/edifact/footer'
@@ -22,6 +21,18 @@ require 'eancom/edifact/segments/unt'
22
21
  require 'eancom/edifact/segments/unz'
23
22
 
24
23
  require 'eancom/edifact/segments/alc'
24
+ require 'eancom/edifact/segments/ajt'
25
+ require 'eancom/edifact/segments/dgs'
26
+ require 'eancom/edifact/segments/efi'
27
+ require 'eancom/edifact/segments/tru'
28
+ require 'eancom/edifact/segments/cdi'
29
+ require 'eancom/edifact/segments/gin'
30
+ require 'eancom/edifact/segments/rte'
31
+ require 'eancom/edifact/segments/pcd'
32
+ require 'eancom/edifact/segments/eqd'
33
+ require 'eancom/edifact/segments/tod'
34
+ require 'eancom/edifact/segments/pat'
35
+ require 'eancom/edifact/segments/doc'
25
36
  require 'eancom/edifact/segments/ali'
26
37
  require 'eancom/edifact/segments/bgm'
27
38
  require 'eancom/edifact/segments/cav'
@@ -29,21 +40,22 @@ require 'eancom/edifact/segments/cci'
29
40
  require 'eancom/edifact/segments/cnt'
30
41
  require 'eancom/edifact/segments/cps'
31
42
  require 'eancom/edifact/segments/cux'
43
+ require 'eancom/edifact/segments/cta'
32
44
  require 'eancom/edifact/segments/dtm'
33
45
  require 'eancom/edifact/segments/ftx'
34
46
  require 'eancom/edifact/segments/imd'
47
+ require 'eancom/edifact/segments/inv'
35
48
  require 'eancom/edifact/segments/lin'
36
49
  require 'eancom/edifact/segments/loc'
37
50
  require 'eancom/edifact/segments/mea'
38
51
  require 'eancom/edifact/segments/moa'
39
52
  require 'eancom/edifact/segments/nad'
40
53
  require 'eancom/edifact/segments/pac'
54
+ require 'eancom/edifact/segments/pci'
41
55
  require 'eancom/edifact/segments/pgi'
42
- require 'eancom/edifact/segments/pcd'
43
56
  require 'eancom/edifact/segments/pia'
44
57
  require 'eancom/edifact/segments/pri'
45
58
  require 'eancom/edifact/segments/qty'
46
- require 'eancom/edifact/segments/qvr'
47
59
  require 'eancom/edifact/segments/rff'
48
60
  require 'eancom/edifact/segments/tax'
49
61
  require 'eancom/edifact/segments/tdt'
@@ -52,4 +64,3 @@ module Eancom
52
64
  module Edifact
53
65
  end
54
66
  end
55
-
@@ -36,4 +36,4 @@ module Eancom
36
36
  end
37
37
 
38
38
  end
39
- end
39
+ end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Eancom
4
2
  module Parser
5
3
  class Document
@@ -12,14 +10,9 @@ module Eancom
12
10
  @document = Eancom::Edifact::Document.new
13
11
  end
14
12
 
15
- def parse(header_only: false)
13
+ def parse
16
14
  content.split(segment_delimiter).each do |segment_string|
17
15
  segment = Parser::Segment.new(segment_string)
18
-
19
- if header_only && segment.segment_class::TYPE != :header
20
- next
21
- end
22
-
23
16
  segment = segment.parse
24
17
  add(segment)
25
18
  end
@@ -34,7 +27,7 @@ module Eancom
34
27
  elsif segment.is_body?
35
28
  @document.add_to_body(segment)
36
29
  elsif segment.is_footer?
37
- @document.add_to_footer(segment)
30
+ @document.add_to_body(segment)
38
31
  else
39
32
  raise SegmentTypeNotDefined
40
33
  end
@@ -60,13 +53,7 @@ module Eancom
60
53
  end
61
54
 
62
55
  def convert(string)
63
- string.encode(
64
- 'UTF-8',
65
- 'binary',
66
- invalid: :replace,
67
- undef: :replace,
68
- replace: ''
69
- )
56
+ string.encode('UTF-8')
70
57
  end
71
58
  end
72
59
  end
@@ -2,13 +2,11 @@ module Eancom
2
2
  module Parser
3
3
  class Segment
4
4
 
5
- attr_accessor :tag, :string, :components, :segment_class
5
+ attr_accessor :tag, :components, :string
6
6
 
7
7
  def initialize(string)
8
8
  @string = string
9
9
  @components = []
10
- @tag = una? ? 'UNA' : string.split(data_delimiter)[0]
11
- @segment_class = find_segment_class
12
10
  end
13
11
 
14
12
  def parse
@@ -21,13 +19,13 @@ module Eancom
21
19
  private
22
20
 
23
21
  def parse_component
24
- if una?
25
- parse_una
26
- else
22
+ if string =~ /^UNA/
23
+ parse_una
24
+ else
27
25
  string.split(data_delimiter).each do |data|
28
26
  components << parse_data(data)
29
27
  end
30
- end
28
+ end
31
29
  end
32
30
 
33
31
  def parse_data(data)
@@ -48,6 +46,10 @@ module Eancom
48
46
  components << [DELIMITERS[:segment]]
49
47
  end
50
48
 
49
+ def tag
50
+ components.first.first
51
+ end
52
+
51
53
  def find_segment_class
52
54
  Eancom.find_segment(tag: tag)
53
55
  end
@@ -64,9 +66,6 @@ module Eancom
64
66
  DELIMITERS[:component]
65
67
  end
66
68
 
67
- def una?
68
- string =~ /^UNA/
69
- end
70
69
  end
71
70
  end
72
71
  end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Eancom
4
- VERSION = '1.6.3'
2
+ VERSION = "2.0.0"
5
3
  end
data/lib/eancom.rb CHANGED
@@ -10,8 +10,10 @@ module Eancom
10
10
  pricat
11
11
  ordrsp
12
12
  slsrpt
13
- invrp
13
+ invrpt
14
14
  orders
15
+ invoic
16
+ retann
15
17
  ].freeze
16
18
 
17
19
  DELIMITERS = {
data/pricat.json ADDED
@@ -0,0 +1 @@
1
+ "#<File:0x00007ff38589ba40>"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eancom
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.3
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fadendaten GmbH
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-06 00:00:00.000000000 Z
11
+ date: 2021-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: pry-nav
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: pry-remote
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -53,35 +39,7 @@ dependencies:
53
39
  - !ruby/object:Gem::Version
54
40
  version: '0'
55
41
  - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop
42
+ name: pry-nav
85
43
  requirement: !ruby/object:Gem::Requirement
86
44
  requirements:
87
45
  - - ">="
@@ -133,9 +91,7 @@ files:
133
91
  - ".gitignore"
134
92
  - ".gitlab-ci.yml"
135
93
  - ".rspec"
136
- - ".rubocop.yml"
137
94
  - ".ruby-version"
138
- - ".tool-versions"
139
95
  - ".travis.yml"
140
96
  - Gemfile
141
97
  - Gemfile.lock
@@ -146,32 +102,57 @@ files:
146
102
  - bin/setup
147
103
  - definitions/desadv/d01b.rb
148
104
  - definitions/desadv/d96a.rb
105
+ - definitions/invoic/d01b.rb
106
+ - definitions/invoic/d96a.rb
107
+ - definitions/invrpt/d01b.rb
108
+ - definitions/invrpt/d96a.rb
109
+ - definitions/orders/d01b.rb
110
+ - definitions/orders/d96b.rb
111
+ - definitions/ordrsp/d01b.rb
112
+ - definitions/ordrsp/d96b.rb
113
+ - definitions/pricat/d01b.rb
114
+ - definitions/pricat/d96b.rb
115
+ - definitions/retann/d01b.rb
116
+ - definitions/retann/d96b.rb
117
+ - definitions/segments/ajt.rb
149
118
  - definitions/segments/alc.rb
150
119
  - definitions/segments/ali.rb
151
120
  - definitions/segments/bgm.rb
152
121
  - definitions/segments/cav.rb
153
122
  - definitions/segments/cci.rb
123
+ - definitions/segments/cdi.rb
154
124
  - definitions/segments/cnt.rb
155
125
  - definitions/segments/cps.rb
126
+ - definitions/segments/cta.rb
156
127
  - definitions/segments/cux.rb
128
+ - definitions/segments/dgs.rb
129
+ - definitions/segments/doc.rb
157
130
  - definitions/segments/dtm.rb
131
+ - definitions/segments/efi.rb
132
+ - definitions/segments/eqd.rb
158
133
  - definitions/segments/ftx.rb
134
+ - definitions/segments/gin.rb
159
135
  - definitions/segments/imd.rb
136
+ - definitions/segments/inv.rb
160
137
  - definitions/segments/lin.rb
161
138
  - definitions/segments/loc.rb
162
139
  - definitions/segments/mea.rb
163
140
  - definitions/segments/moa.rb
164
141
  - definitions/segments/nad.rb
165
142
  - definitions/segments/pac.rb
143
+ - definitions/segments/pat.rb
166
144
  - definitions/segments/pcd.rb
145
+ - definitions/segments/pci.rb
167
146
  - definitions/segments/pgi.rb
168
147
  - definitions/segments/pia.rb
169
148
  - definitions/segments/pri.rb
170
149
  - definitions/segments/qty.rb
171
- - definitions/segments/qvr.rb
172
150
  - definitions/segments/rff.rb
151
+ - definitions/segments/rte.rb
173
152
  - definitions/segments/tax.rb
174
153
  - definitions/segments/tdt.rb
154
+ - definitions/segments/tod.rb
155
+ - definitions/segments/tru.rb
175
156
  - definitions/segments/una.rb
176
157
  - definitions/segments/unb.rb
177
158
  - definitions/segments/unh.rb
@@ -192,35 +173,47 @@ files:
192
173
  - lib/eancom/edifact/footer.rb
193
174
  - lib/eancom/edifact/header.rb
194
175
  - lib/eancom/edifact/item.rb
195
- - lib/eancom/edifact/location.rb
196
176
  - lib/eancom/edifact/message.rb
197
177
  - lib/eancom/edifact/segment.rb
178
+ - lib/eancom/edifact/segments/ajt.rb
198
179
  - lib/eancom/edifact/segments/alc.rb
199
180
  - lib/eancom/edifact/segments/ali.rb
200
181
  - lib/eancom/edifact/segments/bgm.rb
201
182
  - lib/eancom/edifact/segments/cav.rb
202
183
  - lib/eancom/edifact/segments/cci.rb
184
+ - lib/eancom/edifact/segments/cdi.rb
203
185
  - lib/eancom/edifact/segments/cnt.rb
204
186
  - lib/eancom/edifact/segments/cps.rb
187
+ - lib/eancom/edifact/segments/cta.rb
205
188
  - lib/eancom/edifact/segments/cux.rb
189
+ - lib/eancom/edifact/segments/dgs.rb
190
+ - lib/eancom/edifact/segments/doc.rb
206
191
  - lib/eancom/edifact/segments/dtm.rb
192
+ - lib/eancom/edifact/segments/efi.rb
193
+ - lib/eancom/edifact/segments/eqd.rb
207
194
  - lib/eancom/edifact/segments/ftx.rb
195
+ - lib/eancom/edifact/segments/gin.rb
208
196
  - lib/eancom/edifact/segments/imd.rb
197
+ - lib/eancom/edifact/segments/inv.rb
209
198
  - lib/eancom/edifact/segments/lin.rb
210
199
  - lib/eancom/edifact/segments/loc.rb
211
200
  - lib/eancom/edifact/segments/mea.rb
212
201
  - lib/eancom/edifact/segments/moa.rb
213
202
  - lib/eancom/edifact/segments/nad.rb
214
203
  - lib/eancom/edifact/segments/pac.rb
204
+ - lib/eancom/edifact/segments/pat.rb
215
205
  - lib/eancom/edifact/segments/pcd.rb
206
+ - lib/eancom/edifact/segments/pci.rb
216
207
  - lib/eancom/edifact/segments/pgi.rb
217
208
  - lib/eancom/edifact/segments/pia.rb
218
209
  - lib/eancom/edifact/segments/pri.rb
219
210
  - lib/eancom/edifact/segments/qty.rb
220
- - lib/eancom/edifact/segments/qvr.rb
221
211
  - lib/eancom/edifact/segments/rff.rb
212
+ - lib/eancom/edifact/segments/rte.rb
222
213
  - lib/eancom/edifact/segments/tax.rb
223
214
  - lib/eancom/edifact/segments/tdt.rb
215
+ - lib/eancom/edifact/segments/tod.rb
216
+ - lib/eancom/edifact/segments/tru.rb
224
217
  - lib/eancom/edifact/segments/una.rb
225
218
  - lib/eancom/edifact/segments/unb.rb
226
219
  - lib/eancom/edifact/segments/unh.rb
@@ -233,6 +226,7 @@ files:
233
226
  - lib/eancom/parser/document.rb
234
227
  - lib/eancom/parser/segment.rb
235
228
  - lib/eancom/version.rb
229
+ - pricat.json
236
230
  homepage: https://fadendaten.ch
237
231
  licenses:
238
232
  - MIT
@@ -253,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
253
247
  - !ruby/object:Gem::Version
254
248
  version: '0'
255
249
  requirements: []
256
- rubygems_version: 3.2.22
250
+ rubygems_version: 3.2.3
257
251
  signing_key:
258
252
  specification_version: 4
259
253
  summary: EDIFACT Generator for the EANCOM Subset
data/.rubocop.yml DELETED
@@ -1,2 +0,0 @@
1
- inherit_from:
2
- - https://gitlab.com/fadendaten/infrastructure/styleguides/-/raw/main/ruby/.rubocop.yml
data/.tool-versions DELETED
@@ -1 +0,0 @@
1
- ruby 3.0.2
@@ -1,140 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- tag = 'QVR'
4
- Eancom.register_segment(tag: tag, klass: Eancom::Edifact::QVR)
5
-
6
- structure = Eancom::Edifact::Structure.new(tag: tag)
7
- #==============================================================================
8
- # Tag #
9
- #==============================================================================
10
- tag = Eancom::Edifact::Composite.new
11
- data = Eancom::Edifact::Data.new(
12
- type: String,
13
- length: 3,
14
- dictionary: nil,
15
- description: "Message Header",
16
- required: true
17
- )
18
- tag.add(:tag, data)
19
-
20
- structure << tag
21
- #==============================================================================
22
- # Quantity difference information
23
- #==============================================================================
24
- quantity_difference_information = Eancom::Edifact::Composite.new
25
-
26
- data = Eancom::Edifact::Data.new(
27
- type: Integer,
28
- length: 1..15,
29
- dictionary: nil,
30
- description: "Specify the actual variance amount here.",
31
- required: true
32
- )
33
- quantity_difference_information.add(:quantity_variance_value, data)
34
-
35
- data = Eancom::Edifact::Data.new(
36
- type: String,
37
- length: 1..3,
38
- dictionary: {
39
- '21' => {
40
- description: 'Ordered quantity',
41
- identifier: 'ordered_quantity'
42
- },
43
- '66' => {
44
- description: 'Committed quantity',
45
- identifier: 'committed_quantity'
46
- }
47
- },
48
- description: "Quantity type code qualifier",
49
- required: true
50
- )
51
- quantity_difference_information.add(:quantity_type_code_qualifier, data)
52
-
53
- structure << quantity_difference_information
54
- #==============================================================================
55
- # Discrepancy nature identification code
56
- #==============================================================================
57
- discrepancy_nature_identification_code = Eancom::Edifact::Composite.new
58
-
59
- data = Eancom::Edifact::Data.new(
60
- type: String,
61
- length: 0..3,
62
- dictionary: {
63
- 'BP' => {
64
- description: 'Shipment partial - back order to follow',
65
- identifier: 'shipment_partial_back_order_to_follow',
66
- },
67
- 'CP' => {
68
- description: 'Shipment partial - considered complete, no backorder',
69
- identifier: 'shipment_partial_considered_complete_no_backorder',
70
- },
71
- },
72
- description: "",
73
- required: true
74
- )
75
- discrepancy_nature_identification_code.add(:discrepancy_nature_identification_code, data)
76
-
77
- structure << discrepancy_nature_identification_code
78
- #==============================================================================
79
- # Reason for change
80
- #==============================================================================
81
- reason_for_change = Eancom::Edifact::Composite.new
82
-
83
- data = Eancom::Edifact::Data.new(
84
- type: String,
85
- length: 1..3,
86
- dictionary: {
87
- 'WR' => {
88
- description: 'Temporarily unavailable',
89
- identifier: 'temporarily_unavailable',
90
- },
91
- },
92
- description: "Change reason description code",
93
- required: false
94
- )
95
- reason_for_change.add(:change_reason_description_code, data)
96
-
97
- data = Eancom::Edifact::Data.new(
98
- type: String,
99
- length: 0..17,
100
- dictionary: nil,
101
- description: 'Code list identification code',
102
- required: false
103
- )
104
- reason_for_change.add(:code_list_idenfitifaction_code, data)
105
-
106
- data = Eancom::Edifact::Data.new(
107
- type: String,
108
- length: 0..3,
109
- dictionary: {
110
- '9' => {
111
- description: 'GS1',
112
- identifier: 'gsi',
113
- },
114
- '91' => {
115
- description: 'Assigned by supplier or suppliers agent',
116
- identifier: 'assigned_by_supplier_or_suppliers_agent'
117
- },
118
- '92' => {
119
- description: 'Assigned by buyer or buyers agent',
120
- identifier: 'assigned_by_buyer_or_buyers_agent'
121
- }
122
- },
123
- description: 'Code list responsible agancy code',
124
- required: false
125
- )
126
- reason_for_change.add(:code_list_responsibility_agency_code, data)
127
-
128
- data = Eancom::Edifact::Data.new(
129
- type: String,
130
- length: 1..35,
131
- dictionary: nil,
132
- description: "Change reason description",
133
- required: false
134
- )
135
- reason_for_change.add(:change_reason_description, data)
136
-
137
- structure << reason_for_change
138
-
139
- #==============================================================================
140
- Eancom.register_structure(tag: 'QVR', structure: structure)
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Eancom
4
- module Edifact
5
- class Location
6
- attr_accessor :items, :hash
7
-
8
- def initialize
9
- @items = []
10
- @hash = {}
11
- end
12
-
13
- def add_item(item)
14
- @items << item
15
- end
16
-
17
- def <<(segment)
18
- start_item if segment.starts_item?
19
-
20
- if @item
21
- @item << segment
22
- elsif name = group_name(segment)
23
- @hash[name] = [] if @hash[name].nil?
24
- @hash[name] << segment.to_json_hash
25
- else
26
- @hash.merge!(segment.to_json_hash)
27
- end
28
- end
29
-
30
- def to_json_hash
31
- if @item && !@item.empty?
32
- add_item(@item.to_json_hash)
33
- end
34
-
35
- @hash.merge({ items: @items })
36
- end
37
-
38
- def empty?
39
- @hash.empty?
40
- end
41
-
42
- def start_item
43
- if @item && !@item.empty?
44
- add_item(@item.to_json_hash)
45
- end
46
- @item = Eancom::Edifact::Item.new
47
- end
48
-
49
- private
50
-
51
- def group_name(segment)
52
- segment.item_group_name || segment.group_name
53
- end
54
- end
55
- end
56
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Eancom
4
- module Edifact
5
- class QVR < Segment
6
- TAG = 'QVR'
7
- TYPE = :body
8
-
9
- def initialize(
10
- tag: nil,
11
- quantity_variance_value:,
12
- quantity_type_code_qualifier:,
13
- discrepancy_nature_identification_code: nil,
14
- change_reason_description_code: nil,
15
- code_list_identification_code: nil,
16
- code_list_responsible_agency_code: nil,
17
- change_reason_description: nil
18
- )
19
- @tag = tag
20
-
21
- @quantity_variance_value = quantity_variance_value
22
- @quantity_type_code_qualifier = quantity_type_code_qualifier
23
- @discrepancy_nature_identification_code = discrepancy_nature_identification_code
24
- @change_reason_description_code = change_reason_description_code
25
- @code_list_identification_code = code_list_identification_code
26
- @code_list_responsible_agency_code = code_list_responsible_agency_code
27
- @change_reason_description = change_reason_description
28
-
29
- super(tag: tag || TAG)
30
- end
31
-
32
- def to_json_hash
33
- hash = {}
34
- hash.merge!(quantity_variance_value: quantity_variance_value)
35
- hash.merge!(quantity_type_code_qualifier: find_identifier(:quantity_type_code_qualifier))
36
- hash.merge!(discrepancy_nature_identification_code: find_identifier(:discrepancy_nature_identification_code)) if @discrepancy_nature_identification_code
37
- hash.merge!(change_reason_description: @change_reason_description) if @change_reason_description
38
- hash
39
- end
40
-
41
- def group_name
42
- 'quantity_variances'
43
- end
44
-
45
- def segment_type
46
- TYPE
47
- end
48
- end
49
- end
50
- end