Sha256: 622a1ef2217ff964cc2ad122e368d888b32206178280d9b84467c0977b749578

Contents?: true

Size: 813 Bytes

Versions: 6

Compression:

Stored size: 813 Bytes

Contents

module Comee
  module Core
    class ClientPrice < Price
      belongs_to :client
      belongs_to :previous_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
        ]
      end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
comee_core-0.1.37 app/models/comee/core/client_price.rb
comee_core-0.1.36 app/models/comee/core/client_price.rb
comee_core-0.1.35 app/models/comee/core/client_price.rb
comee_core-0.1.34 app/models/comee/core/client_price.rb
comee_core-0.1.33 app/models/comee/core/client_price.rb
comee_core-0.1.32 app/models/comee/core/client_price.rb