Register Opening Balance
Register initial stock when setting up inventory or correcting balances. Creates a stock movement with reasonOPENING_BALANCE.
Request Body
Target inventory location ID
Item variant ID
Quantity in the specified UOM (must be > 0)
Unit of measure ID for the quantity
Cost per unit in the specified UOM (must be ≥ 0)
Reference number (e.g., physical count document number)
Additional notes about this opening balance
How It Works
- The system converts the quantity to the variant’s base UOM using UOM conversions
- Creates a
StockMovementwith reasonOPENING_BALANCEand statusPOSTED - Creates movement lines with FIFO costing data
- Updates the
Stockrecord for the location/variant (increaseson_hand) - Updates the variant’s
avg_unit_costusing weighted average
Response
Example Response
Errors
422- Validation error (invalid IDs, negative quantity, etc.)400- Business logic error (e.g., no UOM conversion found between entry UOM and variant base UOM)403- Insufficient permissions
UOM Conversion:
If the entry UOM differs from the variant’s base UOM, a valid UOM conversion must exist. For example, if the variant’s base UOM is
KG and you enter quantity in GR (grams), there must be a GR → KG conversion defined.Register Stock Out
Register stock consumption or sale. Reduces stock using FIFO costing.Request Body
Source inventory location ID (where stock is deducted from)
Item variant ID
Quantity to deduct in the specified UOM (must be > 0)
Unit of measure ID for the quantity
Reason for stock out:
SALE, CONSUMPTION, WASTE, ADJUSTMENT, TRANSFER, or OTHERSale price per unit (for
SALE reason, used to calculate profit margin)Reference number (e.g., sale order number, production order)
Additional notes about this movement
How It Works
- Validates that sufficient stock is available (
available >= requested qty) - Converts quantity to base UOM
- Applies FIFO costing: consumes oldest stock first based on movement lines
- Creates
StockMovementwith specified reason and statusPOSTED - Creates movement lines with cost and profit data
- Updates
Stockrecord (decreaseson_hand) - If reason is
SALEandsale_priceis provided, calculates profit margin
Response
Example Response
Errors
422- Validation error (invalid IDs, negative quantity, invalid reason)400- Business logic error:- Insufficient stock:
"Insufficient stock. Available: 5, Requested: 10" - No UOM conversion found
- Location not found or inactive
- Insufficient stock:
403- Insufficient permissions
Movement Reasons
SALE
Product sold to a customer. Use
sale_price to track revenue and profit margin.CONSUMPTION
Material consumed in production or operations (e.g., ingredients used in recipes).
WASTE
Stock lost due to spoilage, damage, or expiration.
ADJUSTMENT
Inventory adjustment (e.g., after physical count discrepancy).
TRANSFER
Stock transferred to another location (creates corresponding IN movement at destination).
OTHER
Other reasons not covered above. Use
notes to clarify.FIFO Costing
The system uses First-In-First-Out (FIFO) costing for stock out movements:- When stock is consumed, the system finds the oldest movement lines with remaining quantity
- Deducts from oldest lines first until the requested quantity is fulfilled
- Each movement line tracks the original unit cost from when stock was received
- This ensures accurate cost of goods sold (COGS) calculation
- 50 kg received at $25/kg on Jan 1
- 100 kg received at $28/kg on Jan 15
- 50 kg costed at $25/kg (from Jan 1 batch)
- 25 kg costed at $28/kg (from Jan 15 batch)
- Total COGS: (50 × 28) = $1,950