Sha256: 53d5c5057c476e2efb2475118af7fb9b9ff0e1521eb41c20fa4c21f55a749b1e

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

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

      attr_reader :segment_type

      def initialize(
        tag: nil,
        price_code_qualifier:,
        price_amount:,
        price_type_code: nil,
        price_specification_code: nil,
        unit_price_basis_value: nil,
        measurment_unit_code: nil,
        subline_item_price_change_operation_code: nil
      )
        @tag = tag

        @price_code_qualifier = price_code_qualifier
        @price_amount = price_amount
        @price_type_code = price_type_code
        @price_specification_code = price_specification_code
        @unit_price_basis_value = unit_price_basis_value
        @measurment_unit_code = measurment_unit_code
        @subline_item_price_change_operation_code = subline_item_price_change_operation_code

        super(tag: tag || TAG)
      end

      def to_json_hash
        hash = {}
        hash.merge!(price_code_qualifier: find_identifier(:price_code_qualifier)) if @price_code_qualifier
        hash.merge!(price_amount: @price_amount) if @price_amount
        hash.merge!(price_type_code: find_identifier(:price_type_code)) if @price_type_code
        hash.merge!(price_specification_code: find_identifier(:price_specification_code)) if @price_specification_code
        hash.merge!(unit_price_basis_value: @unit_price_basis_value) if @unit_price_basis_value
        hash.merge!(measurment_unit_code: find_identifier(:measurment_unit_code)) if @measurment_unit_code
        { price: hash }
      end

      def group_name
        'prices'
      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/pri.rb