Sha256: 899845a46144f2d61bcc57671ee2c0ca56139180a39a35c7fe63f31f5453d1e6

Contents?: true

Size: 1.3 KB

Versions: 15

Compression:

Stored size: 1.3 KB

Contents

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

      attr_reader :segment_type

      def initialize(
        tag: nil,
        monetary_amount_type_code_qualifier:,
        monetary_amount:,
        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

15 entries across 15 versions & 1 rubygems

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