Sha256: 41556b1c67b1087a5f80659ab21c4603e7c5db6df5ff754d59df22aaef715313
Contents?: true
Size: 671 Bytes
Versions: 42
Compression:
Stored size: 671 Bytes
Contents
# frozen_string_literal: true 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 stock_item.should_track_inventory? stock_item.adjust_count_on_hand quantity end end end
Version data entries
42 entries across 42 versions & 2 rubygems