Skip to content
← Back to Index

calculateAvailableStock

calculateAvailableStock(
  skuNumber: text
  asOf: instant
  inventoryKeys: [text] | nothing
  allocationKeys: [text] | nothing
): { text -> number }

Queries available stock for a SKU across inventories.

The available quantity per inventory key is computed as: unallocated physical stock + incoming stock expected before asOf + any stock allocated to the specified allocationKeys.

Parameters

ParameterTypeRequiredDescription
skuNumbertextYesThe SKU number to look up.
asOfinstantYesOnly include incoming stock expected before this date.
inventoryKeys[text]NoInventory keys to include. If omitted, all inventories are returned.
allocationKeys[text]NoInclude stock allocated to these keys in the available total.

Return Value

{ text -> number }

A map where each key is an inventory key and each value is the total available quantity for that inventory.

Availability

PromotionRuleReactor

Examples

Basic usage

filtrera
let stock = calculateAvailableStock (orderLine.skuNumber, delivery.inventoryDate)
from stock->'warehouse-stockholm'

Specific inventories

filtrera
let stock = calculateAvailableStock (
  orderLine.skuNumber,
  delivery.inventoryDate,
  ['warehouse-stockholm', 'warehouse-gothenburg']
)

With allocation keys

filtrera
let stock = calculateAvailableStock (
  orderLine.skuNumber,
  delivery.inventoryDate,
  ['warehouse-stockholm'],
  ['vip-allocation']
)

© 2024 Hantera AB. All rights reserved.