Stock movements
A Spree::StockMovement object is created every time that a stock item moves in
or out of a stock location. This objects documents how many items were added or
removed.
The Spree::StockMovement model has the following attributes:
stock_item_id: The ID of theSpree::StockItemthe movement is related to.quantity: The amount of stock items added or removed from theSpree::StockItem'scount_on_handvalue.originator_typeandoriginator_id: The model and ID of an object that initiated the creation of the current stock movement. For example, an originator could be an administrator (aSpree::User) adding new stock or aSpree::Shipmentbeing created after an order is placed.
Usage example
A typical example of a stock movement would be when a customer buys an item from your store:
- A stock item has a
count_on_handvalue of20. - A customer buys one unit of its associated variant.
- A new
Spree::StockMovementobject is created.- It has a
quantityof-1. - It has a
originator_typeofSpree::Shipmentbecause a new shipment triggered the movement.
- It has a
- The stock item's
count_on_handvalue is updated to19.
Administrating inventory
Administrators can generate stock movements by changing the "Count On Hand"
value for a stock item in the solidus_backend (on the Stock page).
However, they cannot create a stock movement directly.
Because of this, Solidus has no concept of adding to existing inventory. For example:
- A stock item has a
count_on_handvalue of7. - A store administrator receives 25 new items to add to inventory.
- They log into the backend and change the count on hand from
7to33. - This creates a new
Spree::StockMovementwith a quantity of25. (7 + 25 = 33.)
If an administrator does not account for the units already in stock, they may enter the wrong value into the "Count On Hand" field for an item.
For example, if the administrator changes the value from 7 to 25, then the
stock movement only documents that 18 units were added to inventory. (7 + 18 = 25.)