Sha256: 681de8bc4bcd8ff38d6484cffbb3100e08b0f8d8accce6958037ce02d54d9939

Contents?: true

Size: 1.64 KB

Versions: 15

Compression:

Stored size: 1.64 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

15 entries across 15 versions & 1 rubygems

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