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,76 @@
1
+ tag = 'CPS'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::CPS)
3
+
4
+ structure = Eancom::Edifact::Structure.new(tag: tag)
5
+ #==============================================================================
6
+ # Tag #
7
+ #==============================================================================
8
+ tag = Eancom::Edifact::Composite.new()
9
+ data = Eancom::Edifact::Data.new(
10
+ type: String,
11
+ length: 3,
12
+ dictionary: nil,
13
+ description: "Message Header",
14
+ required: true
15
+ )
16
+ tag.add(:tag, data)
17
+
18
+ structure << tag
19
+ #==============================================================================
20
+ # Hierarchical structure level identifier #
21
+ #==============================================================================
22
+ hierarchical_structure_level_identifier = Eancom::Edifact::Composite.new()
23
+
24
+ data = Eancom::Edifact::Data.new(
25
+ type: String,
26
+ length: 1..35,
27
+ description: "Hierarchical structure level identifier",
28
+ required: true
29
+ )
30
+ hierarchical_structure_level_identifier.add(:hierarchical_structure_level_identifier, data)
31
+
32
+ structure << hierarchical_structure_level_identifier
33
+ #==============================================================================
34
+ # Hierarchical structure parent identifier #
35
+ #==============================================================================
36
+ hierarchical_structure_parent_identifier = Eancom::Edifact::Composite.new()
37
+
38
+ data = Eancom::Edifact::Data.new(
39
+ type: String,
40
+ length: 1..35,
41
+ description: "Hierarchical structure parent identifier",
42
+ required: false
43
+ )
44
+ hierarchical_structure_parent_identifier.add(:hierarchical_structure_parent_identifier, data)
45
+
46
+ structure << hierarchical_structure_parent_identifier
47
+ #==============================================================================
48
+ # Hierarchical structure level identifier #
49
+ #==============================================================================
50
+ packaging_level_code = Eancom::Edifact::Composite.new()
51
+
52
+ data = Eancom::Edifact::Data.new(
53
+ type: String,
54
+ length: 0..3,
55
+ dictionary: {
56
+ '1E' => {
57
+ description: 'Highest (GS1 Temporary Code)',
58
+ identifier: 'highest'
59
+ },
60
+ '4' => {
61
+ description: 'No packaging hierarchy',
62
+ identifier: 'no_packing_hierarchy'
63
+ },
64
+ '5' => {
65
+ description: 'Shipment Level',
66
+ identifier: 'shipment_level'
67
+ }
68
+ },
69
+ description: "Packaging level code",
70
+ required: false
71
+ )
72
+ packaging_level_code.add(:packaging_level_code, data)
73
+
74
+ structure << packaging_level_code
75
+ #==============================================================================
76
+ Eancom.register_structure(tag: 'CPS', structure: structure)
@@ -0,0 +1,167 @@
1
+ tag = 'CUX'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::CUX)
3
+
4
+ structure = Eancom::Edifact::Structure.new(tag: tag)
5
+ #==============================================================================
6
+ # Tag #
7
+ #==============================================================================
8
+ tag = Eancom::Edifact::Composite.new()
9
+ data = Eancom::Edifact::Data.new(
10
+ type: String,
11
+ length: 3,
12
+ dictionary: nil,
13
+ description: "Message Header",
14
+ required: true
15
+ )
16
+ tag.add(:tag, data)
17
+
18
+ structure << tag
19
+ #==============================================================================
20
+ # Currency Details 1
21
+ #==============================================================================
22
+ currency_type_dictionary = {
23
+ '2' => {
24
+ description: 'Reference Currency',
25
+ identifier: 'reference_currency'
26
+ },
27
+ '3' => {
28
+ description: 'Target Currency',
29
+ identifier: 'target_currency'
30
+ },
31
+ '4' => {
32
+ description: 'Invoicing Currency',
33
+ identifier: 'invoicing_currency'
34
+ },
35
+ '8' => {
36
+ description: 'Price list currency',
37
+ identifier: 'price_list_currency'
38
+ },
39
+ '10' => {
40
+ description: 'Pricing_currency',
41
+ identifier: 'pricing_currency'
42
+ },
43
+ '11' => {
44
+ description: 'Payment currency',
45
+ identifier: 'payment_currency'
46
+ }
47
+ }
48
+
49
+ currency_details = Eancom::Edifact::Composite.new()
50
+
51
+ data = Eancom::Edifact::Data.new(
52
+ type: String,
53
+ length: 1..3,
54
+ dictionary: currency_type_dictionary,
55
+ description: 'Currency usage code qualifier',
56
+ required: true
57
+ )
58
+
59
+ currency_details.add(:currency_usage_code_qualifier_1, data)
60
+
61
+ data = Eancom::Edifact::Data.new(
62
+ type: String,
63
+ length: 1..3,
64
+ dictionary: nil,
65
+ description: 'Currency identification code',
66
+ required: true
67
+ )
68
+ currency_details.add(:currency_identification_code_1, data)
69
+
70
+
71
+ data = Eancom::Edifact::Data.new(
72
+ type: String,
73
+ length: 1..3,
74
+ dictionary: currency_type_dictionary,
75
+ description: 'Currency type code qualifier',
76
+ required: true
77
+ )
78
+ currency_details.add(:currency_type_code_qualifier_1, data)
79
+
80
+ data = Eancom::Edifact::Data.new(
81
+ type: String,
82
+ length: 0..4,
83
+ dictionary: nil,
84
+ description: 'Currency rate value',
85
+ required: false
86
+ )
87
+
88
+ currency_details.add(:currency_rate_value_1, data)
89
+
90
+ structure << currency_details
91
+ #==============================================================================
92
+ # Currency Details 2
93
+ #==============================================================================
94
+ currency_details_2 = Eancom::Edifact::Composite.new()
95
+
96
+ data = Eancom::Edifact::Data.new(
97
+ type: String,
98
+ length: 1..3,
99
+ dictionary: currency_type_dictionary,
100
+ description: 'Currency usage code qualifier',
101
+ required: false
102
+ )
103
+
104
+ currency_details_2.add(:currency_usage_code_qualifier_2, data)
105
+
106
+ data = Eancom::Edifact::Data.new(
107
+ type: String,
108
+ length: 1..3,
109
+ dictionary: nil,
110
+ description: 'Currency identification code',
111
+ required: false
112
+ )
113
+ currency_details_2.add(:currency_identification_code_2, data)
114
+
115
+ data = Eancom::Edifact::Data.new(
116
+ type: String,
117
+ length: 1..3,
118
+ dictionary: currency_type_dictionary,
119
+ description: 'Currency type code qualifier',
120
+ required: false
121
+ )
122
+ currency_details_2.add(:currency_type_code_qualifier_2, data)
123
+
124
+ data = Eancom::Edifact::Data.new(
125
+ type: String,
126
+ length: 0..4,
127
+ dictionary: nil,
128
+ description: 'Currency rate value',
129
+ required: false
130
+ )
131
+
132
+ currency_details_2.add(:currency_rate_value_2, data)
133
+
134
+ structure << currency_details_2
135
+ #==============================================================================
136
+ # Currency Exchange Rate
137
+ #==============================================================================
138
+ currency_exchange_rate = Eancom::Edifact::Composite.new()
139
+
140
+ data = Eancom::Edifact::Data.new(
141
+ type: String,
142
+ length: 0..12,
143
+ dictionary: nil,
144
+ description: 'Currency exchange rate',
145
+ required: false
146
+ )
147
+ currency_exchange_rate.add(:currency_exchange_rate, data)
148
+
149
+ structure << currency_exchange_rate
150
+ #==============================================================================
151
+ # Exchange rate currency market identifier
152
+ #==============================================================================
153
+ exchange_rate_currency_market_identifier = Eancom::Edifact::Composite.new()
154
+
155
+ data = Eancom::Edifact::Data.new(
156
+ type: String,
157
+ length: 0..3,
158
+ dictionary: nil,
159
+ description: 'Exchange rate currency market identifier',
160
+ required: false
161
+ )
162
+ exchange_rate_currency_market_identifier.add(:exchange_rate_currency_market_identifier, data)
163
+
164
+ structure << exchange_rate_currency_market_identifier
165
+ #==============================================================================
166
+ Eancom.register_structure(tag: 'CUX', structure: structure)
167
+
@@ -0,0 +1,159 @@
1
+ tag = 'DTM'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::DTM)
3
+
4
+ structure = Eancom::Edifact::Structure.new(tag: tag)
5
+
6
+ composite = Eancom::Edifact::Composite.new()
7
+ data = Eancom::Edifact::Data.new(
8
+ type: String,
9
+ length: 3,
10
+ description: "DATE/TIME/PERIOD",
11
+ required: true
12
+ )
13
+ composite.add(:tag, data)
14
+ structure << composite
15
+
16
+ composite = Eancom::Edifact::Composite.new()
17
+
18
+ type_dictionary = {
19
+ '1' => {
20
+ description: 'Service completion date/time, actual',
21
+ identifier: 'service_completion_date_time_actual'
22
+ },
23
+ '2' => {
24
+ description: 'Delivery date/time, reqested',
25
+ identifier: 'delivery_date_time'
26
+ },
27
+ '7' => {
28
+ description: 'Effectiv date/time',
29
+ identifier: 'effectiv_date_time'
30
+ },
31
+ '11' => {
32
+ description: 'Despatch date and/or time',
33
+ identifier: 'despatch_date_and_or_time'
34
+ },
35
+ '17' => {
36
+ description: 'Delivery date/time, estimated',
37
+ identifier: 'delivery_date_time_estimated'
38
+ },
39
+ '35' => {
40
+ description: 'Delivery date and/or time',
41
+ identifier: 'delivery_date_and_or_time'
42
+ },
43
+ '36' => {
44
+ description: 'Expiry Date',
45
+ identifier: 'expiry_date'
46
+ },
47
+ '44' => {
48
+ description: 'Availability',
49
+ identifier: 'availability'
50
+ },
51
+ '50' => {
52
+ description: 'Goods receipt date/time',
53
+ identifier: 'goods_receipt_date_time'
54
+ },
55
+ '63' => {
56
+ description: 'Delivery date/time, latest',
57
+ identifier: 'delivery_date_time_latest'
58
+ },
59
+ '90' => {
60
+ description: 'Report start date',
61
+ identifier: 'report_start_date'
62
+ },
63
+ '91' => {
64
+ description: 'Report end date',
65
+ identifier: 'report_end_date'
66
+ },
67
+ '64' => {
68
+ description: 'Delivery date/time, earliest',
69
+ identifier: 'delivery_date_time_earliest'
70
+ },
71
+ '137' => {
72
+ description: 'Document/message date/time',
73
+ identifier: 'document_message_date_time'
74
+ },
75
+ '157' => {
76
+ description: 'Validity start date',
77
+ identifier: 'valitity_start_date'
78
+ },
79
+ '171' => {
80
+ description: 'Reference date/time',
81
+ identifier: 'reference_date_time'
82
+ },
83
+ '200' => {
84
+ description: 'Pick-up/collection date/time of cargo',
85
+ identifier: 'pick_up_collection_date_time_of_cargo'
86
+ },
87
+ '263' => {
88
+ description: 'Invoicing period',
89
+ identifier: 'invoicing_period'
90
+ },
91
+ '325' => {
92
+ description: 'Tax period',
93
+ identifier: 'tax_period'
94
+ },
95
+ '356' => {
96
+ description: 'Sales date, and or time, and or period',
97
+ identifier: 'sales_date_and_or_time_and_or_period'
98
+ },
99
+ '454' => {
100
+ description: 'Accounting value date',
101
+ identifier: 'accounting_value_date'
102
+ },
103
+ '44E' => {
104
+ description: 'Connection date/time',
105
+ identifier: 'connection_date_time'
106
+ },
107
+ }
108
+
109
+ data = Eancom::Edifact::Data.new(
110
+ type: String,
111
+ length: 1..3,
112
+ dictionary: type_dictionary,
113
+ description: 'Date or time or period function code qualifier',
114
+ required: true
115
+ )
116
+ composite.add(:type, data)
117
+
118
+ data = Eancom::Edifact::Data.new(
119
+ type: String,
120
+ length: 1..35,
121
+ description: 'Date or time or period value',
122
+ required: true
123
+ )
124
+ composite.add(:date_time, data)
125
+
126
+ format_dictionary = {
127
+ '102' => {
128
+ description: 'Date',
129
+ value: 'CCYYMMDD',
130
+ identifier: 'date'
131
+ },
132
+ '203' => {
133
+ description: 'Date and Time',
134
+ value: 'CCYYMMDDHHMM',
135
+ identifier: 'date_time'
136
+ },
137
+ '204' => {
138
+ description: 'Date and Time',
139
+ value: 'CCYYMMDDHHMMSS',
140
+ identifier: 'date_time_second'
141
+ },
142
+ '718' => {
143
+ description: 'Period',
144
+ value: 'CCYYMMDD-CCZZMMDD',
145
+ identifier: 'period'
146
+ }
147
+ }
148
+
149
+ data = Eancom::Edifact::Data.new(
150
+ type: String,
151
+ length: 1..35,
152
+ dictionary: format_dictionary,
153
+ description: 'Date or time or period value',
154
+ required: true
155
+ )
156
+ composite.add(:format, data)
157
+ structure << composite
158
+
159
+ Eancom.register_structure(tag: 'DTM', structure: structure)
@@ -0,0 +1,143 @@
1
+ tag = 'FTX'
2
+ Eancom.register_segment(tag: tag, klass: Eancom::Edifact::FTX)
3
+
4
+ structure = Eancom::Edifact::Structure.new(tag: tag)
5
+ #==============================================================================
6
+ # Tag #
7
+ #==============================================================================
8
+ tag = Eancom::Edifact::Composite.new()
9
+ data = Eancom::Edifact::Data.new(
10
+ type: String,
11
+ length: 3,
12
+ dictionary: nil,
13
+ description: "Message Header",
14
+ required: true
15
+ )
16
+ tag.add(:tag, data)
17
+
18
+ structure << tag
19
+ #==============================================================================
20
+ # Text subject code qualifier #
21
+ #==============================================================================
22
+ text_subject_code_qualifier = Eancom::Edifact::Composite.new()
23
+
24
+ data = Eancom::Edifact::Data.new(
25
+ type: String,
26
+ length: 1..3,
27
+ dictionary: nil,
28
+ description: "Text subject code qualifier",
29
+ required: true
30
+ )
31
+ text_subject_code_qualifier.add(:text_subject_code_qualifier, data)
32
+
33
+ structure << text_subject_code_qualifier
34
+ #==============================================================================
35
+ # Free Text function code
36
+ #==============================================================================
37
+ free_text_function_code = Eancom::Edifact::Composite.new()
38
+
39
+ data = Eancom::Edifact::Data.new(
40
+ type: String,
41
+ length: 0..3,
42
+ dictionary: {
43
+ '1' => {
44
+ description: 'Text for subsequent use',
45
+ identifier: 'text_for_subsequent_use'
46
+ }
47
+ },
48
+ description: "Free Text function code",
49
+ required: false
50
+ )
51
+ free_text_function_code.add(:free_text_function_code, data)
52
+
53
+ structure << free_text_function_code
54
+ #==============================================================================
55
+ # Text Reference
56
+ #==============================================================================
57
+ text_reference = Eancom::Edifact::Composite.new()
58
+
59
+ data = Eancom::Edifact::Data.new(
60
+ type: String,
61
+ length: 0..3,
62
+ dictionary: nil,
63
+ description: "Free Text value_code",
64
+ required: false
65
+ )
66
+ text_reference.add(:free_text_value_code, data)
67
+
68
+ data = Eancom::Edifact::Data.new(
69
+ type: String,
70
+ length: 0..17,
71
+ description: "Code list identification code",
72
+ required: false
73
+ )
74
+ text_reference.add(:code_list_identification_code, data)
75
+
76
+ data = Eancom::Edifact::Data.new(
77
+ type: String,
78
+ length: 0..3,
79
+ dictionary: {
80
+ '9' => {
81
+ description: 'GS1',
82
+ identifier: 'gs1'
83
+ },
84
+ '91' => {
85
+ description: "Assigned by supplier or supplier's agent",
86
+ identifier: 'assigned_by_supplier_or_suppliers_agent'
87
+ },
88
+ '92' => {
89
+ description: "Assigned by buyer or buyer's agent",
90
+ identifier: 'assigned_by_buyer_or_buyers_agent'
91
+ },
92
+ '246' => {
93
+ description: "GS1 Germany",
94
+ identifier: 'gs1_germany'
95
+ }
96
+ },
97
+ description: "Code list responsible agency code",
98
+ required: false
99
+ )
100
+ text_reference.add(:code_list_responsible_agency_code, data)
101
+
102
+ structure << text_reference
103
+ #==============================================================================
104
+ # Text Literal
105
+ #==============================================================================
106
+ text_literal = Eancom::Edifact::Composite.new()
107
+
108
+ data = Eancom::Edifact::Data.new(
109
+ type: String,
110
+ length: 0..512,
111
+ dictionary: nil,
112
+ description: "Free Text Value",
113
+ required: false
114
+ )
115
+ text_literal.add(:free_text_value_1, data)
116
+
117
+ data = Eancom::Edifact::Data.new(
118
+ type: String,
119
+ length: 0..512,
120
+ dictionary: nil,
121
+ description: "Free Text Value",
122
+ required: false
123
+ )
124
+ text_literal.add(:free_text_value_2, data)
125
+ text_literal.add(:free_text_value_3, data)
126
+ text_literal.add(:free_text_value_4, data)
127
+ text_literal.add(:free_text_value_5, data)
128
+
129
+ structure << text_literal
130
+ #==============================================================================
131
+ # Language Name code
132
+ language_name_code = Eancom::Edifact::Composite.new()
133
+
134
+ data = Eancom::Edifact::Data.new(
135
+ type: String,
136
+ length: 0..3,
137
+ dictionary: nil,
138
+ description: "Language name Code",
139
+ required: false
140
+ )
141
+ language_name_code.add(:language_name_code, data)
142
+ #==============================================================================
143
+ Eancom.register_structure(tag: 'FTX', structure: structure)