Sha256: d82078c76dd23d410f46522c29d2dbe3ea28943558366fd987051573b012bd06

Contents?: true

Size: 1.92 KB

Versions: 15

Compression:

Stored size: 1.92 KB

Contents

module Eancom
  module Edifact
    class ALI < Segment
      TAG = 'ALI'.freeze
      TYPE = :body.freeze

      attr_reader :segment_type

      def initialize(
        tag: nil,
        country_of_origin_name_code: nil,
        duty_regime_type_code: nil,
        special_condition_code_1: nil,
        special_condition_code_2: nil,
        special_condition_code_3: nil,
        special_condition_code_4: nil,
        special_condition_code_5: nil
      )
        @tag = tag
        @country_of_origin_name_code = country_of_origin_name_code
        @duty_regime_type_code = duty_regime_type_code
        @special_condition_code_1 = special_condition_code_1
        @special_condition_code_2 = special_condition_code_2
        @special_condition_code_3 = special_condition_code_3
        @special_condition_code_4 = special_condition_code_4
        @special_condition_code_5 = special_condition_code_5

        super(tag: tag || TAG)
      end

      def to_json_hash
        hash = {}
        hash.merge!(country_of_origin_name_code: @country_of_origin_name_code) if @country_of_origin_name_code
        hash.merge!(duty_regime_type_code: @duty_regime_type_code) if @duty_regime_type_code
        hash.merge!(special_condition_code_1: find_identifier(:special_condition_code_1)) if @special_condition_code_1
        hash.merge!(special_condition_code_2: find_identifier(:special_condition_code_2)) if @special_condition_code_2
        hash.merge!(special_condition_code_3: find_identifier(:special_condition_code_3)) if @special_condition_code_3
        hash.merge!(special_condition_code_4: find_identifier(:special_condition_code_4)) if @special_condition_code_4
        hash.merge!(special_condition_code_5: find_identifier(:special_condition_code_5)) if @special_condition_code_5
        outer_hash = {}
        outer_hash.merge!(additional_information: hash )
        outer_hash
      end

      def segment_type
        TYPE
      end


    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
eancom-1.6.3 lib/eancom/edifact/segments/ali.rb
eancom-1.6.2 lib/eancom/edifact/segments/ali.rb
eancom-1.6.0 lib/eancom/edifact/segments/ali.rb
eancom-1.5.7 lib/eancom/edifact/segments/ali.rb
eancom-1.5.6 lib/eancom/edifact/segments/ali.rb
eancom-1.5.5 lib/eancom/edifact/segments/ali.rb
eancom-1.5.4 lib/eancom/edifact/segments/ali.rb
eancom-1.5.2 lib/eancom/edifact/segments/ali.rb
eancom-1.5.1 lib/eancom/edifact/segments/ali.rb
eancom-1.5.0 lib/eancom/edifact/segments/ali.rb
eancom-1.4.0 lib/eancom/edifact/segments/ali.rb
eancom-1.3.0 lib/eancom/edifact/segments/ali.rb
eancom-1.2.0 lib/eancom/edifact/segments/ali.rb
eancom-1.1.1 lib/eancom/edifact/segments/ali.rb
eancom-1.1.0 lib/eancom/edifact/segments/ali.rb