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,45 @@
1
+ module Eancom
2
+ module Edifact
3
+ class BGM < Segment
4
+ TAG = 'BGM'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ document_name_code: nil,
12
+ code_list_responsible_agency_code: nil,
13
+ code_list_identification_code: nil,
14
+ document_name: nil,
15
+ document_identifier: nil,
16
+ message_function_code: nil
17
+ )
18
+ @tag = tag
19
+ @document_name_code = document_name_code
20
+ @code_list_responsible_agency_code = code_list_responsible_agency_code
21
+ @code_list_identification_code = code_list_identification_code
22
+ @document_name = document_name
23
+ @document_identifier = document_identifier
24
+ @message_function_code = message_function_code
25
+
26
+ super(tag: tag || TAG)
27
+ end
28
+
29
+ def to_json_hash
30
+ {
31
+ document_identifier: @document_identifier
32
+ }
33
+ end
34
+
35
+ def starts_message?
36
+ true
37
+ end
38
+
39
+ def segment_type
40
+ TYPE
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,47 @@
1
+ module Eancom
2
+ module Edifact
3
+ class CAV < Segment
4
+ TAG = 'CAV'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ characterisitc_value_description_code: nil,
12
+ code_list_identification_code: nil,
13
+ code_list_respobsibility_agency_code: nil,
14
+ characterisitc_value_description_1: nil,
15
+ characterisitc_value_description_2: nil
16
+ )
17
+ @tag = tag
18
+ @characterisitc_value_description_code = characterisitc_value_description_code
19
+ @code_list_identification_code = code_list_identification_code
20
+ @code_list_respobsibility_agency_code = code_list_respobsibility_agency_code
21
+ @characterisitc_value_description_1 = characterisitc_value_description_1
22
+ @characterisitc_value_description_2 = characterisitc_value_description_2
23
+
24
+ super(tag: tag || TAG)
25
+ end
26
+
27
+ def to_json_hash
28
+ hash = {}
29
+ hash.merge!(characterisitc_value_description_code: find_identifier(:characterisitc_value_description_code)) if @characterisitc_value_description_code
30
+ hash.merge!(code_list_identification_code: @code_list_identification_code) if @code_list_identification_code
31
+ hash.merge!(code_list_respobsibility_agency_code: find_identifier(:code_list_respobsibility_agency_code)) if @code_list_respobsibility_agency_code
32
+ hash.merge!(characterisitc_value_description_1: find_identifier(:characterisitc_value_description_1)) if @characterisitc_value_description_1
33
+ hash.merge!(characterisitc_value_description_2: @characterisitc_value_description_2) if @characterisitc_value_description_2
34
+ hash
35
+ end
36
+
37
+ def group_name
38
+ 'characterisitcs'
39
+ end
40
+
41
+ def segment_type
42
+ TYPE
43
+ end
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,53 @@
1
+ module Eancom
2
+ module Edifact
3
+ class CCI < Segment
4
+ TAG = 'CCI'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ class_type_code: nil,
12
+ measurment_attribute_code: nil,
13
+ characteristic_description_code:,
14
+ code_list_identification_code: nil,
15
+ code_list_respobsibility_agency_code: nil,
16
+ characterisitc_description_1: nil,
17
+ characterisitc_description_2: nil
18
+ )
19
+ @tag = tag
20
+ @class_type_code = class_type_code
21
+ @measurment_attribute_code = measurment_attribute_code
22
+ @characteristic_description_code = characteristic_description_code
23
+ @code_list_identification_code = code_list_identification_code
24
+ @code_list_respobsibility_agency_code = code_list_respobsibility_agency_code
25
+ @characterisitc_description_1 = characterisitc_description_1
26
+ @characterisitc_description_2 = characterisitc_description_2
27
+
28
+ super(tag: tag || TAG)
29
+ end
30
+
31
+ def to_json_hash
32
+ hash = {}
33
+ hash.merge!(class_type_code: find_identifier(:class_type_code)) if @class_type_code
34
+ hash.merge!(measurment_attribute_code: @measurment_attribute_code) if @measurment_attribute_code
35
+ hash.merge!(characteristic_description_code: find_identifier(:characteristic_description_code)) if @characteristic_description_code
36
+ hash.merge!(code_list_identification_code: @code_list_identification_code) if @code_list_identification_code
37
+ hash.merge!(code_list_respobsibility_agency_code: find_identifier(:code_list_respobsibility_agency_code)) if @code_list_respobsibility_agency_code
38
+ hash.merge!(characterisitc_description_1: @characterisitc_description_1) if @characterisitc_description_1
39
+ hash.merge!(characterisitc_description_2: @characterisitc_description_2) if @characterisitc_description_2
40
+ hash
41
+ end
42
+
43
+ def group_name
44
+ 'characterisitcs'
45
+ end
46
+
47
+ def segment_type
48
+ TYPE
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,33 @@
1
+ module Eancom
2
+ module Edifact
3
+ class CNT < Segment
4
+ TAG = 'CNT'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ control_total_type_code_quantifier:,
12
+ control_total_value:,
13
+ measurment_unit_code: nil
14
+ )
15
+ @tag = tag
16
+ @control_total_type_code_quantifier = control_total_type_code_quantifier
17
+ @control_total_value = control_total_value
18
+ @measurment_unit_code = measurment_unit_code
19
+
20
+ super(tag: tag || TAG)
21
+ end
22
+
23
+ def to_json_hash
24
+ {}
25
+ end
26
+
27
+ def segment_type
28
+ TYPE
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,30 @@
1
+ module Eancom
2
+ module Edifact
3
+ class CPS < Segment
4
+ TAG = 'CPS'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ def initialize(
8
+ tag: nil,
9
+ hierarchical_structure_level_identifier:,
10
+ hierarchical_structure_parent_identifier: nil,
11
+ packaging_level_code: nil
12
+ )
13
+ @tag = tag
14
+ @hierarchical_structure_level_identifier = hierarchical_structure_level_identifier
15
+ @hierarchical_structure_parent_identifier = hierarchical_structure_parent_identifier
16
+ @packaging_level_code = packaging_level_code
17
+
18
+ super(tag: tag || TAG)
19
+ end
20
+
21
+ def to_json_hash
22
+ {}
23
+ end
24
+
25
+ def segment_type
26
+ TYPE
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,60 @@
1
+ module Eancom
2
+ module Edifact
3
+ class CUX < Segment
4
+ TAG = 'CUX'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ currency_usage_code_qualifier_1:,
12
+ currency_identification_code_1:,
13
+ currency_type_code_qualifier_1:,
14
+ currency_rate_value_1: nil,
15
+ currency_usage_code_qualifier_2: nil,
16
+ currency_identification_code_2: nil,
17
+ currency_type_code_qualifier_2: nil,
18
+ currency_rate_value_2: nil,
19
+ currency_exchange_rate: nil,
20
+ exchange_rate_currency_market_identifier: nil
21
+ )
22
+ @tag = tag
23
+ @currency_usage_code_qualifier_1 = currency_usage_code_qualifier_1
24
+ @currency_identification_code_1 = currency_identification_code_1
25
+ @currency_type_code_qualifier_1 = currency_type_code_qualifier_1
26
+ @currency_rate_value_1 = currency_rate_value_1
27
+ @currency_usage_code_qualifier_2 = currency_usage_code_qualifier_2
28
+ @currency_identification_code_2 = currency_identification_code_2
29
+ @currency_type_code_qualifier_2 = currency_type_code_qualifier_2
30
+ @currency_rate_value_2 = currency_rate_value_2
31
+ @currency_exchange_rate = currency_exchange_rate
32
+ @exchange_rate_currency_market_identifier = exchange_rate_currency_market_identifier
33
+
34
+ super(tag: tag || TAG)
35
+ end
36
+
37
+ def to_json_hash
38
+ hash = {}
39
+ hash.merge!(currency_usage_code_qualifier_1: find_identifier(:currency_usage_code_qualifier_1)) if @currency_usage_code_qualifier_1
40
+ hash.merge!(currency_identification_code_1: @currency_identification_code_1) if @currency_identification_code_1
41
+ hash.merge!(currency_type_code_qualifier_1: find_identifier(:currency_type_code_qualifier_1)) if @currency_type_code_qualifier_1
42
+ hash.merge!(currency_rate_value_1: @currency_rate_value_1) if @currency_rate_value_1
43
+ hash.merge!(currency_usage_code_qualifier_2: find_identifier(:currency_usage_code_qualifier_2)) if @currency_usage_code_qualifier_2
44
+ hash.merge!(currency_identification_code_2: @currency_identification_code_2) if @currency_identification_code_2
45
+ hash.merge!(currency_type_code_qualifier_2: find_identifier(:currency_type_code_qualifier_2)) if @currency_type_code_qualifier_2
46
+ hash.merge!(currency_rate_value_2: @currency_rate_value_2) if @currency_rate_value_2
47
+ { currency: hash }
48
+ end
49
+
50
+ def item_group_name
51
+ 'prices'
52
+ end
53
+
54
+ def segment_type
55
+ TYPE
56
+ end
57
+
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,43 @@
1
+ module Eancom
2
+ module Edifact
3
+ class DTM < Segment
4
+ TAG = 'DTM'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_accessor :type, :date_time, :format
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ type:,
12
+ date_time:,
13
+ format:
14
+ )
15
+ @tag = tag
16
+ @type = type
17
+ @date_time = date_time
18
+ @format = format
19
+
20
+ super(tag: @tag || TAG)
21
+ end
22
+
23
+ def to_json_hash
24
+ {
25
+ identifier => {
26
+ date_time: @date_time
27
+ }
28
+ }
29
+ end
30
+
31
+ def segment_type
32
+ TYPE
33
+ end
34
+
35
+ private
36
+
37
+ def identifier
38
+ @identifier ||= structure.find(:type).dictionary[@type][:identifier]
39
+ end
40
+ end
41
+ end
42
+ end
43
+
@@ -0,0 +1,63 @@
1
+ module Eancom
2
+ module Edifact
3
+ class FTX < Segment
4
+ TAG = 'FTX'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ text_subject_code_qualifier:,
12
+ free_text_function_code: nil,
13
+ free_text_value_code: nil,
14
+ code_list_identification_code: nil,
15
+ code_list_responsible_agency_code: nil,
16
+ free_text_value_1: nil,
17
+ free_text_value_2: nil,
18
+ free_text_value_3: nil,
19
+ free_text_value_4: nil,
20
+ free_text_value_5: nil
21
+ )
22
+ @tag = tag
23
+ @text_subject_code_qualifier = text_subject_code_qualifier
24
+ @free_text_function_code = free_text_function_code
25
+ @free_text_value_code = free_text_value_code
26
+ @code_list_identification_code = code_list_identification_code
27
+ @code_list_responsible_agency_code = code_list_responsible_agency_code
28
+ @free_text_value_1 = free_text_value_1
29
+ @free_text_value_2 = free_text_value_2
30
+ @free_text_value_3 = free_text_value_3
31
+ @free_text_value_4 = free_text_value_4
32
+ @free_text_value_5 = free_text_value_5
33
+
34
+ super(tag: tag || TAG)
35
+ end
36
+
37
+ def to_json_hash
38
+ hash = {}
39
+ hash.merge!(text_subject_code_qualifier: @text_subject_code_qualifier) if @text_subject_code_qualifier
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
42
+ hash.merge!(code_list_identification_code: @code_list_identification_code) if @code_list_identification_code
43
+ hash.merge!(code_list_responsible_agency_code: find_identifier(:code_list_responsible_agency_code)) if @code_list_responsible_agency_code
44
+ hash.merge!(free_text_value_1: @free_text_value_1) if @free_text_value_1
45
+ hash.merge!(free_text_value_2: @free_text_value_2) if @free_text_value_2
46
+ hash.merge!(free_text_value_3: @free_text_value_3) if @free_text_value_3
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
49
+ hash
50
+ end
51
+
52
+ def segment_type
53
+ TYPE
54
+ end
55
+
56
+ def group_name
57
+ 'free_texts'
58
+ end
59
+
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,69 @@
1
+ module Eancom
2
+ module Edifact
3
+ class IMD < Segment
4
+ TAG = 'IMD'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ def initialize(
8
+ tag: nil,
9
+ description_format_code:,
10
+ item_characteristic_code: nil,
11
+ code_list_identification_code: nil,
12
+ code_list_responsible_agency_code: nil,
13
+ item_description_code: nil,
14
+ code_list_identification_code_1: '',
15
+ code_list_responsible_agency_code_1: nil,
16
+ item_description_1: nil,
17
+ item_description_2: nil,
18
+ language_name_code: nil,
19
+ surface_or_layer_code: nil
20
+ )
21
+ @tag = tag
22
+ @description_format_code = description_format_code
23
+ @item_characteristic_code = item_characteristic_code
24
+ @code_list_identification_code = code_list_identification_code
25
+ @code_list_responsible_agency_code = code_list_responsible_agency_code
26
+ @item_description_code = item_description_code
27
+ @code_list_identification_code_1 = code_list_identification_code_1
28
+ @code_list_responsible_agency_code_1 = code_list_responsible_agency_code_1
29
+ @item_description_1 = item_description_1
30
+ @item_description_2 = item_description_2
31
+ @language_name_code = language_name_code
32
+ @surface_or_layer_code = surface_or_layer_code
33
+
34
+ super(tag: tag || TAG)
35
+ end
36
+
37
+ def to_json_hash
38
+ hash = {}
39
+ hash.merge!(description_format_code: find_identifier(:description_format_code)) if @description_format_code
40
+ hash.merge!(item_characteristic_code: find_identifier(:item_characteristic_code)) if @item_characteristic_code
41
+ hash.merge!(code_list_identification_code: @code_list_identification_code) if @code_list_identification_code
42
+ hash.merge!(code_list_responsible_agency_code: find_identifier(:code_list_responsible_agency_code)) if @code_list_responsible_agency_code
43
+ if @item_description_code
44
+ identifier = find_identifier(:item_description_code)
45
+ if identifier
46
+ hash.merge!(item_description_code: identifier)
47
+ else
48
+ hash.merge!(item_description_code: @item_description_code)
49
+ end
50
+ end
51
+ hash.merge!(code_list_identification_code_1: @code_list_identification_code_1) if @code_list_identification_code_1
52
+ hash.merge!(code_list_responsible_agency_code_1: find_identifier(:code_list_responsible_agency_code_1)) if @code_list_responsible_agency_code_1
53
+ hash.merge!(item_description_1: @item_description_1) if @item_description_1
54
+ hash.merge!(item_description_2: @item_description_2) if @item_description_2
55
+ hash.merge!(language_name_code: @language_name_code) if @language_name_code
56
+ hash.merge!(surface_or_layer_code: @surface_or_layer_code) if @surface_or_layer_code
57
+ hash
58
+ end
59
+
60
+ def group_name
61
+ 'item_descriptions'
62
+ end
63
+
64
+ def segment_type
65
+ TYPE
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,43 @@
1
+ module Eancom
2
+ module Edifact
3
+ class LIN < Segment
4
+ TAG = 'LIN'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ def initialize(
8
+ tag: nil,
9
+ line_item_identifier_1:,
10
+ action_request_notification_description_code: '',
11
+ item_identifier:,
12
+ item_type_identification_code:,
13
+ sub_line_indicator_code: nil,
14
+ line_item_identifier_2: nil
15
+ )
16
+ @tag = tag
17
+ @line_item_identifier_1 = line_item_identifier_1
18
+ @action_request_notification_description_code = action_request_notification_description_code
19
+ @item_identifier = item_identifier
20
+ @item_type_identification_code = item_type_identification_code
21
+ @sub_line_indicator_code = sub_line_indicator_code
22
+ @line_item_identifier_2 = line_item_identifier_2
23
+
24
+ super(tag: tag || TAG )
25
+ end
26
+
27
+ def starts_item?
28
+ true
29
+ end
30
+
31
+ def to_json_hash
32
+ {
33
+ ean: @item_identifier
34
+ }
35
+ end
36
+
37
+ def segment_type
38
+ TYPE
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,43 @@
1
+ module Eancom
2
+ module Edifact
3
+ class LOC < Segment
4
+ TAG = 'LOC'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ location_function_qualifier:,
12
+ location_name_code:,
13
+ code_list_identification_code: nil,
14
+ code_list_responsible_agancy_code: nil
15
+ )
16
+ @tag = tag
17
+ @location_function_qualifier = location_function_qualifier
18
+ @location_name_code = location_name_code
19
+ @code_list_identification_code = code_list_identification_code
20
+ @code_list_responsible_agancy_code = code_list_responsible_agancy_code
21
+
22
+ super(tag: tag || TAG)
23
+ end
24
+
25
+ def to_json_hash
26
+ hash = {}
27
+ hash.merge!(location_function_qualifier: find_identifier(:location_function_qualifier)) if @location_function_qualifier
28
+ hash.merge!(location_name_code: @location_name_code) if @location_name_code
29
+ hash.merge!(code_list_identification_code: @code_list_identification_code) if @code_list_identification_code
30
+ hash.merge!(code_list_responsible_agancy_code: find_identifier(:code_list_responsible_agancy_code)) if @code_list_responsible_agancy_code
31
+ hash
32
+ outer_hash = {}
33
+ outer_hash.merge!({ location: hash})
34
+ outer_hash
35
+ end
36
+
37
+ def segment_type
38
+ TYPE
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,53 @@
1
+ module Eancom
2
+ module Edifact
3
+ class MEA < Segment
4
+ TAG = 'MEA'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ measurement_purpose_code_qualifier:,
12
+ measured_attribute_code:,
13
+ measurement_significance_code: nil,
14
+ measurment_unit_code:,
15
+ measurement_value:,
16
+ range_minimum_value: nil,
17
+ range_maximum_value: nil
18
+ )
19
+ @tag = tag
20
+
21
+ @measurement_purpose_code_qualifier = measurement_purpose_code_qualifier
22
+ @measured_attribute_code = measured_attribute_code
23
+ @measurement_significance_code = measurement_significance_code
24
+ @measurment_unit_code = measurment_unit_code
25
+ @measurement_value = measurement_value
26
+ @range_minimum_value = range_minimum_value
27
+ @range_maximum_value = range_maximum_value
28
+
29
+ super(tag: tag || TAG)
30
+ end
31
+
32
+ def to_json_hash
33
+ hash = {}
34
+ hash.merge!(measurement_purpose_code_qualifier: find_identifier(:measurement_purpose_code_qualifier)) if @measurement_purpose_code_qualifier
35
+ hash.merge!(measured_attribute_code: find_identifier(:measured_attribute_code)) if @measured_attribute_code
36
+ hash.merge!(measurement_significance_code: find_identifier(:measurement_significance_code)) if @measurement_significance_code
37
+ hash.merge!(measurement_value: @measurement_value) if @measurement_value
38
+ hash.merge!(range_minimum_value: @range_minimum_value) if @range_minimum_value
39
+ hash.merge!(range_maximum_value: @range_maximum_value) if @range_maximum_value
40
+ hash
41
+ end
42
+
43
+ def group_name
44
+ 'characterisitcs'
45
+ end
46
+
47
+ def segment_type
48
+ TYPE
49
+ end
50
+
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,45 @@
1
+ module Eancom
2
+ module Edifact
3
+ class MOA < Segment
4
+ TAG = 'MOA'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ monetary_amount_type_code_qualifier:,
12
+ monetary_amount:,
13
+ currency_identification_code: nil,
14
+ currency_type_code_qualifier: nil
15
+ )
16
+ @tag = tag
17
+
18
+ @monetary_amount_type_code_qualifier = monetary_amount_type_code_qualifier
19
+ @monetary_amount= monetary_amount
20
+ @currency_identification_code = currency_identification_code
21
+ @currency_type_code_qualifier = currency_type_code_qualifier
22
+
23
+ super(tag: tag || TAG)
24
+ end
25
+
26
+ def to_json_hash
27
+ hash = {}
28
+ hash.merge!(monetary_amount_type_code_qualifier: find_identifier(:monetary_amount_type_code_qualifier)) if @monetary_amount_type_code_qualifier
29
+ hash.merge!(monetary_amount: @monetary_amount) if @monetary_amount
30
+ hash.merge!(currency_identification_code: @currency_identification_code) if @currency_identification_code
31
+ hash.merge!(currency_type_code_qualifier: find_identifier(@currency_type_code_qualifier)) if @currency_type_code_qualifier
32
+ hash
33
+ end
34
+
35
+ def group_name
36
+ 'monetary_amounts'
37
+ end
38
+
39
+ def segment_type
40
+ TYPE
41
+ end
42
+
43
+ end
44
+ end
45
+ end