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
data/eancom.gemspec CHANGED
@@ -23,12 +23,9 @@ Gem::Specification.new do |spec|
23
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
24
  spec.require_paths = ["lib"]
25
25
 
26
- spec.add_development_dependency 'pry'
27
- spec.add_development_dependency 'pry-nav'
28
- spec.add_development_dependency 'pry-remote'
29
- spec.add_development_dependency 'rake'
30
- spec.add_development_dependency 'rspec'
31
- spec.add_development_dependency 'rubocop'
32
- spec.add_development_dependency 'simplecov'
33
- spec.add_development_dependency 'timecop'
26
+ spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "pry-remote"
28
+ spec.add_development_dependency "pry-nav"
29
+ spec.add_development_dependency "simplecov"
30
+ spec.add_development_dependency "timecop"
34
31
  end
@@ -1,9 +1,8 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Eancom
4
2
  module Edifact
5
3
  class Body < DocumentElement
6
- attr_accessor :hash, :messages, :locations, :items
4
+
5
+ attr_accessor :hash, :items, :messages
7
6
 
8
7
  def initialize
9
8
  super
@@ -12,32 +11,52 @@ module Eancom
12
11
  end
13
12
 
14
13
  def to_json_hash
15
- @to_json_hash ||= build_json_hash
14
+ @segments.each do |segment|
15
+ start_message(segment) if segment.starts_message?
16
+ start_item(segment) if segment.starts_item?
17
+ if @item
18
+ @item << segment
19
+ else
20
+ @message << segment
21
+ end
22
+ end
23
+ @message.add_item(@item.to_json_hash)
24
+ @messages << @message.to_json_hash
25
+ hash.merge!({ messages: messages })
26
+ { body: hash }
16
27
  end
17
28
 
18
- def start_message
29
+ def start_message(segment)
19
30
  if @message
20
31
  @messages << @message.to_json_hash
32
+ if @item && !@item.empty?
33
+ @message.add_item(@item.to_json_hash)
34
+ end
35
+ @item = nil
21
36
  end
22
- @message = Eancom::Edifact::Message.new
37
+ @message = Eancom::Edifact::Message.new()
23
38
  end
24
39
 
25
- private
26
-
27
- def group_name(segment)
28
- segment.group_name
40
+ def start_item(segment)
41
+ if @item && !@item.empty?
42
+ @message.add_item(@item.to_json_hash)
43
+ end
44
+ @item = Eancom::Edifact::Item.new()
29
45
  end
30
46
 
31
- def build_json_hash
32
- @segments.each do |segment|
33
- start_message if segment.starts_message?
34
- @message << segment
47
+ private
48
+
49
+ def merge(hash, segment)
50
+ if name = group_name(segment)
51
+ hash[name] = [] if hash[name].nil?
52
+ hash[name] << segment.to_json_hash
53
+ else
54
+ hash.merge!(segment.to_json_hash)
35
55
  end
36
- messages << @message.to_json_hash if @message
56
+ end
37
57
 
38
- {
39
- body: hash.merge({ messages: messages })
40
- }
58
+ def group_name(segment)
59
+ return segment.group_name
41
60
  end
42
61
  end
43
62
  end
@@ -1,25 +1,24 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Eancom
4
2
  module Edifact
5
3
  class Document
4
+
6
5
  attr_accessor :header_element, :body_element, :footer_element
7
6
 
8
7
  def initialize
9
- @header_element = Header.new
10
- @body_element = Body.new
11
- @footer_element = Footer.new
8
+ @header_element = Header.new()
9
+ @body_element = Body.new()
10
+ @footer_element = Footer.new()
12
11
  end
13
12
 
14
- def header
13
+ def header(&block)
15
14
  yield(@header_element)
16
15
  end
17
16
 
18
- def body
17
+ def body(&block)
19
18
  yield(@body_element)
20
19
  end
21
20
 
22
- def footer
21
+ def footer(&block)
23
22
  yield(@footer_element)
24
23
  end
25
24
 
@@ -35,6 +34,7 @@ module Eancom
35
34
  @footer_element.segment(segment)
36
35
  end
37
36
 
37
+ # Should header and footer segments be added to total_segments?
38
38
  def total_segments
39
39
  total = 0
40
40
  total += @body_element.segments.count
@@ -42,14 +42,18 @@ module Eancom
42
42
  end
43
43
 
44
44
  def to_s(debug: false)
45
- "#{@header_element.to_s(debug: debug)}#{@body_element.to_s(debug: debug)}#{@footer_element.to_s(debug: debug)}"
46
- end
47
-
48
- def to_json(_obj = nil)
49
- {
50
- **@header_element.to_json_hash,
51
- **@body_element.to_json_hash
52
- }.to_json
45
+ stream = ''
46
+ stream << @header_element.to_s(debug: debug)
47
+ stream << @body_element.to_s(debug: debug)
48
+ stream << @footer_element.to_s(debug: debug)
49
+ stream
50
+ end
51
+
52
+ def to_json
53
+ hash = {}
54
+ hash.merge! @header_element.to_json_hash
55
+ hash.merge! @body_element.to_json_hash
56
+ hash.to_json
53
57
  end
54
58
  end
55
59
  end
@@ -1,6 +1,7 @@
1
1
  module Eancom
2
2
  module Edifact
3
3
  class Footer < DocumentElement
4
+ # Why is this module empty?
4
5
  end
5
6
  end
6
7
  end
@@ -4,7 +4,7 @@ module Eancom
4
4
 
5
5
  attr_accessor :hash
6
6
 
7
- def initialize
7
+ def initialize()
8
8
  @hash = {}
9
9
  end
10
10
 
@@ -1,33 +1,20 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Eancom
4
2
  module Edifact
5
3
  class Message
6
- attr_accessor :locations, :items, :hash
7
4
 
8
- def initialize
9
- @locations = []
5
+ attr_accessor :items, :hash
6
+
7
+ def initialize()
10
8
  @items = []
11
9
  @hash = {}
12
10
  end
13
11
 
14
- def add_location(location)
15
- @locations << location
16
- end
17
-
18
12
  def add_item(item)
19
13
  @items << item
20
14
  end
21
15
 
22
- def <<(segment)
23
- start_location if segment.starts_location?
24
- start_item if segment.starts_item?
25
-
26
- if @location
27
- @location << segment
28
- elsif @item
29
- @item << segment
30
- elsif name = group_name(segment)
16
+ def << (segment)
17
+ if name = group_name(segment)
31
18
  @hash[name] = [] if @hash[name].nil?
32
19
  @hash[name] << segment.to_json_hash
33
20
  else
@@ -36,16 +23,10 @@ module Eancom
36
23
  end
37
24
 
38
25
  def to_json_hash
39
- if @location && !@location.empty?
40
- add_location(@location.to_json_hash)
41
- end
42
- if @item && !@item.empty?
43
- add_item(@item.to_json_hash)
44
- end
45
26
  message_hash = {}
27
+ items_hash = { items: @items }
46
28
  message_hash.merge!(@hash)
47
- message_hash.merge!({ locations: @locations }) if !@locations.empty?
48
- message_hash.merge!({ items: @items }) if !@items.empty?
29
+ message_hash.merge!(items_hash)
49
30
  message_hash
50
31
  end
51
32
 
@@ -55,19 +36,6 @@ module Eancom
55
36
  segment.group_name
56
37
  end
57
38
 
58
- def start_location
59
- if @location && !@location.empty?
60
- add_location(@location.to_json_hash)
61
- end
62
- @location = Eancom::Edifact::Location.new
63
- end
64
-
65
- def start_item
66
- if @item && !@item.empty?
67
- add_item(@item.to_json_hash)
68
- end
69
- @item = Eancom::Edifact::Item.new
70
- end
71
39
  end
72
40
  end
73
41
  end
@@ -11,18 +11,21 @@ module Eancom
11
11
  end
12
12
 
13
13
  def self.initialize_by_components(structure, array)
14
- new(**structure.build_hash(array))
15
- rescue StandardError => e
16
- raise SegmentParserError, "'Parser Error in structure #{structure.tag} with array #{array}.\n \
17
- 'Inside Structure: \n \ '#{structure}.\n \
14
+ begin
15
+ new(**structure.build_hash(array))
16
+ rescue StandardError => e
17
+ raise SegmentParserError.new(
18
+ "'Parser Error in structure #{structure.tag} with array #{array}.\n \
19
+ 'Inside Structure: \n \ '#{structure.to_s}.\n \
18
20
  'Error:\n \
19
21
  '#{e}"
22
+ )
23
+ end
20
24
  end
21
25
 
22
26
  def validate_structure
23
27
  attributes.each do |key, value|
24
28
  next if value.nil?
25
-
26
29
  structure.validate!(key, value)
27
30
  end
28
31
  end
@@ -36,10 +39,9 @@ module Eancom
36
39
  end
37
40
 
38
41
  def to_s
39
- string = array.map do |e|
42
+ string = array.map do |e|
40
43
  e = e.compact
41
44
  next if e.empty?
42
-
43
45
  [e.join(component_delimiter)]
44
46
  end.join(data_delimiter)
45
47
  clean_end_string(string)
@@ -83,10 +85,6 @@ module Eancom
83
85
  false
84
86
  end
85
87
 
86
- def starts_location?
87
- false
88
- end
89
-
90
88
  def starts_item?
91
89
  false
92
90
  end
@@ -0,0 +1,32 @@
1
+ module Eancom
2
+ module Edifact
3
+ class AJT < Segment
4
+ TAG = 'AJT'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ adjustment_reason_description:
12
+ )
13
+ @tag = tag
14
+ @adjustment_reason_description = adjustment_reason_description
15
+
16
+ super(tag: tag || TAG)
17
+ end
18
+
19
+ def to_json_hash
20
+ hash = {}
21
+ if @adjustment_reason_description
22
+ hash.merge!(adjustment_reason_description: find_identifier(:adjustment_reason_description))
23
+ end
24
+ hash
25
+ end
26
+
27
+ def segment_type
28
+ TYPE
29
+ end
30
+ end
31
+ end
32
+ end
@@ -2,7 +2,7 @@ module Eancom
2
2
  module Edifact
3
3
  class ALI < Segment
4
4
  TAG = 'ALI'.freeze
5
- TYPE = :body.freeze
5
+ TYPE = :body
6
6
 
7
7
  attr_reader :segment_type
8
8
 
@@ -38,15 +38,13 @@ module Eancom
38
38
  hash.merge!(special_condition_code_4: find_identifier(:special_condition_code_4)) if @special_condition_code_4
39
39
  hash.merge!(special_condition_code_5: find_identifier(:special_condition_code_5)) if @special_condition_code_5
40
40
  outer_hash = {}
41
- outer_hash.merge!(additional_information: hash )
41
+ outer_hash.merge!(additional_information: hash)
42
42
  outer_hash
43
43
  end
44
44
 
45
45
  def segment_type
46
46
  TYPE
47
47
  end
48
-
49
-
50
48
  end
51
49
  end
52
50
  end
@@ -8,7 +8,7 @@ module Eancom
8
8
 
9
9
  def initialize(
10
10
  tag: nil,
11
- document_name_code: nil,
11
+ document_name_code:,
12
12
  code_list_responsible_agency_code: nil,
13
13
  code_list_identification_code: nil,
14
14
  document_name: nil,
@@ -28,7 +28,9 @@ module Eancom
28
28
 
29
29
  def to_json_hash
30
30
  {
31
- document_identifier: @document_identifier
31
+ document_name_code: @document_name_code,
32
+ document_identifier: @document_identifier,
33
+ message_function_code: @message_function_code
32
34
  }
33
35
  end
34
36
 
@@ -39,7 +41,6 @@ module Eancom
39
41
  def segment_type
40
42
  TYPE
41
43
  end
42
-
43
44
  end
44
45
  end
45
46
  end
@@ -0,0 +1,30 @@
1
+ module Eancom
2
+ module Edifact
3
+ class CDI < Segment
4
+ TAG = 'CDI'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ physical_or_logical_state_type_code_qualifier: nil
12
+ )
13
+
14
+ @tag = tag
15
+ @physical_or_logical_state_type_code_qualifier = physical_or_logical_state_type_code_qualifier
16
+ super(tag: @tag || TAG)
17
+ end
18
+
19
+ def to_json_hash
20
+ hash = {}
21
+ hash.merge!(physical_or_logical_state_type_code_qualifier: find_identifier(:physical_or_logical_state_type_code_qualifier)) if @physical_or_logical_state_type_code_qualifier
22
+ hash
23
+ end
24
+
25
+ def segment_type
26
+ TYPE
27
+ end
28
+ end
29
+ end
30
+ end
@@ -21,7 +21,14 @@ module Eancom
21
21
  end
22
22
 
23
23
  def to_json_hash
24
- {}
24
+ hash = {}
25
+ hash.merge!(control_total_type_code_quantifier: find_identifier(:control_total_type_code_quantifier)) if @control_total_type_code_quantifier
26
+ hash.merge!(control_total_value: @control_total_value) if @control_total_value
27
+ hash
28
+ end
29
+
30
+ def group_name
31
+ 'counts'
25
32
  end
26
33
 
27
34
  def segment_type
@@ -19,7 +19,10 @@ module Eancom
19
19
  end
20
20
 
21
21
  def to_json_hash
22
- {}
22
+ hash = {}
23
+ hash.merge!(hierarchical_structure_level_identifier: @hierarchical_structure_level_identifier) if @hierarchical_structure_level_identifier
24
+ hash.merge!(hierarchical_structure_parent_identifier: @hierarchical_structure_parent_identifier) if @hierarchical_structure_parent_identifier
25
+ hash
23
26
  end
24
27
 
25
28
  def segment_type
@@ -0,0 +1,30 @@
1
+ module Eancom
2
+ module Edifact
3
+ class CTA < Segment
4
+ TAG = 'CTA'.freeze
5
+ TYPE = :body
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ contact_function_code:
12
+ )
13
+
14
+ @tag = tag
15
+ @contact_function_code = contact_function_code
16
+ super(tag: tag || TAG)
17
+ end
18
+
19
+ def to_json_hash
20
+ hash = {}
21
+ hash.merge!(contact_function_code: find_identifier(:contact_function_code)) if @contact_function_code
22
+ hash
23
+ end
24
+
25
+ def segment_type
26
+ TYPE
27
+ end
28
+ end
29
+ end
30
+ end
@@ -10,7 +10,7 @@ module Eancom
10
10
  tag: nil,
11
11
  currency_usage_code_qualifier_1:,
12
12
  currency_identification_code_1:,
13
- currency_type_code_qualifier_1:,
13
+ currency_type_code_qualifier_1: nil,
14
14
  currency_rate_value_1: nil,
15
15
  currency_usage_code_qualifier_2: nil,
16
16
  currency_identification_code_2: nil,
@@ -0,0 +1,31 @@
1
+ module Eancom
2
+ module Edifact
3
+ class DGS < Segment
4
+ TAG = 'DGS'.freeze
5
+ TYPE = :body
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ hazard_identification_code:
12
+ )
13
+
14
+ @tag = tag
15
+ @hazard_identification_code = hazard_identification_code
16
+
17
+ super(tag: tag || TAG)
18
+ end
19
+
20
+ def to_json_hash
21
+ hash = {}
22
+ hash.merge!(hazard_identification_code: @hazard_identification_code)
23
+ hash
24
+ end
25
+
26
+ def segment_type
27
+ TYPE
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,30 @@
1
+ module Eancom
2
+ module Edifact
3
+ class DOC < Segment
4
+ TAG = 'DOC'.freeze
5
+ TYPE = :header
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ document_name_code:
12
+ )
13
+ @tag = tag
14
+ @document_name_code = document_name_code
15
+
16
+ super(tag: tag || TAG)
17
+ end
18
+
19
+ def to_json_hash
20
+ {
21
+ document_name_code: @document_name_code
22
+ }
23
+ end
24
+
25
+ def segment_type
26
+ TYPE
27
+ end
28
+ end
29
+ end
30
+ end
@@ -21,11 +21,16 @@ module Eancom
21
21
  end
22
22
 
23
23
  def to_json_hash
24
- {
25
- identifier => {
26
- date_time: @date_time
27
- }
28
- }
24
+ hash = { identifier => {} }
25
+ hash[identifier].merge!({ date_time: @date_time }) if @date_time
26
+
27
+ hash.merge!({ identifier: @identifier }) if @identifier
28
+ hash = {} if hash[identifier].empty?
29
+ hash
30
+ end
31
+
32
+ def group_name
33
+ 'date_time_messages'
29
34
  end
30
35
 
31
36
  def segment_type
@@ -40,4 +45,3 @@ module Eancom
40
45
  end
41
46
  end
42
47
  end
43
-
@@ -0,0 +1,38 @@
1
+ module Eancom
2
+ module Edifact
3
+ class EFI < Segment
4
+ TAG = 'EFI'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ file_name: nil,
12
+ file_format_name:,
13
+ data_format_description_code:
14
+ )
15
+
16
+ @tag = tag
17
+ @file_name = file_name
18
+ @file_format_name = file_format_name
19
+ @data_format_description_code = data_format_description_code
20
+
21
+ super(tag: tag || TAG)
22
+ end
23
+
24
+
25
+ def to_json_hash
26
+ hash = {}
27
+ hash.merge!(file_name: file_name) if @file_name
28
+ hash.merge!(file_format_name: file_format_name) if @file_format_name
29
+ hash.merge!(data_format_description_code: find_identifier(:data_format_description_code)) if @data_format_description_code
30
+ hash
31
+ end
32
+
33
+ def segment_type
34
+ TYPE
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,30 @@
1
+ module Eancom
2
+ module Edifact
3
+ class EQD < Segment
4
+ TAG = 'EQD'.freeze
5
+ TYPE = :header
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ equipment_code_qualifier: nil
12
+ )
13
+
14
+ @tag = tag
15
+ @equipment_code_qualifier = equipment_code_qualifier
16
+
17
+ super(tag: tag || TAG)
18
+ end
19
+
20
+ def to_json_hash
21
+ hash = {}
22
+ hash.merge!(equipment_code_qualifier: find_identifier(:equipment_code_qualifier)) if @equipment_code_qualifier
23
+ end
24
+
25
+ def segment_type
26
+ TYPE
27
+ end
28
+ end
29
+ end
30
+ end
@@ -38,14 +38,14 @@ module Eancom
38
38
  hash = {}
39
39
  hash.merge!(text_subject_code_qualifier: @text_subject_code_qualifier) if @text_subject_code_qualifier
40
40
  hash.merge!(free_text_function_code: find_identifier(:free_text_function_code)) if @free_text_function_code
41
- hash.merge!(free_text_value_code: @free_text_value_code) if @free_text_value_code
41
+ hash.merge!(free_text_value_code: find_identifier(:free_text_value_code)) if @free_text_value_code
42
42
  hash.merge!(code_list_identification_code: @code_list_identification_code) if @code_list_identification_code
43
43
  hash.merge!(code_list_responsible_agency_code: find_identifier(:code_list_responsible_agency_code)) if @code_list_responsible_agency_code
44
44
  hash.merge!(free_text_value_1: @free_text_value_1) if @free_text_value_1
45
45
  hash.merge!(free_text_value_2: @free_text_value_2) if @free_text_value_2
46
46
  hash.merge!(free_text_value_3: @free_text_value_3) if @free_text_value_3
47
47
  hash.merge!(free_text_value_4: @free_text_value_4) if @free_text_value_4
48
- hash.merge!(free_text_value_5: @free_text_value_5) if @free_text_value_4
48
+ hash.merge!(free_text_value_5: @free_text_value_5) if @free_text_value_5
49
49
  hash
50
50
  end
51
51