eancom 1.6.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +7 -4
- data/.gitlab-ci.yml +11 -13
- data/.ruby-version +1 -1
- data/Gemfile +2 -4
- data/Gemfile.lock +21 -103
- data/README.md +46 -0
- data/definitions/desadv/d01b.rb +134 -87
- data/definitions/desadv/d96a.rb +145 -82
- data/definitions/invoic/d01b.rb +559 -0
- data/definitions/invoic/d96a.rb +389 -0
- data/definitions/invrpt/d01b.rb +134 -0
- data/definitions/invrpt/d96a.rb +125 -0
- data/definitions/orders/d01b.rb +182 -0
- data/definitions/orders/d96b.rb +198 -0
- data/definitions/ordrsp/d01b.rb +251 -0
- data/definitions/ordrsp/d96b.rb +226 -0
- data/definitions/pricat/d01b.rb +225 -0
- data/definitions/pricat/d96b.rb +207 -0
- data/definitions/retann/d01b.rb +172 -0
- data/definitions/retann/d96b.rb +221 -0
- data/definitions/segments/ajt.rb +47 -0
- data/definitions/segments/alc.rb +128 -36
- data/definitions/segments/bgm.rb +122 -2
- data/definitions/segments/cdi.rb +39 -0
- data/definitions/segments/cnt.rb +4 -0
- data/definitions/segments/cta.rb +89 -0
- data/definitions/segments/cux.rb +9 -2
- data/definitions/segments/dgs.rb +34 -0
- data/definitions/segments/doc.rb +45 -0
- data/definitions/segments/dtm.rb +75 -20
- data/definitions/segments/efi.rb +67 -0
- data/definitions/segments/eqd.rb +37 -0
- data/definitions/segments/ftx.rb +22 -8
- data/definitions/segments/gin.rb +113 -0
- data/definitions/segments/imd.rb +9 -13
- data/definitions/segments/inv.rb +94 -0
- data/definitions/segments/lin.rb +24 -4
- data/definitions/segments/loc.rb +52 -4
- data/definitions/segments/moa.rb +86 -2
- data/definitions/segments/nad.rb +69 -9
- data/definitions/segments/pac.rb +12 -0
- data/definitions/segments/pat.rb +171 -0
- data/definitions/segments/pcd.rb +9 -92
- data/definitions/segments/pci.rb +110 -0
- data/definitions/segments/pgi.rb +7 -3
- data/definitions/segments/pia.rb +21 -29
- data/definitions/segments/pri.rb +25 -13
- data/definitions/segments/qty.rb +208 -2
- data/definitions/segments/rff.rb +49 -13
- data/definitions/segments/rte.rb +52 -0
- data/definitions/segments/tax.rb +17 -10
- data/definitions/segments/tdt.rb +24 -0
- data/definitions/segments/tod.rb +64 -0
- data/definitions/segments/tru.rb +34 -0
- data/definitions/segments/una.rb +8 -8
- data/definitions/segments/unb.rb +4 -4
- data/definitions/segments/unh.rb +70 -5
- data/definitions/segments/uns.rb +2 -2
- data/definitions/segments/unt.rb +2 -2
- data/definitions/slsrpt/d01b.rb +132 -128
- data/definitions/slsrpt/d96a.rb +132 -129
- data/eancom.gemspec +5 -8
- data/lib/eancom/edifact/body.rb +37 -18
- data/lib/eancom/edifact/document.rb +20 -16
- data/lib/eancom/edifact/footer.rb +1 -0
- data/lib/eancom/edifact/item.rb +1 -1
- data/lib/eancom/edifact/message.rb +7 -39
- data/lib/eancom/edifact/segment.rb +9 -11
- data/lib/eancom/edifact/segments/ajt.rb +32 -0
- data/lib/eancom/edifact/segments/ali.rb +2 -4
- data/lib/eancom/edifact/segments/bgm.rb +4 -3
- data/lib/eancom/edifact/segments/cdi.rb +30 -0
- data/lib/eancom/edifact/segments/cnt.rb +8 -1
- data/lib/eancom/edifact/segments/cps.rb +4 -1
- data/lib/eancom/edifact/segments/cta.rb +30 -0
- data/lib/eancom/edifact/segments/cux.rb +1 -1
- data/lib/eancom/edifact/segments/dgs.rb +31 -0
- data/lib/eancom/edifact/segments/doc.rb +30 -0
- data/lib/eancom/edifact/segments/dtm.rb +10 -6
- data/lib/eancom/edifact/segments/efi.rb +38 -0
- data/lib/eancom/edifact/segments/eqd.rb +30 -0
- data/lib/eancom/edifact/segments/ftx.rb +2 -2
- data/lib/eancom/edifact/segments/gin.rb +45 -0
- data/lib/eancom/edifact/segments/imd.rb +1 -1
- data/lib/eancom/edifact/segments/inv.rb +43 -0
- data/lib/eancom/edifact/segments/lin.rb +7 -4
- data/lib/eancom/edifact/segments/loc.rb +8 -9
- data/lib/eancom/edifact/segments/mea.rb +1 -0
- data/lib/eancom/edifact/segments/moa.rb +3 -3
- data/lib/eancom/edifact/segments/nad.rb +11 -6
- data/lib/eancom/edifact/segments/pac.rb +3 -1
- data/lib/eancom/edifact/segments/pat.rb +37 -0
- data/lib/eancom/edifact/segments/pcd.rb +6 -17
- data/lib/eancom/edifact/segments/pci.rb +40 -0
- data/lib/eancom/edifact/segments/pia.rb +1 -0
- data/lib/eancom/edifact/segments/pri.rb +0 -1
- data/lib/eancom/edifact/segments/qty.rb +9 -5
- data/lib/eancom/edifact/segments/rff.rb +8 -2
- data/lib/eancom/edifact/segments/rte.rb +33 -0
- data/lib/eancom/edifact/segments/tax.rb +7 -1
- data/lib/eancom/edifact/segments/tdt.rb +4 -1
- data/lib/eancom/edifact/segments/tod.rb +33 -0
- data/lib/eancom/edifact/segments/tru.rb +31 -0
- data/lib/eancom/edifact/segments/una.rb +2 -1
- data/lib/eancom/edifact/segments/unb.rb +4 -5
- data/lib/eancom/edifact/segments/unh.rb +6 -4
- data/lib/eancom/edifact/segments/uns.rb +4 -1
- data/lib/eancom/edifact/structure.rb +0 -1
- data/lib/eancom/edifact.rb +15 -4
- data/lib/eancom/factory.rb +1 -1
- data/lib/eancom/parser/document.rb +3 -16
- data/lib/eancom/parser/segment.rb +9 -10
- data/lib/eancom/version.rb +1 -3
- data/lib/eancom.rb +3 -1
- data/pricat.json +1 -0
- metadata +45 -51
- data/.rubocop.yml +0 -2
- data/.tool-versions +0 -1
- data/definitions/segments/qvr.rb +0 -140
- data/lib/eancom/edifact/location.rb +0 -56
- data/lib/eancom/edifact/segments/qvr.rb +0 -50
@@ -2,43 +2,32 @@ module Eancom
|
|
2
2
|
module Edifact
|
3
3
|
class PCD < Segment
|
4
4
|
TAG = 'PCD'.freeze
|
5
|
-
TYPE = :
|
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
|
-
|
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
|
-
|
28
|
-
|
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
|
@@ -19,11 +19,15 @@ module Eancom
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_json_hash
|
22
|
-
{
|
23
|
-
|
24
|
-
|
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
|
@@ -47,16 +47,15 @@ module Eancom
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def to_json_hash
|
50
|
-
|
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
|
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
|
@@ -2,7 +2,7 @@ module Eancom
|
|
2
2
|
module Edifact
|
3
3
|
class UNS < Segment
|
4
4
|
TAG = 'UNS'.freeze
|
5
|
-
TYPE = :
|
5
|
+
TYPE = :header.freeze
|
6
6
|
|
7
7
|
def initialize(
|
8
8
|
tag: nil,
|
@@ -14,6 +14,9 @@ module Eancom
|
|
14
14
|
super(tag: tag || TAG)
|
15
15
|
end
|
16
16
|
|
17
|
+
'''
|
18
|
+
Why is line 22 commented?
|
19
|
+
'''
|
17
20
|
def to_json_hash
|
18
21
|
hash = {}
|
19
22
|
# hash.merge!(section_identification: find_identifier(:section_identification)) if @section_identification
|
data/lib/eancom/edifact.rb
CHANGED
@@ -3,7 +3,6 @@ require 'eancom/edifact/segment'
|
|
3
3
|
require 'eancom/edifact/document_element'
|
4
4
|
require 'eancom/edifact/header'
|
5
5
|
require 'eancom/edifact/message'
|
6
|
-
require 'eancom/edifact/location'
|
7
6
|
require 'eancom/edifact/item'
|
8
7
|
require 'eancom/edifact/body'
|
9
8
|
require 'eancom/edifact/footer'
|
@@ -22,6 +21,18 @@ require 'eancom/edifact/segments/unt'
|
|
22
21
|
require 'eancom/edifact/segments/unz'
|
23
22
|
|
24
23
|
require 'eancom/edifact/segments/alc'
|
24
|
+
require 'eancom/edifact/segments/ajt'
|
25
|
+
require 'eancom/edifact/segments/dgs'
|
26
|
+
require 'eancom/edifact/segments/efi'
|
27
|
+
require 'eancom/edifact/segments/tru'
|
28
|
+
require 'eancom/edifact/segments/cdi'
|
29
|
+
require 'eancom/edifact/segments/gin'
|
30
|
+
require 'eancom/edifact/segments/rte'
|
31
|
+
require 'eancom/edifact/segments/pcd'
|
32
|
+
require 'eancom/edifact/segments/eqd'
|
33
|
+
require 'eancom/edifact/segments/tod'
|
34
|
+
require 'eancom/edifact/segments/pat'
|
35
|
+
require 'eancom/edifact/segments/doc'
|
25
36
|
require 'eancom/edifact/segments/ali'
|
26
37
|
require 'eancom/edifact/segments/bgm'
|
27
38
|
require 'eancom/edifact/segments/cav'
|
@@ -29,21 +40,22 @@ require 'eancom/edifact/segments/cci'
|
|
29
40
|
require 'eancom/edifact/segments/cnt'
|
30
41
|
require 'eancom/edifact/segments/cps'
|
31
42
|
require 'eancom/edifact/segments/cux'
|
43
|
+
require 'eancom/edifact/segments/cta'
|
32
44
|
require 'eancom/edifact/segments/dtm'
|
33
45
|
require 'eancom/edifact/segments/ftx'
|
34
46
|
require 'eancom/edifact/segments/imd'
|
47
|
+
require 'eancom/edifact/segments/inv'
|
35
48
|
require 'eancom/edifact/segments/lin'
|
36
49
|
require 'eancom/edifact/segments/loc'
|
37
50
|
require 'eancom/edifact/segments/mea'
|
38
51
|
require 'eancom/edifact/segments/moa'
|
39
52
|
require 'eancom/edifact/segments/nad'
|
40
53
|
require 'eancom/edifact/segments/pac'
|
54
|
+
require 'eancom/edifact/segments/pci'
|
41
55
|
require 'eancom/edifact/segments/pgi'
|
42
|
-
require 'eancom/edifact/segments/pcd'
|
43
56
|
require 'eancom/edifact/segments/pia'
|
44
57
|
require 'eancom/edifact/segments/pri'
|
45
58
|
require 'eancom/edifact/segments/qty'
|
46
|
-
require 'eancom/edifact/segments/qvr'
|
47
59
|
require 'eancom/edifact/segments/rff'
|
48
60
|
require 'eancom/edifact/segments/tax'
|
49
61
|
require 'eancom/edifact/segments/tdt'
|
@@ -52,4 +64,3 @@ module Eancom
|
|
52
64
|
module Edifact
|
53
65
|
end
|
54
66
|
end
|
55
|
-
|
data/lib/eancom/factory.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
module Eancom
|
4
2
|
module Parser
|
5
3
|
class Document
|
@@ -12,14 +10,9 @@ module Eancom
|
|
12
10
|
@document = Eancom::Edifact::Document.new
|
13
11
|
end
|
14
12
|
|
15
|
-
def parse
|
13
|
+
def parse
|
16
14
|
content.split(segment_delimiter).each do |segment_string|
|
17
15
|
segment = Parser::Segment.new(segment_string)
|
18
|
-
|
19
|
-
if header_only && segment.segment_class::TYPE != :header
|
20
|
-
next
|
21
|
-
end
|
22
|
-
|
23
16
|
segment = segment.parse
|
24
17
|
add(segment)
|
25
18
|
end
|
@@ -34,7 +27,7 @@ module Eancom
|
|
34
27
|
elsif segment.is_body?
|
35
28
|
@document.add_to_body(segment)
|
36
29
|
elsif segment.is_footer?
|
37
|
-
@document.
|
30
|
+
@document.add_to_body(segment)
|
38
31
|
else
|
39
32
|
raise SegmentTypeNotDefined
|
40
33
|
end
|
@@ -60,13 +53,7 @@ module Eancom
|
|
60
53
|
end
|
61
54
|
|
62
55
|
def convert(string)
|
63
|
-
string.encode(
|
64
|
-
'UTF-8',
|
65
|
-
'binary',
|
66
|
-
invalid: :replace,
|
67
|
-
undef: :replace,
|
68
|
-
replace: ''
|
69
|
-
)
|
56
|
+
string.encode('UTF-8')
|
70
57
|
end
|
71
58
|
end
|
72
59
|
end
|
@@ -2,13 +2,11 @@ module Eancom
|
|
2
2
|
module Parser
|
3
3
|
class Segment
|
4
4
|
|
5
|
-
attr_accessor :tag, :
|
5
|
+
attr_accessor :tag, :components, :string
|
6
6
|
|
7
7
|
def initialize(string)
|
8
8
|
@string = string
|
9
9
|
@components = []
|
10
|
-
@tag = una? ? 'UNA' : string.split(data_delimiter)[0]
|
11
|
-
@segment_class = find_segment_class
|
12
10
|
end
|
13
11
|
|
14
12
|
def parse
|
@@ -21,13 +19,13 @@ module Eancom
|
|
21
19
|
private
|
22
20
|
|
23
21
|
def parse_component
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
if string =~ /^UNA/
|
23
|
+
parse_una
|
24
|
+
else
|
27
25
|
string.split(data_delimiter).each do |data|
|
28
26
|
components << parse_data(data)
|
29
27
|
end
|
30
|
-
|
28
|
+
end
|
31
29
|
end
|
32
30
|
|
33
31
|
def parse_data(data)
|
@@ -48,6 +46,10 @@ module Eancom
|
|
48
46
|
components << [DELIMITERS[:segment]]
|
49
47
|
end
|
50
48
|
|
49
|
+
def tag
|
50
|
+
components.first.first
|
51
|
+
end
|
52
|
+
|
51
53
|
def find_segment_class
|
52
54
|
Eancom.find_segment(tag: tag)
|
53
55
|
end
|
@@ -64,9 +66,6 @@ module Eancom
|
|
64
66
|
DELIMITERS[:component]
|
65
67
|
end
|
66
68
|
|
67
|
-
def una?
|
68
|
-
string =~ /^UNA/
|
69
|
-
end
|
70
69
|
end
|
71
70
|
end
|
72
71
|
end
|
data/lib/eancom/version.rb
CHANGED
data/lib/eancom.rb
CHANGED
data/pricat.json
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
"#<File:0x00007ff38589ba40>"
|