Sha256: c564f47a46902b93f81f1d141e04573c81edf9b4a0c2956b6cc198ab7334adfa

Contents?: true

Size: 503 Bytes

Versions: 5

Compression:

Stored size: 503 Bytes

Contents

module Shoppe
  class StockLevelAdjustment < ActiveRecord::Base
    
    # Relationships
    belongs_to :product
    belongs_to :parent, :polymorphic => true
    
    # Validations
    validates :product_id, :presence => true
    validates :description, :presence => true
    validates :adjustment, :numericality => true
    validate { errors.add(:adjustment, "must be greater or less than zero") if adjustment == 0 }
    
    # Scopes
    scope :ordered, -> { order('created_at desc') }
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
shoppe-0.0.14 app/models/shoppe/stock_level_adjustment.rb
shoppe-0.0.13 app/models/shoppe/stock_level_adjustment.rb
shoppe-0.0.12 app/models/shoppe/stock_level_adjustment.rb
shoppe-0.0.11 app/models/shoppe/stock_level_adjustment.rb
shoppe-0.0.10 app/models/shoppe/stock_level_adjustment.rb