Data sources
STP needs two different kinds of input, and they behave differently:
- Movements — things that change the quantity. Sales, deliveries, counts, corrections, transfers.
- Item master data — things that change how a movement is interpreted. Whether the item is stock handled at all, which costing method applies, what it costs to buy, and whether it is a bundle of other items.
Most of both arrives automatically from other Hii Retail services. The Input API exists for movements that originate somewhere else.
One switch governs all of it. Every ingress on this page except the Input API is gated by the tenant setting
Do enable PosLog processing. Despite the name it controls every feed from a Hii Retail service — sales, goods received, stock counts, corrections, store transfers, and item master data from PnP. With it disabled the Input API is the only way in, which is what you want while an external system still owns the stock. See Configuration.
Movements from other Hii Retail services
STP subscribes to the public events of the services that own each business process. Nothing needs to be configured per integration — if the source service is in use, its movements reach STP.
| Source | Event | Becomes |
|---|---|---|
| POS, via the transaction service | txr.public.output.transactions.v1 | sales and returns |
| Goods Received | grc.public.event.goods-received.v1 | receipt of a delivery |
| Stock Count | stc.public.event.stock-count-completed.v1 | a counted quantity, and the resulting gain/loss |
| Stock Corrections | scr.public.event.stock-correction.v1 | a correction (damage, waste, etc.) |
| Store Transfer | str.public.event.store-transfer-requested.v1 | stock reserved for an outgoing transfer |
| Store Transfer | str.public.event.store-transfer-completed.v1 | the transfer leaving the sending store |
Sales — subscribing to PosLog
Sales reach STP as PosLog transactions published by the transaction service. STP reads the item lines and converts each one into a stock movement.
Two things are worth knowing if you are reconciling POS data against stock:
- Only item lines that move stock are processed.
Sale,SaleForDeliveryandReturnlines become transactions. Lines with a status ofCanceledare skipped, and line types that do not represent an item movement — deposits, tenders, discounts — are ignored. - A return does not go back into sales stock. A
SalereducesSalesStock; aReturnincreasesReturned, which is a separate stock type. Returned goods have to be inspected and put back deliberately. See The stock model.
Note: all lines of one receipt share the receipt's transaction time (
endDateTime) — the moment the receipt was closed — rather than the time each individual line was scanned. That is the official time of the sale.
Item master data from PnP
Item master data comes from Product, Price and Promotion (PnP), which is the master for items across Hii Retail. STP keeps a local copy so that processing a sale does not depend on a live lookup.
| What | Where it comes from in PnP | Used for |
|---|---|---|
| Whether and how the item is stock handled | the Stp.StockHandlingType, Stp.StockHandlingMethod and Stp.UseAverageWeightedCostPrice additional properties on the item | deciding whether to calculate stock, which batch to draw down, and how to cost the movement |
| Purchase price | the item's PURCHASE price specification | costing a movement when nothing else supplies a cost |
| Item links | the item's STRUCTURE item links | expanding bundles into their components |
If an item is not yet known locally, STP looks it up in PnP on demand and caches the result. If PnP has no such
item either, behaviour depends on the Use default values if item is unknown setting: with it enabled the movement
is still processed using defaults, so the quantity stays correct; with it disabled the movement is not stock
handled.
Note: only items of type STOCK can be stock handled, and an item's purchase price is what makes cost calculation possible. An item with no purchase price and no other cost source produces movements with a cost of 0 — see Cost calculations.
Master data is always business-unit scoped
Stock is calculated per business unit, so item master data has to be too. PnP resolves that for you. An item or a price defined globally, or on a business unit group, is published with the full list of business units it applies to — including every store that inherits it. STP stores one entry per business unit, so a store always has its own effective item configuration and its own purchase price, however that configuration was defined upstream.
There is therefore no separate "global" item state to reason about, and no inheritance for a consumer to resolve.
Because additional properties are dynamic, an external system can set any of the Stp.* properties on an item
without a change to the PnP schema — which is what makes stock configuration possible for tenants whose item data is
maintained outside Hii Retail.
Prices are always the currently valid one
A PURCHASE price specification in PnP carries a validity period, and a price can be created in advance to take
effect on a future date. STP only ever holds the price that is in effect now: PnP marks the currently valid price
as current, and publishes a fresh message when a future price becomes active. So a price change scheduled for next
month arrives twice — once when it is created, which STP ignores, and again when it takes effect, which is when STP
adopts it.
That means the purchase price STP applies to a movement is the price valid at the time the movement is processed.
Input API
The Input API accepts movements that do not already arrive from another Hii Retail service — typically from an external ERP, a warehouse system, or a customer integration.
| Endpoint | Operation |
|---|---|
POST /business-units/{businessUnitId}/synchronize-stocks | Set an absolute quantity |
POST /business-units/{businessUnitId}/stock-counts | Counted quantity, with gain/loss calculated |
POST /business-units/{businessUnitId}/stock-corrections | Damage, waste, or other adjustment |
POST /business-units/{businessUnitId}/goods-received | Receipt of a delivery |
POST /business-units/{businessUnitId}/purchase-orders | Order placed with a supplier |
POST /business-units/{businessUnitId}/order-responses | Supplier's confirmation of what will be delivered |
POST /business-units/{businessUnitId}/supplier-returns | Goods returned to the supplier |
POST /business-units/{businessUnitId}/receipts | Sales and returns |
POST /business-units/{businessUnitId}/reservations | Stock set aside for a customer |
POST /business-units/{businessUnitId}/depreciations | Adjust the cost of remaining stock |
POST /business-units/{businessUnitId}/stock-transactions | Generic transaction |
POST /stock-transfers | Transfer from one business unit to another |
POST /transfers-received | Receipt of a transfer at the destination |
See Operations for what each one means to the stock.
The Input API is for movements only. Item master data — stock-handling settings, purchase prices, item links — is maintained in PnP, which is the master for items across Hii Retail and reaches every consuming service rather than only stock. See Item master data from PnP above.
Read next
- The stock model — what a quantity means once it has been calculated
- Operations — the supported business operations in detail
- Synchronizing stock — when an external system owns the stock
- Configuration — the settings referenced above