Sha256: 3e730a26c441f2e4b6fd740f013251b672e98aa7b5edd7934312cbbfd3954561

Contents?: true

Size: 1.63 KB

Versions: 2

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

module Eancom
  module Edifact
    class QVR < Segment
      TAG = 'QVR'
      TYPE = :body

      def initialize(
        tag: nil,
        quantity_variance_value:,
        quantity_type_code_qualifier:,
        discrepancy_nature_identification_code: nil,
        change_reason_description_code: nil,
        code_list_identification_code: nil,
        code_list_responsible_agency_code: nil,
        change_reason_description: nil
      )
        @tag = tag

        @quantity_variance_value = quantity_variance_value
        @quantity_type_code_qualifier = quantity_type_code_qualifier
        @discrepancy_nature_identification_code = discrepancy_nature_identification_code
        @change_reason_description_code = change_reason_description_code
        @code_list_identification_code = code_list_identification_code
        @code_list_responsible_agency_code = code_list_responsible_agency_code
        @change_reason_description = change_reason_description

        super(tag: tag || TAG)
      end

      def to_json_hash
        hash = {}
        hash.merge!(quantity_variance_value: quantity_variance_value)
        hash.merge!(quantity_type_code_qualifier: find_identifier(:quantity_type_code_qualifier))
        hash.merge!(discrepancy_nature_identification_code: find_identifier(:discrepancy_nature_identification_code)) if @discrepancy_nature_identification_code
        hash.merge!(change_reason_description: @change_reason_description) if @change_reason_description
        hash
      end

      def group_name
        'quantity_variances'
      end

      def segment_type
        TYPE
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
eancom-1.6.3 lib/eancom/edifact/segments/qvr.rb
eancom-1.6.2 lib/eancom/edifact/segments/qvr.rb