Sha256: 27002eb8f6fe7ee9027ad231ae094e3536d9e5668b296bde0d4dd403f309d286

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

module Eancom
  module Edifact
    class MOA < Segment
      TAG = 'MOA'.freeze
      TYPE = :footer.freeze

      attr_reader :segment_type

      def initialize(
        tag: nil,
        monetary_amount_type_code_qualifier:,
        monetary_amount: nil,
        currency_identification_code: nil,
        currency_type_code_qualifier: nil
      )
        @tag = tag

        @monetary_amount_type_code_qualifier = monetary_amount_type_code_qualifier
        @monetary_amount= monetary_amount
        @currency_identification_code = currency_identification_code
        @currency_type_code_qualifier = currency_type_code_qualifier

        super(tag: tag || TAG)
      end

      def to_json_hash
        hash = {}
        hash.merge!(monetary_amount_type_code_qualifier: find_identifier(:monetary_amount_type_code_qualifier)) if @monetary_amount_type_code_qualifier
        hash.merge!(monetary_amount: @monetary_amount) if @monetary_amount
        hash.merge!(currency_identification_code: @currency_identification_code) if @currency_identification_code
        hash.merge!(currency_type_code_qualifier: find_identifier(:currency_type_code_qualifier)) if @currency_type_code_qualifier
        hash
      end

      def group_name
        'monetary_amounts'
      end

      def segment_type
        TYPE
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eancom-2.0.0 lib/eancom/edifact/segments/moa.rb