Sha256: d274f05ab70f58568330a545590c13b28a072b10309c66584372914a010cb2c3

Contents?: true

Size: 660 Bytes

Versions: 5

Compression:

Stored size: 660 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, "must be greater or less than zero") if adjustment == 0 }
    
    # All stock level adjustments ordered by their created date desending
    scope :ordered, -> { order(:id => :desc) }
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
shoppe-1.0.2 app/models/shoppe/stock_level_adjustment.rb
shoppe-1.0.1 app/models/shoppe/stock_level_adjustment.rb
shoppe-1.0.0 app/models/shoppe/stock_level_adjustment.rb
shoppe-0.0.21 app/models/shoppe/stock_level_adjustment.rb
shoppe-0.0.20 app/models/shoppe/stock_level_adjustment.rb