Sha256: 5c78b0ce9cc110c69953405886598d55da8ce7a4791c16e0d8ced0f6afa9f3a9

Contents?: true

Size: 683 Bytes

Versions: 1

Compression:

Stored size: 683 Bytes

Contents

module Shoppe
  class StockLevelAdjustment < ActiveRecord::Base

    # The orderable item which the stock level adjustment belongs to
    belongs_to :item, polymorphic: true

    # The parent (OrderItem) which the stock level adjustment belongs to
    belongs_to :parent, polymorphic: true

    # Validations
    validates :description, presence: true
    validates :adjustment, numericality: true
    validate { errors.add(:adjustment, I18n.t('shoppe.activerecord.attributes.stock_level_adjustment.must_be_greater_or_equal_zero')) if adjustment == 0 }

    # All stock level adjustments ordered by their created date desending
    scope :ordered, -> { order(id: :desc) }

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoppe-1.1.2 app/models/shoppe/stock_level_adjustment.rb