Sha256: e0d4c2d31bd5a2f4e035c1ff975036d24905e45cdd4111057f5d06f266c9e33e

Contents?: true

Size: 587 Bytes

Versions: 33

Compression:

Stored size: 587 Bytes

Contents

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

    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

33 entries across 33 versions & 2 rubygems

Version Path
solidus_core-1.0.0 app/models/spree/stock_movement.rb
solidus_core-1.0.0.rc2 app/models/spree/stock_movement.rb
solidus_core-1.0.0.rc1 app/models/spree/stock_movement.rb
solidus_core-1.0.0.pre3 app/models/spree/stock_movement.rb
solidus_core-1.0.0.pre2 app/models/spree/stock_movement.rb
solidus_core-1.0.0.pre app/models/spree/stock_movement.rb
spree_core-3.0.1 app/models/spree/stock_movement.rb
spree_core-2.4.7 app/models/spree/stock_movement.rb
spree_core-2.3.10 app/models/spree/stock_movement.rb
spree_core-3.0.0 app/models/spree/stock_movement.rb
spree_core-2.4.6 app/models/spree/stock_movement.rb
spree_core-2.3.9 app/models/spree/stock_movement.rb
spree_core-2.3.8 app/models/spree/stock_movement.rb
spree_core-2.4.5 app/models/spree/stock_movement.rb
spree_core-3.0.0.rc4 app/models/spree/stock_movement.rb
spree_core-3.0.0.rc3 app/models/spree/stock_movement.rb
spree_core-2.4.4 app/models/spree/stock_movement.rb
spree_core-2.3.7 app/models/spree/stock_movement.rb
spree_core-3.0.0.rc1 app/models/spree/stock_movement.rb
spree_core-2.4.3 app/models/spree/stock_movement.rb