Fluent Commerce Logo
Docs
Sign In

CreateBaseVirtualPositionIfNotPresent

Rule

Changed on:

29 Nov 2023

Overview

Checks if a Virtual Position does not exist, if the Virtual Position does not exist it will create a new Virtual Position with the matching attributes

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

Checks if a Virtual Position does not exist, if the Virtual Position does not exist it will create a new Virtual Position with the matching attributes

Accepts

  • VIRTUAL_CATALOGUE

Actions

  • If a corresponding base virtual position does not exist, this rule will produce a MutationAction to create a new virtual position. If a virtual position already exists, no action is triggered from this rule.

Rule parameters

Not required for this rule

Event attributes

Parameter

Description

Data Type

Required?

productRef

The product ref of this virtual position

String

Required

locationRef

The location ref of this virtual position

String

Required

Exceptions

  • An EventAttributeNotFoundException will be produced if either no attributes are defined, on the entity, or if 
    `locationRef`
     or 
    `productRef`
     are not defined on the entity.

Configuration example

1{
2  "name": "{{AccountID}}.globalinventory.CreateBaseVirtualPositionIfNotPresent"
3}

Language: json

Detailed Technical Description

  • The rule will start by reading the 
    `locationRef`
     and 
    `productRef`
     from the event attributes, and the 
    `virtualCatalogueRef`
     as the entity ref. The 
    `virtualCatalogueRef`
     can be determined as the entity ref of the event target entity.
  • The rule can then use these fields to determine the reference for the base VP this catalogue update targets:

`final String targetVirtualPositionRef = String.join(COLON, productRef, locationRef, BASE);`

  • Once the VP ref is determined, we can check for the existence of a virtual position matching the event details:

`virtualService.getVirtualPositionAndVirtualCatalogueByRef(virtualCatalogueRef, targetVirtualPositionRef)`

The result of the above call can be examined to determine whether a virtual position exist or not

  • If a virtual position exists, the rule stops processing with no actions
  • If a virtual position does not exist, 
    `virtualService.createVirtualPosition`
     is called to create it
    • ATS quantity does not need to be calculated here as the 
      `UpdateBaseVirtualPosition`
       rule is responsible for setting this value on the position. For the create event, ATS can be set to 0.

Version History

2023-07-28

v2.0.0

refers to 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