Sha256: 5f42c0051ab2cf30bbbe2ecfdaf2a97dbc2e70c8f573982b43925e7d6be5c34f
Contents?: true
Size: 641 Bytes
Versions: 3
Compression:
Stored size: 641 Bytes
Contents
module Comee module Core class ClientPrice < ApplicationRecord belongs_to :product belongs_to :client validates :valid_from, :valid_to, :new_price, presence: true validates :old_price, :new_price, numericality: {greater_than: 0, allow_nil: true} validates :product_id, uniqueness: {scope: :client_id} validate :validate_price_validity_dates def validate_price_validity_dates return unless valid_from && valid_to period = Period.new(valid_from, valid_to) errors.add(:base, "Price validity date range is not correct.") unless period.valid? end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
comee_core-0.1.12 | app/models/comee/core/client_price.rb |
comee_core-0.1.11 | app/models/comee/core/client_price.rb |
comee_core-0.1.10 | app/models/comee/core/client_price.rb |