Stock Sync

Stock sync keeps the external platform's inventory levels in sync with VARIO ERP. Accurate stock data prevents overselling and ensures customers see real-time availability.

Trigger

Stock sync is triggered by the stock.update webhook. This fires whenever stock levels change — due to incoming goods, outgoing orders, manual adjustments, or inventory counts.

app.apiServer.post('/webhooks/stock-update', async (req, res) =>
{
  res.status(200).send({ success: true });

  const { entityId } = req.body;
  await addToQueue('stock.sync', entityId);
});
circle-info

Stock changes can happen very frequently. A single order fulfillment can trigger stock updates for every line item. Use deduplication in your queue to avoid processing the same article multiple times in quick succession.

Fetching Stock Data

Query stock levels from the ERP using VQL:

const ErpApi = require('@vario-software/vario-app-framework-backend/api/ErpApi');

async function fetchStock(articleId)
{
  const { data } = await ErpApi.vql(
    `SELECT
       id,
       articleNumber,
       stock.available,
       stock.physical,
       stock.reserved
     FROM article.queryArticles
     WHERE id = '${articleId}'`,
    {},
    1
  );

  return data[0] || null;
}

Stock Types

VARIO ERP tracks several stock quantities:

Stock Type
Description

Physical

Actual units in the warehouse

Reserved

Units reserved for existing orders

Available

Physical minus reserved — the quantity available for sale

For platform synchronization, available stock is usually the right value to push. It represents what can actually be sold.

Multi-Location Stock

If the ERP manages stock across multiple warehouses, you may need to:

  • Aggregate — Sum available stock across all locations

  • Filter — Only include stock from specific warehouses designated for online sales

  • Map by location — If the platform supports multi-location inventory, map ERP locations to platform locations

Pushing to the Platform

Stock Buffers

Some integrations apply a buffer to stock quantities before pushing:

  • Safety stock — Subtract a fixed amount to keep a reserve (e.g., push available - 5)

  • Zero threshold — Set stock to zero on the platform when it falls below a minimum

These are business decisions that should be configurable per sales channel. Store buffer values as sales channel parametersarrow-up-right.

Frequency Considerations

Stock sync is the most time-sensitive outbound integration. Stale stock data leads to overselling. Consider:

  • Immediate processing — Process stock queue items with higher priority than product or price sync

  • Skip queuing for stock — Some integrations skip the queue entirely for stock and process the webhook inline (at the cost of slower webhook response)

  • Batch updates — If the platform supports batch inventory updates, collect multiple stock changes and push them together

Handling Variants

For articles with variants, stock is typically tracked per variant. Fetch and push stock for each variant individually:

Next Steps

Was this helpful?