Sha256: a392238417569f06e9e4a90ebeac6ae1cc5902f78399a592b7257044184e1872

Contents?: true

Size: 922 Bytes

Versions: 2

Compression:

Stored size: 922 Bytes

Contents

module Comee
  module Core
    class ClientPrice < Price
      belongs_to :client
      belongs_to :previous_price, class_name: "Comee::Core::ClientPrice", optional: true
      belongs_to :next_price, class_name: "Comee::Core::ClientPrice", optional: true

      validates :price, presence: true
      validates :price, numericality: {greater_than: 0}
      validates :discount, presence: true, numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: 100}
      validates :product_id, uniqueness: {scope: %i[client_id previous_price_id]}

      def self.ransackable_attributes(_auth_object = nil)
        %w[
          valid_from
          valid_to
          price
          status
          product_id
          client_id
          previous_price_id
          next_price_id
        ]
      end

      def self.ransackable_associations(_auth_object = nil)
        %w[product client]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
comee_core-0.1.39 app/models/comee/core/client_price.rb
comee_core-0.1.38 app/models/comee/core/client_price.rb