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
| Parameter | Type | Required | Description |
|---|---|---|---|
skuNumber | text | Yes | The SKU number to look up. |
asOf | instant | Yes | Only include incoming stock expected before this date. |
inventoryKeys | [text] | No | Inventory keys to include. If omitted, all inventories are returned. |
allocationKeys | [text] | No | Include 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
| Promotion | Rule | Reactor |
|---|---|---|
| ✓ | ✓ |
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']
)