ActiveRecord model representing stock movements with validation and lifecycle hooks.
# Source: https://github.com/spree/spree | License: BSD-3-Clause | Copyright 2024-present, Vendo Sp. z o.o., Vendo Connect Inc
# Provided via justclaw.it.com; keep this notice with the code.
module Spree
class StockMovement < Spree.base_class
has_prefix_id :sm
# What happened to stock. The kind carries the direction, so the three
# order-driven kinds are written positive; `received` and `adjusted` keep
# the signed meaning of quantity.
KINDS = %w[received allocated shipped released adjusted].freeze
QUANTITY_LIMITS = {
max: 2**31 - 1,
min: -2**31
}.freeze
include Spree::StockMovement::CustomEvents
publishes_lifecycle_events
# `with_deleted` because the ledger outlives what it describes: a level is
# soft-deleted whenever a produ
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key