Fluent Commerce Logo
Docs
Sign In

UpdateAggregateVirtualPosition

Rule

Changed on:

8 Apr 2025

Overview

Update an Aggregate Virtual Position and calculate its Available-to-Sell (ATS) quantity.

Aggregate Virtual Position ATS calculation is based on the associated Inventory Positions Stock on Hand (SOH) quantities and the applied Controls.

The associated Inventory Positions are defined with:

  • The given Product Reference
  • The list of Locations for the given Network (the first Network assigned to the Virtual Catalog)
  • The specified Inventory Position Statuses
Plugin NameInventory Reference Module
Namespace[[account.id]].globalinventory

The Inventory Reference Module is the foundation for inventory related implementations. It provides reference Workflows for inventory ingestion and processing. Extensible by design, use this Module as a base to build a solution to the needs of your customers.

The Inventory Module includes the following areas:

  • Product Catalogue workflow
  • Inventory Catalogue workflow
  • Control Group workflow
  • Virtual Catalogue workflow

UI Description

Updates an aggregate virtual position including inventory positions in the given {statuses}.

Accepts

  • VIRTUAL_POSITION

Actions

  • This Rule produces a MutateAction that updates the target Aggregate Virtual Position ATS quantity.

Rule parameters

Name

Data Type

Description

statuses

List<String>

Statuses of the Inventory Positions to be used for Aggregate Virtual Position ATS calculation

Event attributes

Parameter

Description

Data Type

Required?

virtualPositionRef

Virtual Position Reference

String

Required

virtualPositionProductRef

Product Reference of the Virtual Position

String

Required

virtualPositionGroupRef

Group Reference of the Virtual Position

String

Required

virtualCatalogueRef

Reference of the Virtual Catalog

String

Required

virtualCatalogueInventoryCatalogueRef

Reference of the Inventory Catalog associated with the Virtual Catalog

String

Required

virtualCatalogueProductCatalogueRef

Reference of the Product Catalog associated with the Virtual Catalog

String

Required

virtualCatalogueControlGroupRef

Reference of the Control Group associated with the Virtual Catalog

String

Optional

virtualCatalogueNetworkIds

Network IDs of the Virtual Catalog

List<String>

Required

Exceptions

  • This Rule throws a
    `PropertyNotFoundException`
    when the Rule parameter(s) is not provided.
  • This Rule throws an 
    `EventAttributeNotFoundException`
     when the required Event attribute(s) is not provided.

Configuration example

1{
2  "name": "[[account.id]].globalinventory.UpdateAggregateVirtualPosition",
3  "props": {
4    "statuses": [
5        "ACTIVE",
6        "AT_RISK",
7        "OUT_OF_STOCK"
8    ]
9  }
10}

Language: json

Detailed Technical Description

This Rule performs the following steps during execution:

  • Retrieve Contextual Data
    • The Rule extracts the Aggregate Virtual Position and associated Catalog data from the Event attributes.
  • Determine Relevant Inventory Positions
    • The Rule identifies Inventory Positions that contribute to the Aggregate Virtual Position being updated.
    • It loads a list of Location References from the Network linked to the specified Virtual Catalog. Only the first Network from the
      `virtualCatalogueNetworkIds`
      event attribute is considered.
    • It queries Inventory Positions using the following criteria:
      • The Inventory Catalog Reference from the
        `virtualCatalogueInventoryCatalogueRef`
        Event Attribute
      • The Product Reference from the
        `virtualPositionProductRef`
        Event Attribute
      • The list of Location References obtained in the previous step
      • The Inventory Position Statuses specified by the Rule's
        `statuses`
        parameter
  • Recalculate ATS Quantity
    • The Rule calculates the updated ATS (Available to Sell) quantity for the Aggregate Virtual Position.
    • This is based on the total SOH (Stock on Hand) from the matched Inventory Positions, applying any relevant Controls.
    • If no Controls are present, the ATS is simply the total on-hand quantity.
    • The calculation logic is identical to that used in the CreateAggregateVirtualPosition Rule and is described in the section below.
  • Update the Aggregate Virtual Position
    • The Rule produces a MutateAction to update the existing Aggregate Virtual Position with the newly calculated ATS quantity.

Version History

2025-04-14

v2.2.1

Rule changes:

  • Now apply control-specific logic only if the event includes a Control Group reference.
  • Skip all control-related validation and logic if no such reference is present in the event payload.
2024-10-28

v.24.10.28

This Rule has been optimized to load all the related Controls (by Product, its Categories, and list of Locations) at once for efficient Aggregate Virtual Position Available-to-Sell (ATS) calculations.

The Rule Version refers to the Product Release Version.

2023-08-03

v2.0.0

refers to the plguin