eancom 0.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
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,107 @@
1
+ module Eancom
2
+ module Edifact
3
+ class NAD < Segment
4
+ TAG = 'NAD'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ def initialize(
8
+ tag: nil,
9
+ party_function_code_qualifier:,
10
+ party_identifier:,
11
+ code_list_identification_code_1: '',
12
+ code_list_responsible_agancy_code_1:,
13
+ name_and_address_description_1: nil,
14
+ name_and_address_description_2: nil,
15
+ name_and_address_description_3: nil,
16
+ name_and_address_description_4: nil,
17
+ name_and_address_description_5: nil,
18
+ party_name_1: nil,
19
+ party_name_2: nil,
20
+ party_name_3: nil,
21
+ party_name_4: nil,
22
+ party_name_5: nil,
23
+ street_and_number_1: nil,
24
+ street_and_number_2: nil,
25
+ street_and_number_3: nil,
26
+ street_and_number_4: nil,
27
+ street_and_number_5: nil,
28
+ city_name: nil,
29
+ country_sub_entity_name_code: nil,
30
+ code_list_identification_code_2: nil,
31
+ code_list_responsible_agancy_code_2: nil,
32
+ country_sub_entry_name: nil,
33
+ postal_identification_code: nil,
34
+ country_name_code: nil
35
+ )
36
+ @tag = tag
37
+ @party_function_code_qualifier = party_function_code_qualifier
38
+ @party_identifier = party_identifier
39
+ @code_list_identification_code_1 = code_list_identification_code_1
40
+ @code_list_responsible_agancy_code_1 = code_list_responsible_agancy_code_1
41
+ @name_and_address_description_1 = name_and_address_description_1
42
+ @name_and_address_description_2 = name_and_address_description_2
43
+ @name_and_address_description_3 = name_and_address_description_3
44
+ @name_and_address_description_4 = name_and_address_description_4
45
+ @name_and_address_description_5 = name_and_address_description_5
46
+ @party_name_1 = party_name_1
47
+ @party_name_2 = party_name_2
48
+ @party_name_3 = party_name_3
49
+ @party_name_4 = party_name_4
50
+ @party_name_5 = party_name_5
51
+ @street_and_number_1 = street_and_number_1
52
+ @street_and_number_2 = street_and_number_2
53
+ @street_and_number_3 = street_and_number_3
54
+ @street_and_number_4 = street_and_number_4
55
+ @street_and_number_5 = street_and_number_5
56
+ @city_name = city_name
57
+ @country_sub_entity_name_code = country_sub_entity_name_code
58
+ @code_list_identification_code_2 = code_list_identification_code_2
59
+ @code_list_responsible_agancy_code_2 = code_list_responsible_agancy_code_2
60
+ @country_sub_entry_name = country_sub_entry_name
61
+ @postal_identification_code = postal_identification_code
62
+ @country_name_code = country_name_code
63
+ super(tag: tag || TAG)
64
+ end
65
+
66
+ def to_json_hash
67
+ hash = { identifier => {} }
68
+ hash[identifier].merge!({ party_identifier: @party_identifier }) if @party_identifier
69
+ hash[identifier].merge!(code_list_responsible_agancy_code_1: find_identifier(:code_list_responsible_agancy_code_1)) if @code_list_responsible_agancy_code_1
70
+ hash[identifier].merge!({ name_and_address_description_1: @name_and_address_description_1 }) if @name_and_address_description_1
71
+ hash[identifier].merge!({ name_and_address_description_2: @name_and_address_description_2 }) if @name_and_address_description_2
72
+ hash[identifier].merge!({ name_and_address_description_3: @name_and_address_description_3 }) if @name_and_address_description_3
73
+ hash[identifier].merge!({ name_and_address_description_4: @name_and_address_description_4 }) if @name_and_address_description_4
74
+ hash[identifier].merge!({ name_and_address_description_5: @name_and_address_description_5 }) if @name_and_address_description_5
75
+ hash[identifier].merge!({ party_name_1: @party_name_1 }) if @party_name_1
76
+ hash[identifier].merge!({ party_name_2: @party_name_2 }) if @party_name_2
77
+ hash[identifier].merge!({ party_name_3: @party_name_3 }) if @party_name_3
78
+ hash[identifier].merge!({ party_name_4: @party_name_4 }) if @party_name_4
79
+ hash[identifier].merge!({ party_name_5: @party_name_5 }) if @party_name_5
80
+ hash[identifier].merge!({ street_and_number_1: @street_and_number_1 }) if @street_and_number_1
81
+ hash[identifier].merge!({ street_and_number_2: @street_and_number_2 }) if @street_and_number_2
82
+ hash[identifier].merge!({ street_and_number_3: @street_and_number_3 }) if @street_and_number_3
83
+ hash[identifier].merge!({ street_and_number_4: @street_and_number_4 }) if @street_and_number_4
84
+ hash[identifier].merge!({ street_and_number_5: @street_and_number_5 }) if @street_and_number_5
85
+ hash[identifier].merge!({ city_name: @city_name }) if @city_name
86
+ hash[identifier].merge!({ country_sub_entity_name_code: @country_sub_entity_name_code }) if @country_sub_entity_name_code
87
+ hash[identifier].merge!({ country_sub_entry_name: @country_sub_entry_name }) if @country_sub_entry_name
88
+ hash[identifier].merge!({ postal_identification_code: @postal_identification_code }) if @postal_identification_code
89
+ hash[identifier].merge!({ country_name_code: @country_name_code }) if @country_name_code
90
+
91
+ hash = {} if hash[identifier].empty?
92
+ hash
93
+ end
94
+
95
+ def segment_type
96
+ TYPE
97
+ end
98
+
99
+ private
100
+
101
+ def identifier
102
+ @identifier ||= structure.find(:party_function_code_qualifier).dictionary[@party_function_code_qualifier][:identifier]
103
+ end
104
+
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,54 @@
1
+ module Eancom
2
+ module Edifact
3
+ class PAC < Segment
4
+ TAG = 'PAC'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ def initialize(
8
+ tag: nil,
9
+ package_quantity: nil,
10
+ packaging_level_code: nil,
11
+ packaging_related_description_code: nil,
12
+ packaging_terms_and_conditions: nil,
13
+ package_type_description_code: nil,
14
+ code_list_identification_code: nil,
15
+ code_list_responsible_agency_code: nil,
16
+ type_of_packages: nil,
17
+ description_format_code: nil,
18
+ type_of_packages_1: nil,
19
+ item_type_identification_code_1: nil,
20
+ type_of_packages_2: nil,
21
+ item_type_identification_code_2: nil,
22
+ returnable_package_freight_payment_responsibility_code: nil,
23
+ returnable_package_load_contents_code: nil
24
+ )
25
+ @tag = tag
26
+ @package_quantity = package_quantity
27
+ @packaging_level_code = packaging_level_code
28
+ @packaging_related_description_code = packaging_related_description_code
29
+ @packaging_terms_and_conditions = packaging_terms_and_conditions
30
+ @package_type_description_code = package_type_description_code
31
+ @code_list_identification_code = code_list_identification_code
32
+ @code_list_responsible_agency_code = code_list_responsible_agency_code
33
+ @type_of_packages = type_of_packages
34
+ @description_format_code = description_format_code
35
+ @type_of_packages_1 = type_of_packages_1
36
+ @item_type_identification_code_1 = item_type_identification_code_1
37
+ @type_of_packages_2 = type_of_packages_2
38
+ @item_type_identification_code_2 = item_type_identification_code_2
39
+ @returnable_package_freight_payment_responsibility_code = returnable_package_freight_payment_responsibility_code
40
+ @returnable_package_load_contents_code = returnable_package_load_contents_code
41
+
42
+ super(tag: tag || TAG)
43
+ end
44
+
45
+ def to_json_hash
46
+ {}
47
+ end
48
+
49
+ def segment_type
50
+ TYPE
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,45 @@
1
+ module Eancom
2
+ module Edifact
3
+ class PGI < Segment
4
+ TAG = 'PGI'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ product_group_type_code:,
12
+ product_group_name_code: nil,
13
+ code_list_identification_code: nil,
14
+ code_list_responsibility_agency_code: nil,
15
+ product_group_name: nil
16
+ )
17
+ @tag = tag
18
+ @product_group_type_code = product_group_type_code
19
+ @product_group_name_code = product_group_name_code
20
+ @code_list_identification_code = code_list_identification_code
21
+ @code_list_responsibility_agency_code = code_list_responsibility_agency_code
22
+ @product_group_name = product_group_name_code
23
+
24
+ super(tag: tag || TAG)
25
+ end
26
+
27
+ def to_json_hash
28
+ hash = {
29
+ 'product_group_identifier': identifier
30
+ }
31
+ end
32
+
33
+ def segment_type
34
+ TYPE
35
+ end
36
+
37
+ private
38
+
39
+ def identifier
40
+ @identifier ||= structure.find(:product_group_type_code).dictionary[@product_group_type_code][:identifier]
41
+ end
42
+
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,107 @@
1
+ module Eancom
2
+ module Edifact
3
+ class PIA < Segment
4
+ TAG = 'PIA'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ def initialize(
8
+ tag: nil,
9
+ product_identifier_code_qualifier:,
10
+ item_identifier_1:,
11
+ item_type_identification_code_1:,
12
+ code_list_identification_code_1: nil,
13
+ code_list_responsible_agency_code_1: nil,
14
+ item_identifier_2: nil,
15
+ item_type_identification_code_2: nil,
16
+ code_list_identification_code_2: nil,
17
+ code_list_responsible_agency_code_2: nil,
18
+ item_identifier_3: nil,
19
+ item_type_identification_code_3: nil,
20
+ code_list_identification_code_3: nil,
21
+ code_list_responsible_agency_code_3: nil,
22
+ item_identifier_4: nil,
23
+ item_type_identification_code_4: nil,
24
+ code_list_identification_code_4: nil,
25
+ code_list_responsible_agency_code_4: nil,
26
+ item_identifier_5: nil,
27
+ item_type_identification_code_5: nil,
28
+ code_list_identification_code_5: nil,
29
+ code_list_responsible_agency_code_5: nil
30
+ )
31
+ @tag = tag
32
+ @product_identifier_code_qualifier = product_identifier_code_qualifier
33
+
34
+ @item_identifier_1 = item_identifier_1
35
+ @item_type_identification_code_1 = item_type_identification_code_1
36
+ @code_list_identification_code_1 = code_list_identification_code_1
37
+ @code_list_responsible_agency_code_1 = code_list_responsible_agency_code_1
38
+
39
+ @item_identifier_2 = item_identifier_2
40
+ @item_type_identification_code_2 = item_type_identification_code_2
41
+ @code_list_identification_code_2 = code_list_identification_code_2
42
+ @code_list_responsible_agency_code_2 = code_list_responsible_agency_code_2
43
+
44
+ @item_identifier_3 = item_identifier_3
45
+ @item_type_identification_code_3 = item_type_identification_code_3
46
+ @code_list_identification_code_3 = code_list_identification_code_3
47
+ @code_list_responsible_agency_code_3 = code_list_responsible_agency_code_3
48
+
49
+ @item_identifier_4 = item_identifier_4
50
+ @item_type_identification_code_4 = item_type_identification_code_4
51
+ @code_list_identification_code_4 = code_list_identification_code_4
52
+ @code_list_responsible_agency_code_4 = code_list_responsible_agency_code_4
53
+
54
+ @item_identifier_5 = item_identifier_5
55
+ @item_type_identification_code_5 = item_type_identification_code_5
56
+ @code_list_identification_code_5 = code_list_identification_code_5
57
+ @code_list_responsible_agency_code_5 = code_list_responsible_agency_code_5
58
+
59
+ super(tag: tag || TAG)
60
+ end
61
+
62
+ def to_json_hash
63
+ hash = {}
64
+ hash.merge!(item_identifier_1: @item_identifier_1) if @item_identifier_1
65
+ hash.merge!(item_type_identification_code_1: find_identifier(:item_type_identification_code_1)) if @item_type_identification_code_1
66
+ hash.merge!(code_list_identification_code_1: @code_list_identification_code_1) if @code_list_identification_code_1
67
+ hash.merge!(code_list_responsible_agency_code_1: find_identifier(:code_list_responsible_agency_code_1)) if @code_list_responsible_agency_code_1
68
+ hash.merge!(item_identifier_2: @item_identifier_2) if @item_identifier_2
69
+ hash.merge!(item_type_identification_code_2: find_identifier(:item_type_identification_code_2)) if @item_type_identification_code_2
70
+ hash.merge!(code_list_identification_code_2: @code_list_identification_code_2) if @code_list_identification_code_2
71
+ hash.merge!(code_list_responsible_agency_code_2: find_identifier(:code_list_responsible_agency_code_2)) if @code_list_responsible_agency_code_2
72
+ hash.merge!(item_identifier_3: @item_identifier_3) if @item_identifier_3
73
+ hash.merge!(item_type_identification_code_3: find_identifier(:item_type_identification_code_3)) if @item_type_identification_code_3
74
+ hash.merge!(code_list_identification_code_3: @code_list_identification_code_3) if @code_list_identification_code_3
75
+ hash.merge!(code_list_responsible_agency_code_3: find_identifier(:code_list_responsible_agency_code_3)) if @code_list_responsible_agency_code_3
76
+ hash.merge!(item_identifier_4: @item_identifier_4) if @item_identifier_4
77
+ hash.merge!(item_type_identification_code_4: find_identifier(:item_type_identification_code_4)) if @item_type_identification_code_4
78
+ hash.merge!(code_list_identification_code_4: @code_list_identification_code_4) if @code_list_identification_code_4
79
+ hash.merge!(code_list_responsible_agency_code_4: find_identifier(:code_list_responsible_agency_code_4)) if @code_list_responsible_agency_code_4
80
+ hash.merge!(item_identifier_5: @item_identifier_5) if @item_identifier_5
81
+ hash.merge!(item_type_identification_code_5: find_identifier(:item_type_identification_code_5)) if @item_type_identification_code_5
82
+ hash.merge!(code_list_identification_code_5: @code_list_identification_code_5) if @code_list_identification_code_5
83
+ hash.merge!(code_list_responsible_agency_code_5: find_identifier(:code_list_responsible_agency_code_5)) if @code_list_responsible_agency_code_5
84
+
85
+ outer_hash = {}
86
+ outer_hash[find_identifier(:product_identifier_code_qualifier)] = hash
87
+ outer_hash
88
+ end
89
+
90
+ def group_name
91
+ 'additional_product_id'
92
+ end
93
+
94
+ def segment_type
95
+ TYPE
96
+ end
97
+
98
+ private
99
+
100
+ def identifier
101
+ @identifier ||= structure.find(:product_identifier_code_qualifier).dictionary[@product_identifier_code_qualifier][:identifier]
102
+ end
103
+
104
+
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,54 @@
1
+ module Eancom
2
+ module Edifact
3
+ class PRI < Segment
4
+ TAG = 'PRI'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+
12
+ price_code_qualifier:,
13
+ price_amount:,
14
+ price_type_code: nil,
15
+ price_specification_code: nil,
16
+ unit_price_basis_value: nil,
17
+ measurment_unit_code: nil,
18
+ subline_item_price_change_operation_code: nil
19
+ )
20
+ @tag = tag
21
+
22
+ @price_code_qualifier = price_code_qualifier
23
+ @price_amount = price_amount
24
+ @price_type_code = price_type_code
25
+ @price_specification_code = price_specification_code
26
+ @unit_price_basis_value = unit_price_basis_value
27
+ @measurment_unit_code = measurment_unit_code
28
+ @subline_item_price_change_operation_code = subline_item_price_change_operation_code
29
+
30
+ super(tag: tag || TAG)
31
+ end
32
+
33
+ def to_json_hash
34
+ hash = {}
35
+ hash.merge!(price_code_qualifier: find_identifier(:price_code_qualifier)) if @price_code_qualifier
36
+ hash.merge!(price_amount: @price_amount) if @price_amount
37
+ hash.merge!(price_type_code: find_identifier(:price_type_code)) if @price_type_code
38
+ hash.merge!(price_specification_code: find_identifier(:price_specification_code)) if @price_specification_code
39
+ hash.merge!(unit_price_basis_value: @unit_price_basis_value) if @unit_price_basis_value
40
+ hash.merge!(measurment_unit_code: find_identifier(:measurment_unit_code)) if @measurment_unit_code
41
+ { price: hash }
42
+ end
43
+
44
+ def group_name
45
+ 'prices'
46
+ end
47
+
48
+ def segment_type
49
+ TYPE
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,40 @@
1
+ module Eancom
2
+ module Edifact
3
+ class QTY < Segment
4
+ TAG = 'QTY'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ def initialize(
8
+ tag: nil,
9
+ quantity_type_code_qualifier:,
10
+ quantity:,
11
+ measurement_unit_code: nil
12
+ )
13
+ @tag = tag
14
+ @quantity_type_code_qualifier = quantity_type_code_qualifier
15
+ @quantity = quantity
16
+ @measurement_unit_code = measurement_unit_code
17
+
18
+ super(tag: tag || TAG)
19
+ end
20
+
21
+ def to_json_hash
22
+ {
23
+ identifier => {
24
+ quantity: @quantity
25
+ }
26
+ }
27
+ end
28
+
29
+ def segment_type
30
+ TYPE
31
+ end
32
+
33
+ private
34
+
35
+ def identifier
36
+ @identifier ||= structure.find(:quantity_type_code_qualifier).dictionary[@quantity_type_code_qualifier][:identifier]
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,41 @@
1
+ module Eancom
2
+ module Edifact
3
+ class RFF < Segment
4
+ TAG = 'RFF'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ def initialize(
8
+ tag: nil,
9
+ reference_code_qualifier:,
10
+ reference_identifier: nil,
11
+ document_line_identifier: nil
12
+ )
13
+ @tag = tag
14
+ @reference_code_qualifier = reference_code_qualifier
15
+ @reference_identifier = reference_identifier
16
+ @document_line_identifier = document_line_identifier
17
+
18
+ super(tag: @tag || TAG)
19
+ end
20
+
21
+ def to_json_hash
22
+ {
23
+ identifier => {
24
+ reference_identifier: @reference_identifier
25
+ }
26
+ }
27
+ end
28
+
29
+ def segment_type
30
+ TYPE
31
+ end
32
+
33
+ private
34
+
35
+ def identifier
36
+ @identifier ||= structure.find(:reference_code_qualifier).dictionary[@reference_code_qualifier][:identifier]
37
+ end
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,72 @@
1
+ module Eancom
2
+ module Edifact
3
+ class TAX < Segment
4
+ TAG = 'TAX'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ duty_or_tax_or_fee_function_code_qualifier:,
12
+ duty_or_tax_or_fee_name_code:,
13
+ code_list_identification_code_1: nil,
14
+ code_list_responsibility_agency_code_1: nil,
15
+ duty_or_tax_or_fee_type_name: nil,
16
+ duty_or_tax_or_fee_account_code: nil,
17
+ code_list_identification_code_2: nil,
18
+ code_list_responsibility_agency_code_2: nil,
19
+ duty_or_tax_of_fee_assessment_basis_value: nil,
20
+ duty_tax_fee_rate_code: nil,
21
+ code_list_identification_code_3: nil,
22
+ code_list_responsibility_agency_code_3: nil,
23
+ duty_or_tax_or_fee_rate: nil,
24
+ duty_or_tax_or_fee_basis_code: nil,
25
+ code_list_identification_code_4: nil,
26
+ code_list_responsibility_agency_code_4: nil,
27
+ duty_or_tax_or_fee_category_code: nil
28
+ )
29
+ @tag = tag
30
+ @duty_or_tax_or_fee_function_code_qualifier = duty_or_tax_or_fee_function_code_qualifier
31
+ @duty_or_tax_or_fee_name_code = duty_or_tax_or_fee_name_code
32
+ @code_list_identification_code_1 = code_list_identification_code_1
33
+ @code_list_responsibility_agency_code_1 = code_list_responsibility_agency_code_1
34
+ @duty_or_tax_or_fee_type_name = duty_or_tax_or_fee_type_name
35
+ @duty_or_tax_or_fee_account_code = duty_or_tax_or_fee_account_code
36
+ @code_list_identification_code_2 = code_list_identification_code_2
37
+ @code_list_responsibility_agency_code_2 = code_list_responsibility_agency_code_2
38
+ @duty_or_tax_of_fee_assessment_basis_value = duty_or_tax_of_fee_assessment_basis_value
39
+ @duty_tax_fee_rate_code = duty_tax_fee_rate_code
40
+ @code_list_identification_code_3 = code_list_identification_code_3
41
+ @code_list_responsibility_agency_code_3 = code_list_responsibility_agency_code_3
42
+ @duty_or_tax_or_fee_rate = duty_or_tax_or_fee_rate
43
+ @duty_or_tax_or_fee_basis_code = duty_or_tax_or_fee_basis_code
44
+ @code_list_identification_code_4 = code_list_identification_code_4
45
+ @code_list_responsibility_agency_code_4 = code_list_responsibility_agency_code_4
46
+ @duty_or_tax_or_fee_category_code = duty_or_tax_or_fee_category_code
47
+
48
+ super(tag: tag || TAG)
49
+ end
50
+
51
+ def to_json_hash
52
+ hash = {}
53
+ hash.merge!(duty_or_tax_or_fee_name_code: find_identifier(:duty_or_tax_or_fee_name_code)) if @duty_or_tax_or_fee_name_code
54
+ hash.merge!(duty_or_tax_or_fee_rate: @duty_or_tax_or_fee_rate) if @duty_or_tax_or_fee_rate
55
+ hash.merge!(duty_or_tax_or_fee_category_code: find_identifier(:duty_or_tax_or_fee_category_code)) if @duty_or_tax_or_fee_category_code
56
+ outer_hash = {}
57
+ identifier = find_identifier(:duty_or_tax_or_fee_function_code_qualifier)
58
+ outer_hash[identifier] = hash
59
+ outer_hash
60
+ end
61
+
62
+ def group_name
63
+ 'taxes'
64
+ end
65
+
66
+ def segment_type
67
+ TYPE
68
+ end
69
+
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,54 @@
1
+ module Eancom
2
+ module Edifact
3
+ class TDT < Segment
4
+ TAG = 'TDT'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ def initialize(
8
+ tag: nil,
9
+ transport_stage_code_qualifier:,
10
+ means_of_transport_journey_identifier: nil,
11
+ transport_mode_name_code:,
12
+ transport_means_description_code: nil,
13
+ transport_means_description: nil,
14
+ carrier_identifier: nil,
15
+ code_list_identification_code_1: nil,
16
+ code_list_responsible_agency_1: nil,
17
+ carrier_name: nil,
18
+ transit_direction_identicator_code: nil,
19
+ transport_means_identification_name_identifier: nil,
20
+ code_list_identification_code_2: nil,
21
+ code_list_responsible_agency_2: nil,
22
+ transport_means_identification_name: nil,
23
+ transport_means_nationality_code: nil
24
+ )
25
+ @tag = tag
26
+ @transport_stage_code_qualifier = transport_stage_code_qualifier
27
+ @means_of_transport_journey_identifier = means_of_transport_journey_identifier
28
+ @transport_mode_name_code = transport_mode_name_code
29
+ @transport_means_description_code = transport_means_description_code
30
+ @transport_means_description = transport_means_description
31
+ @carrier_identifier = carrier_identifier
32
+ @code_list_identification_code_1 = code_list_identification_code_1
33
+ @code_list_responsible_agency_1 = code_list_responsible_agency_1
34
+ @carrier_name = carrier_name
35
+ @transit_direction_identicator_code = transit_direction_identicator_code
36
+ @transport_means_identification_name_identifier = transport_means_identification_name_identifier
37
+ @code_list_identification_code_2 = code_list_identification_code_2
38
+ @code_list_responsible_agency_2 = code_list_responsible_agency_2
39
+ @transport_means_identification_name = transport_means_identification_name
40
+ @transport_means_nationality_code = transport_means_nationality_code
41
+
42
+ super(tag: tag || TAG)
43
+ end
44
+
45
+ def to_json_hash
46
+ {}
47
+ end
48
+
49
+ def segment_type
50
+ TYPE
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,51 @@
1
+ module Eancom
2
+ module Edifact
3
+ class UNA < Segment
4
+ TAG = 'UNA'.freeze
5
+ TYPE = :header.freeze
6
+
7
+ attr_reader :tag, :una1, :una2, :una3, :una4, :una5, :una6
8
+
9
+ def initialize(tag: nil,
10
+ una1: ':',
11
+ una2: '+',
12
+ una3: '.',
13
+ una4: '?',
14
+ una5: ' ',
15
+ una6: '\''
16
+ )
17
+ @tag = tag
18
+ @una1 = una1
19
+ @una2 = una2
20
+ @una3 = una3
21
+ @una4 = una4
22
+ @una5 = una5
23
+ @una6 = una6
24
+
25
+ super(tag: (tag || TAG))
26
+ end
27
+
28
+
29
+ def to_s
30
+ stream = ""
31
+ stream << tag
32
+ stream << una1
33
+ stream << una2
34
+ stream << una3
35
+ stream << una4
36
+ stream << una5
37
+ stream << una6
38
+ stream
39
+ end
40
+
41
+ def to_json_hash
42
+ {}
43
+ end
44
+
45
+ def segment_type
46
+ TYPE
47
+ end
48
+
49
+ end
50
+ end
51
+ end