Class: Eancom::Edifact::ALC

Inherits:
Segment
  • Object
show all
Defined in:
lib/eancom/edifact/segments/alc.rb

Constant Summary collapse

TAG =
'ALC'.freeze
TYPE =
:body.freeze

Instance Attribute Summary collapse

Attributes inherited from Segment

#tag

Instance Method Summary collapse

Methods inherited from Segment

#array, initialize_by_components, #is_body?, #is_footer?, #is_header?, #item_group_name, #starts_item?, #starts_message?, #structure, #tag?, #to_edi, #to_hash, #to_s, #validate_structure

Constructor Details

#initialize(tag: nil, allowance_or_charge_code_qualifier:, allowance_or_charge_identifier: nil, allowance_or_charge_identification_code: nil, settlement_mean_code: nil, calculation_sequence_code: nil, special_service_description_code: nil, code_list_identification_code: nil, code_list_responsible_agency_code: nil, special_service_description_1: nil, special_service_description_2: nil) ⇒ ALC

Returns a new instance of ALC.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/eancom/edifact/segments/alc.rb', line 9

def initialize(
  tag: nil,
  allowance_or_charge_code_qualifier:,
  allowance_or_charge_identifier: nil,
  allowance_or_charge_identification_code: nil,
  settlement_mean_code: nil,
  calculation_sequence_code: nil,
  special_service_description_code: nil,
  code_list_identification_code: nil,
  code_list_responsible_agency_code: nil,
  special_service_description_1: nil,
  special_service_description_2: nil
)
  @tag = tag
  @allowance_or_charge_code_qualifier = allowance_or_charge_code_qualifier
  @allowance_or_charge_identifier = allowance_or_charge_identifier
  @allowance_or_charge_identification_code = allowance_or_charge_identification_code
  @settlement_mean_code = settlement_mean_code
  @calculation_sequence_code = calculation_sequence_code
  @special_service_description_code = special_service_description_code
  @code_list_identification_code = code_list_identification_code
  @code_list_responsible_agency_code = code_list_responsible_agency_code
  @special_service_description_1 = special_service_description_1
  @special_service_description_2 = special_service_description_2
  super(tag: tag || TAG)
end

Instance Attribute Details

#segment_typeObject (readonly)

Returns the value of attribute segment_type.



7
8
9
# File 'lib/eancom/edifact/segments/alc.rb', line 7

def segment_type
  @segment_type
end

Instance Method Details

#group_nameObject



51
52
53
# File 'lib/eancom/edifact/segments/alc.rb', line 51

def group_name
  'allowances_or_charges'
end

#to_json_hashObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/eancom/edifact/segments/alc.rb', line 36

def to_json_hash
  hash = {}
  hash.merge!(allowance_or_charge_code_qualifier: find_identifier(:allowance_or_charge_code_qualifier)) if @allowance_or_charge_code_qualifier
  hash.merge!(allowance_or_charge_identifier: @allowance_or_charge_identifier) if @allowance_or_charge_identifier
  hash.merge!(allowance_or_charge_identification_code: find_identifier(:allowance_or_charge_identification_code)) if @allowance_or_charge_identification_code
  hash.merge!(settlement_mean_code: find_identifier(:settlement_mean_code)) if @settlement_mean_code
  hash.merge!(calculation_sequence_code: find_identifier(:calculation_sequence_code)) if @calculation_sequence_code
  hash.merge!(special_service_description_code: find_identifier(:special_service_description_code)) if @special_service_description_code
  hash.merge!(code_list_identification_code: @code_list_identification_code) if @code_list_identification_code
  hash.merge!(code_list_responsible_agency_code: find_identifier(:code_list_responsible_agency_code)) if @code_list_responsible_agency_code
  hash.merge!(special_service_description_1: @special_service_description_1) if @special_service_description_1
  hash.merge!(special_service_description_2: @special_service_description_2) if @special_service_description_2
  hash
end