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
@@ -0,0 +1,45 @@
1
+ module Eancom
2
+ module Edifact
3
+ class GIN < Segment
4
+ TAG = 'GIN'.freeze
5
+ TYPE = :body.freeze
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ object_identification_code_qualifier:,
12
+ object_identifier_1: nil,
13
+ object_identifier_2: nil,
14
+ object_identifier_3: nil,
15
+ object_identifier_4: nil,
16
+ object_identifier_5: nil
17
+ )
18
+ @tag = tag
19
+ @object_identification_code_qualifier = object_identification_code_qualifier
20
+ @object_identifier_1 = object_identifier_1
21
+ @object_identifier_2 = object_identifier_2
22
+ @object_identifier_3 = object_identifier_3
23
+ @object_identifier_4 = object_identifier_4
24
+ @object_identifier_5 = object_identifier_5
25
+
26
+ super(tag: @tag || TAG)
27
+ end
28
+
29
+ def to_json_hash
30
+ hash = {}
31
+ hash.merge!(object_identification_code_qualifier: @object_identification_code_qualifier) if @object_identification_code_qualifier
32
+ hash.merge!(object_identifier_1: @object_identifier_1) if @object_identifier_1
33
+ hash.merge!(object_identifier_2: @object_identifier_2) if @object_identifier_2
34
+ hash.merge!(object_identifier_3: @object_identifier_3) if @object_identifier_3
35
+ hash.merge!(object_identifier_4: @object_identifier_4) if @object_identifier_4
36
+ hash.merge!(object_identifier_5: @object_identifier_5) if @object_identifier_5
37
+ hash
38
+ end
39
+
40
+ def segment_type
41
+ TYPE
42
+ end
43
+ end
44
+ end
45
+ end
@@ -38,7 +38,7 @@ module Eancom
38
38
  hash = {}
39
39
  hash.merge!(description_format_code: find_identifier(:description_format_code)) if @description_format_code
40
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
41
+ hash.merge!(code_list_identification_code: find_identifier(:code_list_identification_code)) if @code_list_identification_code
42
42
  hash.merge!(code_list_responsible_agency_code: find_identifier(:code_list_responsible_agency_code)) if @code_list_responsible_agency_code
43
43
  if @item_description_code
44
44
  identifier = find_identifier(:item_description_code)
@@ -0,0 +1,43 @@
1
+ module Eancom
2
+ module Edifact
3
+ class INV < Segment
4
+ TAG = 'INV'.freeze
5
+ TYPE = :body
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ inventory_movement_direction_code:,
12
+ inventory_type_code: nil,
13
+ inventory_movement_reason_code: nil,
14
+ inventory_balance_method_code: nil
15
+ )
16
+
17
+ @tag = tag
18
+ @inventory_movement_direction_code = inventory_movement_direction_code
19
+ @inventory_type_code = inventory_type_code
20
+ @inventory_movement_reason_code = inventory_movement_reason_code
21
+ @inventory_balance_method_code = inventory_balance_method_code
22
+ super(tag: tag || TAG)
23
+ end
24
+
25
+ def to_json_hash
26
+ hash = {}
27
+ hash.merge!(inventory_movement_direction_code: find_identifier(:inventory_movement_direction_code)) if @inventory_movement_direction_code
28
+ hash.merge!(inventory_type_code: @inventory_type_code) if @inventory_type_code
29
+ hash.merge!(inventory_movement_reason_code: @inventory_movement_reason_code) if @inventory_movement_reason_code
30
+ hash.merge!(inventory_balance_method_code: @inventory_balance_method_code) if @inventory_balance_method_code
31
+ hash
32
+ end
33
+
34
+ def group_name
35
+ 'inventory'
36
+ end
37
+
38
+ def segment_type
39
+ TYPE
40
+ end
41
+ end
42
+ end
43
+ end
@@ -29,10 +29,13 @@ module Eancom
29
29
  end
30
30
 
31
31
  def to_json_hash
32
- {
33
- line_item_identifier_1: @line_item_identifier_1,
34
- ean: @item_identifier
35
- }
32
+ hash = {}
33
+ hash.merge!(ean: @item_identifier) if @item_identifier
34
+ hash.merge!(action_request_notification_description_code: @action_request_notification_description_code) if @action_request_notification_description_code
35
+ hash.merge!(item_type_identification_code: find_identifier(:item_type_identification_code)) if @item_type_identification_code
36
+ hash.merge!(sub_line_indicator_code: @sub_line_indicator_code) if @sub_line_indicator_code
37
+ hash.merge!(line_item_identifier_2: @line_item_identifier_2) if @line_item_identifier_2
38
+ hash
36
39
  end
37
40
 
38
41
  def segment_type
@@ -9,15 +9,17 @@ module Eancom
9
9
  def initialize(
10
10
  tag: nil,
11
11
  location_function_qualifier:,
12
- location_name_code:,
12
+ location_name_code: nil,
13
+ first_related_name_code: nil,
13
14
  code_list_identification_code: nil,
14
- code_list_responsible_agancy_code: nil
15
+ code_list_responsible_agency_code: nil
15
16
  )
16
17
  @tag = tag
17
18
  @location_function_qualifier = location_function_qualifier
18
19
  @location_name_code = location_name_code
20
+ @first_related_name_code = first_related_name_code
19
21
  @code_list_identification_code = code_list_identification_code
20
- @code_list_responsible_agancy_code = code_list_responsible_agancy_code
22
+ @code_list_responsible_agency_code = code_list_responsible_agency_code
21
23
 
22
24
  super(tag: tag || TAG)
23
25
  end
@@ -26,18 +28,15 @@ module Eancom
26
28
  hash = {}
27
29
  hash.merge!(location_function_qualifier: find_identifier(:location_function_qualifier)) if @location_function_qualifier
28
30
  hash.merge!(location_name_code: @location_name_code) if @location_name_code
31
+ hash.merge!(first_related_name_code: @first_related_name_code) if @first_related_name_code
29
32
  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
33
+ hash.merge!(code_list_responsible_agency_code: find_identifier(:code_list_responsible_agency_code)) if @code_list_responsible_agency_code
31
34
  hash
32
35
  outer_hash = {}
33
- outer_hash.merge!({ location: hash})
36
+ outer_hash.merge!({ location: hash })
34
37
  outer_hash
35
38
  end
36
39
 
37
- def starts_location?
38
- true
39
- end
40
-
41
40
  def segment_type
42
41
  TYPE
43
42
  end
@@ -34,6 +34,7 @@ module Eancom
34
34
  hash.merge!(measurement_purpose_code_qualifier: find_identifier(:measurement_purpose_code_qualifier)) if @measurement_purpose_code_qualifier
35
35
  hash.merge!(measured_attribute_code: find_identifier(:measured_attribute_code)) if @measured_attribute_code
36
36
  hash.merge!(measurement_significance_code: find_identifier(:measurement_significance_code)) if @measurement_significance_code
37
+ hash.merge!(measurment_unit_code: find_identifier(:measurment_unit_code)) if @measurment_unit_code
37
38
  hash.merge!(measurement_value: @measurement_value) if @measurement_value
38
39
  hash.merge!(range_minimum_value: @range_minimum_value) if @range_minimum_value
39
40
  hash.merge!(range_maximum_value: @range_maximum_value) if @range_maximum_value
@@ -2,14 +2,14 @@ module Eancom
2
2
  module Edifact
3
3
  class MOA < Segment
4
4
  TAG = 'MOA'.freeze
5
- TYPE = :body.freeze
5
+ TYPE = :footer.freeze
6
6
 
7
7
  attr_reader :segment_type
8
8
 
9
9
  def initialize(
10
10
  tag: nil,
11
11
  monetary_amount_type_code_qualifier:,
12
- monetary_amount:,
12
+ monetary_amount: nil,
13
13
  currency_identification_code: nil,
14
14
  currency_type_code_qualifier: nil
15
15
  )
@@ -28,7 +28,7 @@ module Eancom
28
28
  hash.merge!(monetary_amount_type_code_qualifier: find_identifier(:monetary_amount_type_code_qualifier)) if @monetary_amount_type_code_qualifier
29
29
  hash.merge!(monetary_amount: @monetary_amount) if @monetary_amount
30
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
31
+ hash.merge!(currency_type_code_qualifier: find_identifier(:currency_type_code_qualifier)) if @currency_type_code_qualifier
32
32
  hash
33
33
  end
34
34
 
@@ -9,7 +9,7 @@ module Eancom
9
9
  party_function_code_qualifier:,
10
10
  party_identifier:,
11
11
  code_list_identification_code_1: '',
12
- code_list_responsible_agancy_code_1:,
12
+ code_list_responsible_agency_code_1: nil,
13
13
  name_and_address_description_1: nil,
14
14
  name_and_address_description_2: nil,
15
15
  name_and_address_description_3: nil,
@@ -28,7 +28,7 @@ module Eancom
28
28
  city_name: nil,
29
29
  country_sub_entity_name_code: nil,
30
30
  code_list_identification_code_2: nil,
31
- code_list_responsible_agancy_code_2: nil,
31
+ code_list_responsible_agency_code_2: nil,
32
32
  country_sub_entry_name: nil,
33
33
  postal_identification_code: nil,
34
34
  country_name_code: nil
@@ -37,7 +37,7 @@ module Eancom
37
37
  @party_function_code_qualifier = party_function_code_qualifier
38
38
  @party_identifier = party_identifier
39
39
  @code_list_identification_code_1 = code_list_identification_code_1
40
- @code_list_responsible_agancy_code_1 = code_list_responsible_agancy_code_1
40
+ @code_list_responsible_agency_code_1 = code_list_responsible_agency_code_1
41
41
  @name_and_address_description_1 = name_and_address_description_1
42
42
  @name_and_address_description_2 = name_and_address_description_2
43
43
  @name_and_address_description_3 = name_and_address_description_3
@@ -55,8 +55,8 @@ module Eancom
55
55
  @street_and_number_5 = street_and_number_5
56
56
  @city_name = city_name
57
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
58
+ @code_list_responsible_agency_code_2 = code_list_identification_code_2
59
+ @code_list_responsible_agency_code_2 = code_list_responsible_agency_code_2
60
60
  @country_sub_entry_name = country_sub_entry_name
61
61
  @postal_identification_code = postal_identification_code
62
62
  @country_name_code = country_name_code
@@ -66,7 +66,6 @@ module Eancom
66
66
  def to_json_hash
67
67
  hash = { identifier => {} }
68
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
69
  hash[identifier].merge!({ name_and_address_description_1: @name_and_address_description_1 }) if @name_and_address_description_1
71
70
  hash[identifier].merge!({ name_and_address_description_2: @name_and_address_description_2 }) if @name_and_address_description_2
72
71
  hash[identifier].merge!({ name_and_address_description_3: @name_and_address_description_3 }) if @name_and_address_description_3
@@ -88,14 +87,20 @@ module Eancom
88
87
  hash[identifier].merge!({ postal_identification_code: @postal_identification_code }) if @postal_identification_code
89
88
  hash[identifier].merge!({ country_name_code: @country_name_code }) if @country_name_code
90
89
 
90
+ hash.merge!({ identifier: @identifier }) if @identifier
91
91
  hash = {} if hash[identifier].empty?
92
92
  hash
93
+
93
94
  end
94
95
 
95
96
  def segment_type
96
97
  TYPE
97
98
  end
98
99
 
100
+ def group_name
101
+ 'nads'
102
+ end
103
+
99
104
  private
100
105
 
101
106
  def identifier
@@ -43,7 +43,9 @@ module Eancom
43
43
  end
44
44
 
45
45
  def to_json_hash
46
- {}
46
+ hash = {}
47
+ hash.merge!(package_quantity: @package_quantity) if @package_quantity
48
+ hash
47
49
  end
48
50
 
49
51
  def segment_type
@@ -0,0 +1,37 @@
1
+ module Eancom
2
+ module Edifact
3
+ class PAT < Segment
4
+ TAG = 'PAT'.freeze
5
+ TYPE = :header
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ payment_terms_type_code_qualifier: nil,
12
+ payment_terms_type_description_identifier: nil,
13
+ time_reference_code: nil
14
+ )
15
+
16
+ @tag = tag,
17
+ @payment_terms_type_code_qualifier = payment_terms_type_code_qualifier,
18
+ @payment_terms_type_description_identifier = payment_terms_type_description_identifier,
19
+ @time_reference_code = time_reference_code
20
+
21
+ super(tag: tag || TAG)
22
+ end
23
+
24
+ def to_json_hash
25
+ hash = {}
26
+ hash.merge!(payment_terms_type_code_qualifier: find_identifier(:payment_terms_type_code_qualifier)) if @payment_terms_type_code_qualifier
27
+ hash.merge!(payment_terms_type_description_identifier: @payment_terms_type_description_identifier) if @payment_terms_type_description_identifier
28
+ hash.merge!(time_reference_code: @time_reference_code) if @time_reference_code
29
+ hash
30
+ end
31
+
32
+ def segment_type
33
+ TYPE
34
+ end
35
+ end
36
+ end
37
+ end
@@ -2,43 +2,32 @@ module Eancom
2
2
  module Edifact
3
3
  class PCD < Segment
4
4
  TAG = 'PCD'.freeze
5
- TYPE = :body.freeze
5
+ TYPE = :header
6
6
 
7
7
  attr_reader :segment_type
8
8
 
9
9
  def initialize(
10
10
  tag: nil,
11
- percentage_type_code_qualifier:,
12
11
  percentage:,
13
- code_list_identification_code: nil,
14
- code_list_responsibility_agency_code: nil
12
+ percentage_type_code_qualifier: nil
15
13
  )
16
14
  @tag = tag
17
15
  @percentage_type_code_qualifier = percentage_type_code_qualifier
18
16
  @percentage = percentage
19
- @code_list_identification_code = code_list_identification_code
20
- @code_list_responsibility_agency_code = code_list_responsibility_agency_code
21
17
 
22
18
  super(tag: tag || TAG)
23
19
  end
24
20
 
25
21
  def to_json_hash
26
- hash = {
27
- 'percentage_type_code_qualifier': percentage_type,
28
- 'percentage': percentage
29
- }
22
+ hash = {}
23
+ hash.merge!(percentage_type_code_qualifier: find_identifier(:percentage_type_code_qualifier)) if @percentage_type_code_qualifier
24
+ hash.merge!(percentage: @percentage) if @percentage
25
+ hash
30
26
  end
31
27
 
32
28
  def segment_type
33
29
  TYPE
34
30
  end
35
-
36
- private
37
-
38
- def percentage_type
39
- @percentage_type ||= find_identifier(:percentage_type_code_qualifier)
40
- end
41
-
42
31
  end
43
32
  end
44
33
  end
@@ -0,0 +1,40 @@
1
+ module Eancom
2
+ module Edifact
3
+ class PCI < Segment
4
+ TAG = 'PCI'.freeze
5
+ TYPE = :body
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ marking_instructions_code:,
12
+ marks_and_labels_code: nil,
13
+ container_or_package_contents_indicator_mode: nil
14
+ )
15
+
16
+ @tag = tag
17
+ @marking_instructions_code = marking_instructions_code
18
+ @marks_and_labels_code = marks_and_labels_code
19
+ @container_or_package_contents_indicator_mode = container_or_package_contents_indicator_mode
20
+ super(tag: tag || TAG)
21
+ end
22
+
23
+ def to_json_hash
24
+ hash = {}
25
+ hash.merge!(marking_instructions_code: find_identifier(:marking_instructions_code)) if @marking_instructions_code
26
+ hash.merge!(marks_and_labels_code: @marks_and_labels_code) if @marks_and_labels_code
27
+ hash.merge!(container_or_package_contents_indicator_mode: @container_or_package_contents_indicator_mode) if @container_or_package_contents_indicator_mode
28
+ hash
29
+ end
30
+
31
+ def group_name
32
+ 'package_identification'
33
+ end
34
+
35
+ def segment_type
36
+ TYPE
37
+ end
38
+ end
39
+ end
40
+ end
@@ -61,6 +61,7 @@ module Eancom
61
61
 
62
62
  def to_json_hash
63
63
  hash = {}
64
+ hash.merge!(product_identifier_code_qualifier: find_identifier(:product_identifier_code_qualifier)) if @product_identifier_code_qualifier
64
65
  hash.merge!(item_identifier_1: @item_identifier_1) if @item_identifier_1
65
66
  hash.merge!(item_type_identification_code_1: find_identifier(:item_type_identification_code_1)) if @item_type_identification_code_1
66
67
  hash.merge!(code_list_identification_code_1: @code_list_identification_code_1) if @code_list_identification_code_1
@@ -8,7 +8,6 @@ module Eancom
8
8
 
9
9
  def initialize(
10
10
  tag: nil,
11
-
12
11
  price_code_qualifier:,
13
12
  price_amount:,
14
13
  price_type_code: nil,
@@ -19,11 +19,15 @@ module Eancom
19
19
  end
20
20
 
21
21
  def to_json_hash
22
- {
23
- identifier => {
24
- quantity: @quantity
25
- }
26
- }
22
+ hash = { identifier => {} }
23
+ hash[identifier].merge!({ quantity: @quantity }) if @quantity
24
+ hash.merge!(measurement_unit_code: find_identifier(:measurement_unit_code)) if @measurement_unit_code
25
+ hash.merge!(identifier: @identifier) if @identifier
26
+ hash
27
+ end
28
+
29
+ def group_name
30
+ 'quantities'
27
31
  end
28
32
 
29
33
  def segment_type
@@ -21,11 +21,17 @@ module Eancom
21
21
  def to_json_hash
22
22
  {
23
23
  identifier => {
24
- reference_identifier: @reference_identifier
25
- }
24
+ reference_identifier: @reference_identifier,
25
+ document_line_identifier: @document_line_identifier
26
+ },
27
+ identifier: @identifier
26
28
  }
27
29
  end
28
30
 
31
+ def group_name
32
+ 'references'
33
+ end
34
+
29
35
  def segment_type
30
36
  TYPE
31
37
  end
@@ -0,0 +1,33 @@
1
+ module Eancom
2
+ module Edifact
3
+ class RTE < Segment
4
+ TAG = 'RTE'.freeze
5
+ TYPE = :header
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ rate_type_code_qualifier: nil,
12
+ unit_price_basis_rate: nil
13
+ )
14
+ @tag = tag
15
+ @rate_type_code_qualifier = rate_type_code_qualifier
16
+ @unit_price_basis_rate = unit_price_basis_rate
17
+
18
+ super(tag: tag || TAG)
19
+ end
20
+
21
+ def to_json_hash
22
+ hash = {}
23
+ hash.merge!(rate_type_code_qualifier: find_identifier(:rate_type_code_qualifier)) if @rate_type_code_qualifier
24
+ hash.merge!(unit_price_basis_rate: @unit_price_basis_rate) if @unit_price_basis_rate
25
+ hash
26
+ end
27
+
28
+ def segment_type
29
+ TYPE
30
+ end
31
+ end
32
+ end
33
+ end
@@ -9,7 +9,7 @@ module Eancom
9
9
  def initialize(
10
10
  tag: nil,
11
11
  duty_or_tax_or_fee_function_code_qualifier:,
12
- duty_or_tax_or_fee_name_code:,
12
+ duty_or_tax_or_fee_name_code: nil,
13
13
  code_list_identification_code_1: nil,
14
14
  code_list_responsibility_agency_code_1: nil,
15
15
  duty_or_tax_or_fee_type_name: nil,
@@ -50,8 +50,14 @@ module Eancom
50
50
 
51
51
  def to_json_hash
52
52
  hash = {}
53
+ hash.merge!(duty_or_tax_or_fee_function_code_qualifier: find_identifier(:duty_or_tax_or_fee_function_code_qualifier)) if @duty_or_tax_or_fee_function_code_qualifier
53
54
  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
55
+ hash.merge!(duty_or_tax_or_fee_account_code: @duty_or_tax_or_fee_account_code) if @duty_or_tax_or_fee_account_code
56
+ hash.merge!(duty_tax_fee_rate_code: @duty_tax_fee_rate_code) if @duty_tax_fee_rate_code
54
57
  hash.merge!(duty_or_tax_or_fee_rate: @duty_or_tax_or_fee_rate) if @duty_or_tax_or_fee_rate
58
+ hash.merge!(code_list_identification_code_3: @code_list_identification_code_3) if @code_list_identification_code_3
59
+ hash.merge!(code_list_responsibility_agency_code_3: @code_list_responsibility_agency_code_3) if @code_list_responsibility_agency_code_3
60
+ hash.merge!(code_list_responsibility_agency_code_4: @code_list_responsibility_agency_code_4) if @code_list_responsibility_agency_code_4
55
61
  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
62
  outer_hash = {}
57
63
  identifier = find_identifier(:duty_or_tax_or_fee_function_code_qualifier)
@@ -43,7 +43,10 @@ module Eancom
43
43
  end
44
44
 
45
45
  def to_json_hash
46
- {}
46
+ hash = {}
47
+ hash.merge!(transport_stage_code_qualifier: find_identifier(:transport_stage_code_qualifier)) if @transport_stage_code_qualifier
48
+ hash.merge!(transport_mode_name_code: find_identifier(:transport_mode_name_code)) if @transport_mode_name_code
49
+ hash
47
50
  end
48
51
 
49
52
  def segment_type
@@ -0,0 +1,33 @@
1
+ module Eancom
2
+ module Edifact
3
+ class TOD < Segment
4
+ TAG = 'TOD'.freeze
5
+ TYPE = :header
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ delivery_or_transport_terms_function_code: nil,
12
+ delivery_or_transport_terms_description_code: nil
13
+ )
14
+ @tag = tag
15
+ @delivery_or_transport_terms_function_code = delivery_or_transport_terms_function_code
16
+ @delivery_or_transport_terms_description_code = delivery_or_transport_terms_description_code
17
+
18
+ super(tag: tag || TAG)
19
+ end
20
+
21
+ def to_json_hash
22
+ hash = {}
23
+ hash.merge!(delivery_or_transport_terms_function_code: @delivery_or_transport_terms_function_code) if @delivery_or_transport_terms_function_code
24
+ hash.merge!(delivery_or_transport_terms_description_code: @delivery_or_transport_terms_description_code) if @delivery_or_transport_terms_description_code
25
+ hash
26
+ end
27
+
28
+ def segment_type
29
+ TYPE
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,31 @@
1
+ module Eancom
2
+ module Edifact
3
+ class TRU < Segment
4
+ TAG = 'TRU'.freeze
5
+ TYPE = :body
6
+
7
+ attr_reader :segment_type
8
+
9
+ def initialize(
10
+ tag: nil,
11
+ object_identifier:
12
+ )
13
+
14
+ @tag = tag
15
+ @object_identifier = object_identifier
16
+
17
+ super(tag: tag || TAG)
18
+ end
19
+
20
+ def to_json_hash
21
+ hash = {}
22
+ hash.merge!(object_identifier: @object_identifier)
23
+ hash
24
+ end
25
+
26
+ def segment_type
27
+ TYPE
28
+ end
29
+ end
30
+ end
31
+ end
@@ -12,7 +12,8 @@ module Eancom
12
12
  una3: '.',
13
13
  una4: '?',
14
14
  una5: ' ',
15
- una6: '\''
15
+ una6: '\'',
16
+ **kwargs
16
17
  )
17
18
  @tag = tag
18
19
  @una1 = una1
@@ -47,16 +47,15 @@ module Eancom
47
47
  end
48
48
 
49
49
  def to_json_hash
50
- hash = {
50
+ {
51
51
  interchange_sender_identification: @interchange_sender_identification,
52
52
  interchange_recipient_identification: @interchange_recipient_identification,
53
53
  date: @date,
54
54
  time: @time,
55
- interchange_control_reference: @interchange_control_reference
55
+ interchange_control_reference: @interchange_control_reference,
56
+ application_reference: @application_reference,
57
+ interchange_agreement_identifier: @interchange_agreement_identifier
56
58
  }
57
-
58
- hash.merge!(sender_identifiction_code_qualifier: @sender_identifiction_code_qualifier) if @sender_identifiction_code_qualifier
59
- hash.merge!(recipient_identifiction_code_qualifier: @recipient_identifiction_code_qualifier) if @recipient_identifiction_code_qualifier
60
59
  end
61
60
 
62
61
  def segment_type
@@ -11,7 +11,7 @@ module Eancom
11
11
  message_version_number:,
12
12
  message_release_number:,
13
13
  controlling_agency:,
14
- association_assigned_code: nil,
14
+ association_assigned_code:,
15
15
  code_list_directory_version_number: nil
16
16
  )
17
17
 
@@ -26,6 +26,10 @@ module Eancom
26
26
  super(tag: tag || TAG)
27
27
  end
28
28
 
29
+ '''
30
+ Changing this to_json_hash function throws unusualy many errors.
31
+ Discuss whether or not this hash function needs to be changed.
32
+ '''
29
33
  def to_json_hash
30
34
  hash = {
31
35
  message_reference_number: @message_reference_number,
@@ -33,10 +37,8 @@ module Eancom
33
37
  message_version_number: @message_version_number,
34
38
  message_release_number: @message_release_number,
35
39
  controlling_agency: @controlling_agency,
40
+ association_assigned_code: @association_assigned_code
36
41
  }
37
- hash[:association_assigned_code] = @association_assigned_code if @association_assigned_code
38
- hash[:code_list_directory_version_number] = @code_list_directory_version_number if @code_list_directory_version_number
39
- hash
40
42
  end
41
43
 
42
44
  def segment_type