Skip to main content

Stock count completed — event schema

This is the published JSON schema for stc.public.event.stock-count-completed.v1, the event Stock Count publishes when a count is submitted. The same document is served at

https://raw.githubusercontent.com/extenda/hiiretail-json-schema-registry/master/external-events/stc/stc.public.event.stock-count-completed.v1.json

The schema says what a message may contain. What the fields mean — which quantities are levels, which timestamp to order by, how a large count is split across several messages, and what to use as a deduplication key — is described in Events. Read that page before building a consumer; the schema alone does not tell you, for example, that one count can arrive as several messages.

Two things the schema does encode, and that trip validators:

  • The root object does not allow unknown fields (additionalProperties: false), and neither do the item, location and line objects (unevaluatedProperties: false). An optional field can still be added to this version, because that is not a breaking change, and the schema gains it before any event carries it. So validate against the current published schema rather than a copy you saved, and ignore fields you do not recognise. A new version is published only for a breaking change — a field removed, renamed, retyped or made required.
  • Enumerations can still grow. Handle a type value you do not recognise rather than rejecting the message.
{
"$id": "hiiretail.contracts.logistics.stc.public.event.stock-count-completed.v1",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "StockCountCompleted",
"description": "Contains details on the completed stock count",
"type": "object",
"required": [
"tenantId",
"businessUnitId",
"stockCountId",
"type",
"submittedAt",
"submittedBy",
"numberOfItemsCounted",
"numberOfItemsNotCounted",
"items",
"messageNumber",
"lastMessageNumber"
],
"additionalProperties": false,
"properties": {
"tenantId": {
"type": "string",
"description": "Id of tenant"
},
"businessUnitId": {
"type": "string",
"description": "Id of business unit"
},
"stockCountId": {
"type": "string",
"description": "Id of the performed stock count"
},
"type": {
"enum": [
"FULL",
"CYCLE",
"CONTROL",
"TEST"
],
"description": "Type of the stock count"
},
"submittedAt": {
"type": [
"null",
"string"
],
"format": "date-time",
"description": "Datetime to indicate when stock count was submitted"
},
"submittedBy": {
"type": [
"null",
"string"
],
"description": "User id for the user who submitted the stock count"
},
"comment": {
"type": [
"null",
"string"
],
"description": "Comment for the stock count"
},
"numberOfItemsCounted": {
"type": "number",
"description": "Number of items counted"
},
"numberOfItemsNotCounted": {
"type": "number",
"description": "Number of items not counted"
},
"expectedCostAmount": {
"type": [
"number",
"null"
],
"description": "Expected cost amount of stock count"
},
"actualCostAmount": {
"type": [
"number",
"null"
],
"description": "Actual cost amount of stock count"
},
"firstCountedDateTime": {
"type": [
"null",
"string"
],
"format": "date-time",
"description": "First time entity was counted"
},
"lastCountedDateTime": {
"type": [
"null",
"string"
],
"format": "date-time",
"description": "Last time entity was counted"
},
"messageNumber": {
"type": "number",
"description": "Batch number of the message. Starts from 1. Each batch will have 1000 items."
},
"lastMessageNumber": {
"type": "number",
"description": "Last batch number of the message."
},
"items": {
"type": "array",
"description": "Items being counted",
"items": {
"$ref": "#/$defs/StockCountItem"
}
}
},
"$defs": {
"StockCountItem": {
"description": "Represents an item being counted",
"type": "object",
"unevaluatedProperties": false,
"allOf": [
{
"anyOf": [
{
"required": [
"itemId",
"itemIdentifier"
],
"properties": {
"itemId": {
"type": "string",
"description": "Id of the item being counted. At least one of `itemId` or `itemIdentifier` is present"
},
"itemIdentifier": {
"type": "null",
"description": "Id of the item being counted. At least one of `itemId` or `itemIdentifier` is present"
}
}
},
{
"required": [
"itemId",
"itemIdentifier"
],
"properties": {
"itemId": {
"type": "null",
"description": "Id of the item being counted. At least one of `itemId` or `itemIdentifier` is present"
},
"itemIdentifier": {
"type": "string",
"description": "Id of the item being counted. At least one of `itemId` or `itemIdentifier` is present"
}
}
},
{
"required": [
"itemId",
"itemIdentifier"
],
"properties": {
"itemId": {
"type": "string",
"description": "Id of the item being counted. At least one of `itemId` or `itemIdentifier` is present"
},
"itemIdentifier": {
"type": "string",
"description": "Id of the item being counted. At least one of `itemId` or `itemIdentifier` is present"
}
}
}
]
},
{
"type": "object",
"required": [
"locations"
],
"properties": {
"itemName": {
"type": [
"string",
"null"
],
"description": "Name of the item being counted"
},
"expectedQuantity": {
"type": [
"number",
"null"
],
"description": "Expected entity stock count quantity"
},
"expectedCostAmount": {
"type": [
"number",
"null"
],
"description": "Expected entity cost amount"
},
"unitCostPrice": {
"type": [
"number",
"null"
],
"description": "Unit cost price of the item being counted"
},
"locations": {
"type": "array",
"description": "Locations of the item being counted",
"items": {
"$ref": "#/$defs/StockCountLocation"
}
}
}
},
{
"$ref": "#/$defs/StockCountData"
}
]
},
"StockCountLocation": {
"description": "Represents a location for an item being counted",
"type": "object",
"unevaluatedProperties": false,
"allOf": [
{
"type": "object",
"required": [
"location",
"lines"
],
"properties": {
"location": {
"type": "string",
"description": "Name of the location"
},
"lines": {
"type": "array",
"description": "Lines of the location",
"items": {
"$ref": "#/$defs/StockCountLine"
}
}
}
},
{
"$ref": "#/$defs/StockCountData"
}
]
},
"StockCountLine": {
"description": "Represents a line for an item being counted",
"type": "object",
"unevaluatedProperties": false,
"allOf": [
{
"type": "object",
"required": [
"lineId",
"actualQuantity",
"countedDateTime"
],
"properties": {
"lineId": {
"type": "string",
"description": "Identifier of the line"
},
"itemIdentifier": {
"type": [
"string",
"null"
],
"description": "Identifier of the item"
},
"businessPartnerId": {
"type": "string",
"description": "Id of the business partner"
},
"batchNumber": {
"type": "string",
"description": "Batch number of the item"
},
"serialNumber": {
"type": "string",
"description": "Serial number of the item"
},
"unitCostPrice": {
"type": [
"number",
"null"
],
"description": "Unit cost price of the item"
},
"actualQuantity": {
"type": "number",
"description": "Actual quantity of the item"
},
"countedDateTime": {
"type": [
"null",
"string"
],
"format": "date-time",
"description": "Date and time when the item was counted"
}
}
}
]
},
"StockCountData": {
"description": "Contains the data of stock count",
"type": "object",
"required": [
"firstCountedDateTime",
"lastCountedDateTime"
],
"properties": {
"actualCostAmount": {
"type": [
"number",
"null"
],
"description": "Actual entity cost amount"
},
"firstCountedDateTime": {
"type": [
"null",
"string"
],
"format": "date-time",
"description": "First time entity was counted"
},
"lastCountedDateTime": {
"type": [
"null",
"string"
],
"format": "date-time",
"description": "Last time entity was counted"
},
"actualQuantity": {
"type": "number",
"description": "Actual entity stock count quantity"
}
}
}
}
}

Events · Introduction