Sha256: ea621d5d33c98cf672d777098a7b22dda4c6ea012e72ab0f8afada5cbfe64e8d

Contents?: true

Size: 639 Bytes

Versions: 5

Compression:

Stored size: 639 Bytes

Contents

module Spree
  class StockMovement < ActiveRecord::Base
    belongs_to :stock_item, class_name: 'Spree::StockItem'
    belongs_to :originator, polymorphic: true

    attr_accessible :quantity, :stock_item, :stock_item_id, :originator, :action

    after_create :update_stock_item_quantity

    validates :stock_item, presence: true
    validates :quantity, presence: true

    scope :recent, order('created_at DESC')

    def readonly?
      !new_record?
    end

    private

    def update_stock_item_quantity
      return unless self.stock_item.should_track_inventory?
      stock_item.adjust_count_on_hand quantity
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
spree_core-2.0.12 app/models/spree/stock_movement.rb
spree_core-2.0.11 app/models/spree/stock_movement.rb
spree_core-2.0.10 app/models/spree/stock_movement.rb
spree_core-2.0.9 app/models/spree/stock_movement.rb
spree_core-2.0.8 app/models/spree/stock_movement.rb