Sha256: 604f848cb5684e41d229f351b16ab2fbf3e96f46ec8dccc4ae6d5ce3f71f8943
Contents?: true
Size: 647 Bytes
Versions: 15
Compression:
Stored size: 647 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) } self.whitelisted_ransackable_attributes = ['quantity'] 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
15 entries across 15 versions & 1 rubygems