Create a Custom Ruleset for Batch Inventory Input for Custom Quantity Types
Author:
Girish Padmanabha
Changed on:
18 Feb 2025
Key Points
- Preprocessing Disabled (Skip Enabled): If preprocessing is disabled (set to skip), all event items are passed as is, regardless of changes.
- Preprocessing Enabled: If preprocessing is enabled, only changed items are passed through as events.
- Event Structure: The batch input includes optional fields, and default values are set if they are not provided.
- Event Name: If you specify a custom event name in the batch input, it will be used in the resulting event. If not, the default event name is .
`"InventoryChanged"`
Steps
Steps to Create a Custom Ruleset for Batch Inventory Input for Custom Quantity Types
Step 1 : Prepare Your Batch Inventory Input Payload
- Structure your batch inventory input according to the format provided below.
- Include the field with your custom event name if desired.
`event`
1{
2 "action": "UPSERT",
3 "entityType": "INVENTORY",
4 "source": "your-batch-source",
5 "event": "YourCustomEventName", // Optional, defaults to "InventoryChanged"
6 "catalogueRef": "<inventoryCatalogRef>", // Optional, defaults to "DEFAULT:<retailerId>"
7 "entities": [
8 {
9 "locationRef": "LOC1",
10 "skuRef": "SKU1",
11 "qty":40,
12 "correctedQty": 0,
13 "type": "PURCHASE_ORDER", // Optional
14 "ref": "SKU1:LOC1:FUTURE:PURCHASE_ORDER:1234", // Optional
15 "status": "ACTIVE", // Optional
16 "retailerId": <retailerId>,
17 "attributes": { // Optional
18 "expectedOn": "2024-11-30T00:00:00.00Z", // Optional
19 "storageAreaRef": "LOC1-SR2", // Optional
20 "condition": "NEW" // Optional
21 }
22 }
23 // Additional entities can be included here
24 ]
25}
26
Language: json
Name: Example Batch Input Payload:
Description:
Example Batch Input Payload:
`
`
- Optional Fields and Defaults:
- : If not provided, defaults to
`event`
.`"InventoryChanged"`
- : If not provided, defaults to
`catalogueRef`
.`"DEFAULT:<retailerId>"`
- ,
`ref`
, and`type`
: Optional and passed through if provided.`status`
- Attributes: Optional . Use the object within each entity to pass extra data, which will be included in the resulting event.
`attributes`
Step 2: Understand How the Batch Input Translates to Events
Event Generation: Each entity in the batch input is translated into an event.
Preprocessing Behavior:
- Preprocessing Disabled (Skip Enabled): All entities are passed through as events, regardless of changes.
- Preprocessing Enabled: Only entities that are deemed changed are passed through as events.
1{
2 "name": "YourCustomEventName", // Or "InventoryChanged" if not specified
3 "retailerId": "<retailerId>",
4 "entityRef": "<inventoryCatalogRef>",
5 "entityType": "INVENTORY_CATALOGUE",
6 "entitySubtype": "<inventoryCatalogType>",
7 "accountId": "<accountId>",
8 "source": "your-batch-source",
9 "attributes": {
10 "inventoryPosition": {
11 "ref" :"LOC1:SKU1",
12 "productRef": "SKU1",
13 "locationRef": "LOC1",
14 "qty": 40,
15 "correctedQty": 0,
16 "inventoryQuantity": {
17 "qty": 40,
18 "ref": "SKU1:LOC1:FUTURE:PURCHASE_ORDER:1234", // If provided
19 "type": "PURCHASE_ORDER", // If provided
20 "status": "ACTIVE", // If provided
21 "attributes": {
22 "expectedOn": "2024-11-30T00:00:00.00Z",// If provided
23 "storageAreaRef": "LOC1-SR2",// If provided
24 "condition": "NEW" // If provided
25 }
26 }
27 }
28 }
29}
30
Language: json
Name: Resulting Event
Description:
Resulting Event in the Inventory Catalog workflow
Step 3: Create a Custom Ruleset
Develop a custom ruleset that will process your custom event name and handle the custom quantity types or additional data included in
`inventoryQuantity.attributes`
- Is present in the Inventory Catalog workflow of the right type
- Processes the to handle custom quantity types.
`inventoryQuantity.attributes`
- Applies any business logic required for your specific use case.
Here is an example that mimics the InventoryChanged ruleset and has similar rules as the entry point from the Batch payload
1 {
2 "name": "YourCustomEventName",
3 "description": "Process Inventory sample ruleset",
4 "type": "INVENTORY_CATALOGUE",
5 "subtype": "DEFAULT",
6 "eventType": "NORMAL",
7 "rules": [
8 {
9 "name": "{{fluentAccountId}}.globalinventory.LoadInventoryPositionData",
10 "props": {
11 "eventName": "CheckInventoryPositionExists"
12 }
13 }
14 ],
15 "triggers": [
16 {
17 "status": "CREATED"
18 },
19 {
20 "status": "ACTIVE"
21 },
22 {
23 "status": "INACTIVE"
24 }
25 ],
26 "userActions": []
27 },
Language: json
Name: Sample ruleset for alternate entry point from Batch Payload
Description:
By adding this ruleset to the workflow, you provide an alternative entry point for events originating from inventory batch payloads. The example name YourCustomEventName can be replaced, but ensure your ruleset manages and processes the events as defined in the event contract.
Step 4: Configure the Batch Job Settings
- Disable Preprocessing (Skip Enabled): If you want all entities to be passed through as events, regardless of changes, set preprocessing to skip.
- Enable Preprocessing: If you want only changed entities to be passed through, keep preprocessing enabled.
- Set the Preprocessing Option in your batch job settings according to your needs.
Step 5: Deploy and Use Your Custom Ruleset
Submit your batch inventory input using the prepared payload.The system will generate events for each entity based on your preprocessing settings.Your custom ruleset will process the events, handling the custom quantity types and additional attributes as defined.