Fluent Commerce Logo
Docs
Sign In

CreateAggregateVirtualPosition

Rule

Changed on:

30 Nov 2023

Overview

Creates an aggregate virtual position including inventory positions in statuses

`{statuses}`
. Sends event
`{eventName}`
.

Plugin NameInventory Reference Module
Namespace{{accountId}}.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 Modules includes the following areas:

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

UI Description

Creates an aggregate virtual position including inventory positions in statuses {statuses}. Sends event {eventName}.

Accepts

  • VIRTUAL_CATALOGUE

Actions

  • This rule produces a MutationAction that creates a new virtual position.
  • This rule produces a SendEventAction that sends an inline event with the given name 
    `{eventName}`
     to the new virtual position.

Rule parameters

Parameter

Description

eventName

The name of event to be triggered

statuses

Status of Inventory Positions to be used in creation

Event attributes

Parameter

Description

Data Type

Required?

productRef

The product ref to load inventory positions

String

Required

targetVirtualPositionRef

The virtual position ref to be created

String

Required

virtualCatalogueRef

The ref of virtual catalogue

String

Required

virtualCatalogueInventoryCatalogueRef

The inventory catalogue ref of the virtual catalogue

String

Required

virtualCatalogueProductCatalogueRef

The product catalogue ref of the virtual catalogue

String

Required

virtualCatalogueControlGroupRef

The control group ref of the virtual catalogue

String

Required

virtualCatalogueNetworkIds

The network ids of the virtual catalogue

String array

Required

Exceptions

  • This rule throws a PropertyNotFoundException when the eventName property is not provided in workflow.
  • The rule throws a EventAttributeNotFoundException if the 
    `productRef`
    `targetVirtualPositionRef`
    `virtualCatalogueRef`
    `virtualCatalogueInventoryCatalogueRef`
    `virtualCatalogueProductCatalogueRef`
    `virtualCatalogueControlGroupRef`
    `virtualCatalogueNetworkIds`
     is not provided in the event attributes.

Configuration example

1{
2  "name": "{{accountId}}.globalinventory.CreateAggregateVirtualPosition",
3  "props": {
4    "eventName": "CREATE",
5    "statuses": ["ACTIVE"]
6  }
7}

Language: json

Detailed Technical Description

  • Load all locations for the network of the virtual catalogue.
    • Get the first network ref of the virtual catalogue from the event attributes (Limitation: only supports the first network of the virtual catalogue).
    • Get all the location refs in the network by network ref (as 
      `{result set 1}`
      ).
  • Load all the inventory positions.
    • Query inventory positions (as 
      `{result set 2}`
      ) by 
      `{productRef}`
       (from event attributes), location refs (
      `{result set 1}`
      ), inventory position statuses (workflow input parameter) and the inventory catalogue ref of the virtual catalogue (event attributes).
    • If inventory position status is not ACTIVE (case insensitive), then the onHand quantity (
      `locationOnHand`
      ) for the product in the location is set to 0.
    • Otherwise, the onHand quantity for the location is the original quantity.
  • Calculate the aggregate quantity for the new virtual position.
    • Get the categories for the variant product by product ref and product catalogue ref (Limitation: it only returns the first 10 categories).
    • For each location ref in 
      `{result set 1}`
      • If the location ref is in the location refs of the inventory positions (
        `{result set 2}`
        ), then
        • Exclusion control calculation: If it has any ACTIVE exclusion controls for the corresponding inventory position, then the onHand quantity for the location is 0.
          • The exclusion controls includes:
            • Category exclusion control ref naming convention: 
              `{controlGroupRef}:EXCLUSION:{categoryRef}`
            • Product exclusion control ref naming convention: 
              `{controlGroupRef}:EXCLUSION:{productRef}`
        • Other control calculation: Else calculate the buffer control for the location.
          • Load all the possible ACTIVE controls for the inventory which includes:
            • Inventory control ref naming convention: 
              `{controlGroupRef}:QUANTITY_BUFFER:{productRef}:{locationRef}`
            • Product control ref naming convention: 
              `{controlGroupRef}:QUANTITY_BUFFER:{productRef}`
            • Category control ref naming convention: 
              `{controlGroupRef}:QUANTITY_BUFFER:{categoryRef}`
               (could be multiple category controls)
            • Location control ref: naming convention: 
              `{controlGroupRef}:QUANTITY_BUFFER:{locationRef}`
          • Sort all the controls by executionOrder in ascending order.
          • Only apply the first control buffer to the onHand quantity: locationOnHand = locationOnHand + controlBuffer
          • After apply the control buffers, if the onHand quantity is less than 0, then set the quantity to 0.
        • Add the location level onHand quantity (after apply control buffers) to the aggregate onHand quantity: aggregateOnHand = aggregateOnHand + locationOnHand
      • Else skip the location ref.
    • Apply master buffer control after aggregate all location level inventories
      • Get and apply the ACTIVE master control buffer value.
        • Master control ref naming convention: 
          `{controlGroupRef}:MASTER_BUFFER:{productRef}`
      • After apply the master control buffer, if the aggregate onHand quantity is less than 0, then set the quantity to 0.
  • The rule produces a MutationAction that creates a new virtual position with the aggregate quantity.
  • The rule produces a SendEventAction that sends an inline event with the given name 
    `{eventName}`
     to the new virtual position.

Version History

2023-07-28

v2.0.0

refers to the plugin

Copyright © 2024 Fluent Retail Pty Ltd (trading as Fluent Commerce). All rights reserved. No materials on this docs.fluentcommerce.com site may be used in any way and/or for any purpose without prior written authorisation from Fluent Commerce. Current customers and partners shall use these materials strictly in accordance with the terms and conditions of their written agreements with Fluent Commerce or its affiliates.

Fluent Logo