eancom 0.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.gitignore +187 -6
  4. data/.gitlab-ci.yml +27 -0
  5. data/.rspec_status +225 -0
  6. data/.rubocop.yml +2 -0
  7. data/.ruby-version +1 -0
  8. data/Gemfile +4 -2
  9. data/Gemfile.lock +87 -3
  10. data/bin/console +3 -2
  11. data/definitions/desadv/d01b.rb +205 -0
  12. data/definitions/desadv/d96a.rb +108 -73
  13. data/definitions/segments/alc.rb +236 -0
  14. data/definitions/segments/ali.rb +93 -0
  15. data/definitions/segments/bgm.rb +267 -0
  16. data/definitions/segments/cav.rb +122 -0
  17. data/definitions/segments/cci.rb +136 -0
  18. data/definitions/segments/cnt.rb +78 -0
  19. data/definitions/segments/cps.rb +76 -0
  20. data/definitions/segments/cux.rb +167 -0
  21. data/definitions/segments/dtm.rb +159 -0
  22. data/definitions/segments/ftx.rb +143 -0
  23. data/definitions/segments/imd.rb +356 -0
  24. data/definitions/segments/lin.rb +113 -0
  25. data/definitions/segments/loc.rb +89 -0
  26. data/definitions/segments/mea.rb +189 -0
  27. data/definitions/segments/moa.rb +144 -0
  28. data/definitions/segments/nad.rb +254 -0
  29. data/definitions/segments/pac.rb +250 -0
  30. data/definitions/segments/pgi.rb +148 -0
  31. data/definitions/segments/pia.rb +501 -0
  32. data/definitions/segments/pri.rb +188 -0
  33. data/definitions/segments/qty.rb +79 -0
  34. data/definitions/segments/rff.rb +166 -0
  35. data/definitions/segments/tax.rb +259 -0
  36. data/definitions/segments/tdt.rb +254 -0
  37. data/definitions/segments/una.rb +85 -0
  38. data/definitions/segments/unb.rb +284 -0
  39. data/definitions/segments/unh.rb +118 -0
  40. data/definitions/segments/uns.rb +40 -0
  41. data/definitions/segments/unt.rb +48 -0
  42. data/definitions/segments/unz.rb +48 -0
  43. data/definitions/slsrpt/d01b.rb +201 -0
  44. data/definitions/slsrpt/d96a.rb +194 -0
  45. data/eancom.gemspec +9 -5
  46. data/lib/eancom/definition.rb +1 -1
  47. data/lib/eancom/edifact/body.rb +63 -0
  48. data/lib/eancom/edifact/composite.rb +38 -0
  49. data/lib/eancom/edifact/data.rb +108 -0
  50. data/lib/eancom/edifact/document.rb +43 -11
  51. data/lib/eancom/edifact/document_element.rb +26 -0
  52. data/lib/eancom/edifact/footer.rb +6 -0
  53. data/lib/eancom/edifact/header.rb +15 -0
  54. data/lib/eancom/edifact/item.rb +40 -0
  55. data/lib/eancom/edifact/message.rb +24 -16
  56. data/lib/eancom/edifact/segment.rb +131 -12
  57. data/lib/eancom/edifact/segments/alc.rb +61 -0
  58. data/lib/eancom/edifact/segments/ali.rb +52 -0
  59. data/lib/eancom/edifact/segments/bgm.rb +45 -0
  60. data/lib/eancom/edifact/segments/cav.rb +47 -0
  61. data/lib/eancom/edifact/segments/cci.rb +53 -0
  62. data/lib/eancom/edifact/segments/cnt.rb +33 -0
  63. data/lib/eancom/edifact/segments/cps.rb +30 -0
  64. data/lib/eancom/edifact/segments/cux.rb +60 -0
  65. data/lib/eancom/edifact/segments/dtm.rb +43 -0
  66. data/lib/eancom/edifact/segments/ftx.rb +63 -0
  67. data/lib/eancom/edifact/segments/imd.rb +69 -0
  68. data/lib/eancom/edifact/segments/lin.rb +43 -0
  69. data/lib/eancom/edifact/segments/loc.rb +43 -0
  70. data/lib/eancom/edifact/segments/mea.rb +53 -0
  71. data/lib/eancom/edifact/segments/moa.rb +45 -0
  72. data/lib/eancom/edifact/segments/nad.rb +107 -0
  73. data/lib/eancom/edifact/segments/pac.rb +54 -0
  74. data/lib/eancom/edifact/segments/pgi.rb +45 -0
  75. data/lib/eancom/edifact/segments/pia.rb +107 -0
  76. data/lib/eancom/edifact/segments/pri.rb +54 -0
  77. data/lib/eancom/edifact/segments/qty.rb +40 -0
  78. data/lib/eancom/edifact/segments/rff.rb +41 -0
  79. data/lib/eancom/edifact/segments/tax.rb +72 -0
  80. data/lib/eancom/edifact/segments/tdt.rb +54 -0
  81. data/lib/eancom/edifact/segments/una.rb +51 -0
  82. data/lib/eancom/edifact/segments/unb.rb +69 -0
  83. data/lib/eancom/edifact/segments/unh.rb +46 -0
  84. data/lib/eancom/edifact/segments/uns.rb +29 -0
  85. data/lib/eancom/edifact/segments/unt.rb +28 -0
  86. data/lib/eancom/edifact/segments/unz.rb +28 -0
  87. data/lib/eancom/edifact/structure.rb +91 -0
  88. data/lib/eancom/edifact.rb +45 -12
  89. data/lib/eancom/factory.rb +8 -7
  90. data/lib/eancom/parser/document.rb +68 -0
  91. data/lib/eancom/parser/segment.rb +71 -0
  92. data/lib/eancom/parser.rb +7 -0
  93. data/lib/eancom/version.rb +1 -1
  94. data/lib/eancom.rb +59 -16
  95. metadata +138 -5
  96. data/lib/eancom/edifact/element.rb +0 -16
  97. data/lib/eancom/edifact/envelope.rb +0 -24
@@ -0,0 +1,63 @@
1
+ module Eancom
2
+ module Edifact
3
+ class Body < DocumentElement
4
+
5
+ attr_accessor :hash, :items, :messages
6
+
7
+ def initialize
8
+ super
9
+ @hash = {}
10
+ @messages = []
11
+ end
12
+
13
+ def to_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 }
27
+ end
28
+
29
+ def start_message(segment)
30
+ if @message
31
+ @messages << @message.to_json_hash
32
+ if @item && !@item.empty?
33
+ @message.add_item(@item.to_json_hash)
34
+ end
35
+ @item = nil
36
+ end
37
+ @message = Eancom::Edifact::Message.new()
38
+ end
39
+
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()
45
+ end
46
+
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)
55
+ end
56
+ end
57
+
58
+ def group_name(segment)
59
+ return segment.group_name
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,38 @@
1
+ module Eancom
2
+ module Edifact
3
+ class Composite
4
+ class DataTypeError < StandardError; end
5
+
6
+ attr_reader :data
7
+
8
+ def initialize
9
+ @data = {}
10
+ end
11
+
12
+ def add(key, value)
13
+ if value.kind_of?(Data)
14
+ @data[key] = value
15
+ else
16
+ raise DataTypeError.new('Added value is not of type Data.')
17
+ end
18
+ end
19
+
20
+ def get(key)
21
+ @data[key]
22
+ end
23
+
24
+ def delete(key)
25
+ @data.delete(key)
26
+ end
27
+
28
+ def to_array
29
+ array = []
30
+ @data.each do |key, value|
31
+ array << key
32
+ end
33
+ array
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,108 @@
1
+ module Eancom
2
+ module Edifact
3
+ class Data
4
+ class TypeError < StandardError; end
5
+ class LengthError < StandardError; end
6
+ class RequiredError < StandardError; end
7
+ class NotFoundInDictionary < StandardError; end
8
+
9
+ attr_accessor :type, :length, :dictionary, :description, :required
10
+
11
+ def initialize(type:,
12
+ length:,
13
+ dictionary: nil,
14
+ description:,
15
+ required:
16
+ )
17
+ @type = type
18
+ @length = length
19
+ @dictionary = dictionary
20
+ @description = description
21
+ @required = required
22
+ end
23
+
24
+ def valid?(key, value)
25
+ type?(key, value)
26
+ length?(key, value)
27
+ required?(key, value)
28
+ dictionary?(key, value) unless value.empty?
29
+ end
30
+
31
+
32
+ def identifier(value)
33
+ if @dictionary
34
+ hash = @dictionary[value]
35
+ unless hash
36
+ raise NotFoundInDictionary.new(
37
+ "Value not found for #{value}. Error in Data: #{self.to_s}"
38
+ )
39
+ else
40
+ hash[:identifier]
41
+ end
42
+ else
43
+ ""
44
+ end
45
+ end
46
+
47
+ def to_s
48
+ "type: #{@type} " \
49
+ "length: #{@length} " \
50
+ "dictionary: #{@dictionary} " \
51
+ "description: #{@description} " \
52
+ "required: #{required} "
53
+ end
54
+
55
+ private
56
+
57
+ def type?(key, value)
58
+ unless value.kind_of?(@type)
59
+ raise TypeError.new(
60
+ "Wrong type of #{key}: #{value}, should be #{@type}. Error in Data: #{self.to_s}"
61
+ )
62
+ end
63
+ end
64
+
65
+ def length?(key, value)
66
+ if @length.kind_of?(Range)
67
+ unless @length.include?(value.length)
68
+ raise LengthError.new(
69
+ "The value #{key}: #{value} is not in the range of #{@length}. Error in Data: #{self.to_s}")
70
+ end
71
+ elsif @length.kind_of?(Integer)
72
+ unless value.length == @length
73
+ raise LengthError.new(
74
+ "The length of #{key}: #{value} should be #{@length}. Error in Data: #{self.to_s}"
75
+ )
76
+ end
77
+ else
78
+ raise LengthError.new(
79
+ "Error in length definition. Error in Data: #{self.to_s}"
80
+ )
81
+ end
82
+ end
83
+
84
+ def required?(key, value)
85
+ unless (!@required || !value.nil?)
86
+ raise RequiredError.new(
87
+ "The field required. Error in #{self.to_s}"
88
+ )
89
+ end
90
+ end
91
+
92
+ def dictionary?(key, value)
93
+ unless @dictionary.nil?
94
+ unless @dictionary.key?(value)
95
+ if @dictionary.key?('*') # Bypass Validation
96
+ return true
97
+ else
98
+ raise NotFoundInDictionary.new(
99
+ "The value '#{key}: #{value}' is not in the dictionary. Error in #{self.to_s}"
100
+ )
101
+ end
102
+ end
103
+ end
104
+ end
105
+
106
+ end
107
+ end
108
+ end
@@ -2,27 +2,59 @@ module Eancom
2
2
  module Edifact
3
3
  class Document
4
4
 
5
+ attr_accessor :header_element,
6
+ :body_element, :footer_element
7
+
5
8
  def initialize
6
- @envelope = Envelope.new
7
- @message = Message.new
9
+ @header_element = Header.new()
10
+ @body_element = Body.new()
11
+ @footer_element = Footer.new()
12
+ end
13
+
14
+ def header(&block)
15
+ yield(@header_element)
16
+ end
17
+
18
+ def body(&block)
19
+ yield(@body_element)
20
+ end
21
+
22
+ def footer(&block)
23
+ yield(@footer_element)
24
+ end
25
+
26
+ def add_to_header(segment)
27
+ @header_element.segment(segment)
8
28
  end
9
29
 
10
- def envelope(&block)
11
- yield(@envelope)
30
+ def add_to_body(segment)
31
+ @body_element.segment(segment)
12
32
  end
13
33
 
14
- def message(name, &block)
15
- @message.name = name
16
- yield(@message)
34
+ def add_to_footer(segment)
35
+ @footer_element.segment(segment)
17
36
  end
18
37
 
19
- def to_s
20
- stream = ""
21
- stream << @envelope.to_s
22
- stream << @message.to_s
38
+ def total_segments
39
+ total = 0
40
+ total += @body_element.segments.count
41
+ total
42
+ end
43
+
44
+ def to_s(debug: false)
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)
23
49
  stream
24
50
  end
25
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
57
+ end
26
58
  end
27
59
  end
28
60
  end
@@ -0,0 +1,26 @@
1
+ module Eancom
2
+ module Edifact
3
+
4
+ class DocumentElement
5
+
6
+ attr_accessor :segments
7
+
8
+ def initialize
9
+ @segments = []
10
+ end
11
+
12
+ def segment(segment)
13
+ segments << segment
14
+ end
15
+
16
+ def to_s(debug: false)
17
+ stream = ""
18
+ segments.each do |segment|
19
+ stream << segment.to_edi
20
+ stream << "\n" if debug
21
+ end
22
+ stream
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ module Eancom
2
+ module Edifact
3
+ class Footer < DocumentElement
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,15 @@
1
+ module Eancom
2
+ module Edifact
3
+ class Header < DocumentElement
4
+
5
+ def to_json_hash
6
+ hash = {}
7
+ hash[:header] = {}
8
+ @segments.each do |segment|
9
+ hash[:header].merge! segment.to_json_hash
10
+ end
11
+ hash
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,40 @@
1
+ module Eancom
2
+ module Edifact
3
+ class Item
4
+
5
+ attr_accessor :hash
6
+
7
+ def initialize()
8
+ @hash = {}
9
+ end
10
+
11
+ def << (segment)
12
+ if name = group_name(segment)
13
+ @hash[name] = [] if @hash[name].nil?
14
+ @hash[name] << segment.to_json_hash
15
+ else
16
+ @hash.merge!(segment.to_json_hash)
17
+ end
18
+ end
19
+
20
+ def to_json_hash
21
+ @hash
22
+ end
23
+
24
+ def empty?
25
+ @hash.empty?
26
+ end
27
+
28
+ private
29
+
30
+ def group_name(segment)
31
+ if segment.item_group_name
32
+ segment.item_group_name
33
+ else
34
+ segment.group_name
35
+ end
36
+ end
37
+
38
+ end
39
+ end
40
+ end
@@ -1,31 +1,39 @@
1
1
  module Eancom
2
2
  module Edifact
3
- class Message < Element
3
+ class Message
4
+
5
+ attr_accessor :items, :hash
4
6
 
5
7
  def initialize()
6
- @me = Segment.new
7
- @segments = [@me]
8
+ @items = []
9
+ @hash = {}
8
10
  end
9
11
 
10
- def add_segment(segment)
11
- @segments << segment
12
+ def add_item(item)
13
+ @items << item
12
14
  end
13
15
 
14
- def composite(composite)
15
- @me.composite(composite)
16
+ def << (segment)
17
+ if name = group_name(segment)
18
+ @hash[name] = [] if @hash[name].nil?
19
+ @hash[name] << segment.to_json_hash
20
+ else
21
+ @hash.merge!(segment.to_json_hash)
22
+ end
16
23
  end
17
24
 
18
- def name=(name)
19
- @me.name = name
25
+ def to_json_hash
26
+ message_hash = {}
27
+ items_hash = { items: @items }
28
+ message_hash.merge!(@hash)
29
+ message_hash.merge!(items_hash)
30
+ message_hash
20
31
  end
21
32
 
22
- def to_s
23
- stream = ""
24
- @segments.each do |segment|
25
- stream << segment.to_s
26
- stream << DELIMITERS[:segment]
27
- end
28
- stream
33
+ private
34
+
35
+ def group_name(segment)
36
+ segment.group_name
29
37
  end
30
38
 
31
39
  end
@@ -1,26 +1,145 @@
1
1
  module Eancom
2
2
  module Edifact
3
3
  class Segment
4
- attr_accessor :name, :composites
4
+ attr_accessor :tag
5
5
 
6
- def initialize(name = "")
7
- @name = name
8
- @composites = []
6
+ class SegmentParserError < StandardError; end
7
+
8
+ def initialize(tag:)
9
+ @tag = tag
10
+ validate_structure
11
+ end
12
+
13
+ def self.initialize_by_components(structure, array)
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 \
20
+ 'Error:\n \
21
+ '#{e}"
22
+ )
23
+ end
24
+ end
25
+
26
+ def validate_structure
27
+ attributes.each do |key, value|
28
+ next if value.nil?
29
+ structure.validate!(key, value)
30
+ end
9
31
  end
10
32
 
11
- def composite(content = "")
12
- @composites << content
33
+ def array
34
+ @array ||= structure.build_array(to_hash)
35
+ end
36
+
37
+ def structure
38
+ @structure ||= Eancom.find_structure(tag: tag)
13
39
  end
14
40
 
15
41
  def to_s
16
- stream = ""
17
- stream << name
18
- @composites.each do |composite|
19
- stream << DELIMITERS[:data]
20
- stream << composite
42
+ string = array.map do |e|
43
+ e = e.compact
44
+ next if e.empty?
45
+ [e.join(component_delimiter)]
46
+ end.join(data_delimiter)
47
+ clean_end_string(string)
48
+ string << segment_delimiter
49
+ string
50
+ end
51
+
52
+ def to_edi
53
+ to_s
54
+ end
55
+
56
+ def to_json_hash
57
+ raise NotImplementedError
58
+ end
59
+
60
+ def segment_type
61
+ raise NotImplementedError
62
+ end
63
+
64
+ def to_hash
65
+ attributes
66
+ end
67
+
68
+ def is_header?
69
+ segment_type == :header
70
+ end
71
+
72
+ def is_body?
73
+ segment_type == :body
74
+ end
75
+
76
+ def is_footer?
77
+ segment_type == :footer
78
+ end
79
+
80
+ def tag?(other)
81
+ tag == other
82
+ end
83
+
84
+ def starts_message?
85
+ false
86
+ end
87
+
88
+ def starts_item?
89
+ false
90
+ end
91
+
92
+ def group_name
93
+ nil
94
+ end
95
+
96
+ def item_group_name
97
+ nil
98
+ end
99
+
100
+ private
101
+
102
+ def data_delimiter
103
+ DELIMITERS[:data]
104
+ end
105
+
106
+ def component_delimiter
107
+ DELIMITERS[:component]
108
+ end
109
+
110
+ def segment_delimiter
111
+ DELIMITERS[:segment]
112
+ end
113
+
114
+ def attributes
115
+ hash = {}
116
+ instance_variables.each do |var|
117
+ key = var.to_s.delete('@').to_sym
118
+ next if key == :structure
119
+ next if key == :array
120
+ value = instance_variable_get(var)
121
+ hash[key] = value
122
+ end
123
+ hash
124
+ end
125
+
126
+ def find_identifier(key)
127
+ dictionary = structure.find(key).dictionary
128
+ var = instance_variable_get('@' + key.to_s)
129
+ if dictionary[var]
130
+ dictionary[var][:identifier]
131
+ else
132
+ var
133
+ end
134
+ end
135
+
136
+ def clean_end_string(string)
137
+ while (string[-1] == data_delimiter)
138
+ string.chop!
21
139
  end
22
- stream
140
+ string
23
141
  end
142
+
24
143
  end
25
144
  end
26
145
  end
@@ -0,0 +1,61 @@
1
+ module Eancom
2
+ module Edifact
3
+ class ALC < Segment
4
+ TAG = 'ALC'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ allowance_or_charge_code_qualifier:,
12
+ allowance_or_charge_identifier: nil,
13
+ allowance_or_charge_identification_code: nil,
14
+ settlement_mean_code: nil,
15
+ calculation_sequence_code: nil,
16
+ special_service_description_code: nil,
17
+ code_list_identification_code: nil,
18
+ code_list_responsible_agency_code: nil,
19
+ special_service_description_1: nil,
20
+ special_service_description_2: nil
21
+ )
22
+ @tag = tag
23
+ @allowance_or_charge_code_qualifier = allowance_or_charge_code_qualifier
24
+ @allowance_or_charge_identifier = allowance_or_charge_identifier
25
+ @allowance_or_charge_identification_code = allowance_or_charge_identification_code
26
+ @settlement_mean_code = settlement_mean_code
27
+ @calculation_sequence_code = calculation_sequence_code
28
+ @special_service_description_code = special_service_description_code
29
+ @code_list_identification_code = code_list_identification_code
30
+ @code_list_responsible_agency_code = code_list_responsible_agency_code
31
+ @special_service_description_1 = special_service_description_1
32
+ @special_service_description_2 = special_service_description_2
33
+ super(tag: tag || TAG)
34
+ end
35
+
36
+ def to_json_hash
37
+ hash = {}
38
+ hash.merge!(allowance_or_charge_code_qualifier: find_identifier(:allowance_or_charge_code_qualifier)) if @allowance_or_charge_code_qualifier
39
+ hash.merge!(allowance_or_charge_identifier: @allowance_or_charge_identifier) if @allowance_or_charge_identifier
40
+ hash.merge!(allowance_or_charge_identification_code: find_identifier(:allowance_or_charge_identification_code)) if @allowance_or_charge_identification_code
41
+ hash.merge!(settlement_mean_code: find_identifier(:settlement_mean_code)) if @settlement_mean_code
42
+ hash.merge!(calculation_sequence_code: find_identifier(:calculation_sequence_code)) if @calculation_sequence_code
43
+ hash.merge!(special_service_description_code: find_identifier(:special_service_description_code)) if @special_service_description_code
44
+ hash.merge!(code_list_identification_code: @code_list_identification_code) if @code_list_identification_code
45
+ hash.merge!(code_list_responsible_agency_code: find_identifier(:code_list_responsible_agency_code)) if @code_list_responsible_agency_code
46
+ hash.merge!(special_service_description_1: @special_service_description_1) if @special_service_description_1
47
+ hash.merge!(special_service_description_2: @special_service_description_2) if @special_service_description_2
48
+ hash
49
+ end
50
+
51
+ def group_name
52
+ 'allowances_or_charges'
53
+ end
54
+
55
+ def segment_type
56
+ TYPE
57
+ end
58
+
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,52 @@
1
+ module Eancom
2
+ module Edifact
3
+ class ALI < Segment
4
+ TAG = 'ALI'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ country_of_origin_name_code: nil,
12
+ duty_regime_type_code: nil,
13
+ special_condition_code_1: nil,
14
+ special_condition_code_2: nil,
15
+ special_condition_code_3: nil,
16
+ special_condition_code_4: nil,
17
+ special_condition_code_5: nil
18
+ )
19
+ @tag = tag
20
+ @country_of_origin_name_code = country_of_origin_name_code
21
+ @duty_regime_type_code = duty_regime_type_code
22
+ @special_condition_code_1 = special_condition_code_1
23
+ @special_condition_code_2 = special_condition_code_2
24
+ @special_condition_code_3 = special_condition_code_3
25
+ @special_condition_code_4 = special_condition_code_4
26
+ @special_condition_code_5 = special_condition_code_5
27
+
28
+ super(tag: tag || TAG)
29
+ end
30
+
31
+ def to_json_hash
32
+ hash = {}
33
+ hash.merge!(country_of_origin_name_code: @country_of_origin_name_code) if @country_of_origin_name_code
34
+ hash.merge!(duty_regime_type_code: @duty_regime_type_code) if @duty_regime_type_code
35
+ hash.merge!(special_condition_code_1: find_identifier(:special_condition_code_1)) if @special_condition_code_1
36
+ hash.merge!(special_condition_code_2: find_identifier(:special_condition_code_2)) if @special_condition_code_2
37
+ hash.merge!(special_condition_code_3: find_identifier(:special_condition_code_3)) if @special_condition_code_3
38
+ hash.merge!(special_condition_code_4: find_identifier(:special_condition_code_4)) if @special_condition_code_4
39
+ hash.merge!(special_condition_code_5: find_identifier(:special_condition_code_5)) if @special_condition_code_5
40
+ outer_hash = {}
41
+ outer_hash.merge!(additional_information: hash )
42
+ outer_hash
43
+ end
44
+
45
+ def segment_type
46
+ TYPE
47
+ end
48
+
49
+
50
+ end
51
+ end
52
+ end