Fluent Commerce Logo
Docs
Sign In

UpdateBaseVirtualPosition

Rule

Changed on:

9 Sept 2024

Overview

Updates a base virtual position

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 a base virtual position

Accepts

  • VIRTUAL_POSITION

Actions

  • This rule produces a MutationAction to update the virtual position effective quantity. The effective quantity is the value after adding relevant buffer values to the on-hand quantity of the corresponding inventory position.

Rule parameters

There are no Input Parameters for this rule

Event attributes

Parameter

Description

Data Type

Required?

inventoryPositionRef

Inventory position ref

String

No

virtualPositionProductRef

The product ref of this virtual position

String

Yes

virtualPositionRef

The ref of this virtual position

String

Yes

virtualPositionGroupRef

The group ref of the virtual position

String

Yes

virtualCatalogueRef

The ref of the virtual catalogue

String

Yes

virtualCatalogueInventoryCatalogueRef

The inventory catalogue ref this virtual catalogue is made of

String

Yes

virtualCatalogueProductCatalogueRef

The product catalogue ref this virtual catalogue is made of

String

Yes

virtualCatalogueControlGroupRef

The control group ref this virtual catalogue is made of

String

Yes

Exceptions

If any of the above event attributes is missing an EventAttributeNotFoundException is thrown.

Configuration example

1{
2  "name": "[[account.id]].globalinventory.UpdateBaseVirtualPosition"
3}

Language: json

Detailed Technical Description

  • The rule first fetches the corresponding inventory position of this virtual position that is to be updated with the following logic:
    • The 
      `{virtualCatalogueInventoryCatalogueRef}`
       event attribute is used to define the reference of the inventory catalogue.
    • if the
      `inventoryPositionRef`
      attribute is provided in the event attribute it will be use to load the inventory position
    • if the  
      `inventoryPositionRef`
      attribute is not provided, it will be generated using the convention => 
      `{productRef}:{locationRef}:DEFAULT`
  • Once the inventory position has been loaded, it validates the fields and raises an exception in case of any validation issues.
  • In order to create the virtual position, the quantity of the virtual position has to be calculated. This quantity is called effective quantity because this quantity is the value after adding relevant buffer values to the on-hand quantity of the corresponding inventory position. See the Quantity Calculation section for details.
  • Once the effective quantity for this virtual position is calculated, it creates the virtual position where the virtual position ref has the value of 
    `{targetVirtualPositionRef}`
     event attribute and the virtual catalogue ref has the value of 
    `{virtualCatalogueRef}`
     event attribute. The generated virtual position type will be BASE.
  • Finally, the rule generates a new inline event where 
    `{entityRef}`
     of the event is the value of 
    `{targetVirtualPositionRef}`
     event attribute of the incoming event, 
    `{entityType}`
     is VIRTUAL_POSITION and 
    `{entitySubtype}`
     is BASE.
Quantity Calculation 
  • The calculation of the effective quantity of the virtual position (of type BASE) involves querying the product's categories and controls. There are two types of controls.
  • Exclusion buffer controls
  • Quantity buffer controls
  • The rule first checks if an exclusion buffer is applicable to this virtual position. If so it will immediately stop the calculation by setting the effective quantity to 0. Therefore, the effective quantity of the new virtual position is set to 0. See the Exclusion Control Buffer Calculation for details.
  • If the rule cannot find any exclusion control buffer/s, it then proceeds to calculate the quantity buffer. Once the quantity buffer value is calculated, it is added to the on-hand value of the inventory position to calculate the effective quantity of the virtual position. If the effective quantity becomes negative after adding the quantity buffer value to the on-hand value of the inventory position, the effective quantity of the virtual position will be set to 0. The resulting value is used as the quantity of the new virtual position. See the Quantity Buffer Calculation for details.
Exclusion Control Buffer Calculation 
  • The rule fetches all the categories belonging to the product by using the 
    `{productRef}`
     and the 
    `{virtualCatalogueProductCatalogueRef}`
     incoming event attributes. Then it uses 
    `{virtualCatalogueControlGroupRef}`
     and 
    `{productRef}`
     event attributes and the list of category references to generate all the possible exclusion control references:
  • `{virtualCatalogueControlGroupRef}:EXCLUSION:{productRef}`
  • for category_ref in each category →
    • `{virtualCatalogueControlGroupRef}:EXCLUSION:{category_ref}`
  • The above step will result in one or more exclusion control references. The rule then tries to fetch controls in ACTIVE status with the above exclusion control references. If it can find at least one exclusion control the effective quantity is set to 0. Otherwise, the rule proceeds with the quantity buffer calculation
Quantity Buffer Calculation 
  • The rule fetches all the categories belonging to the product by using the 
    `{productRef}`
     and the 
    `{virtualCatalogueProductCatalogueRef}`
     incoming event attributes. Then it uses the 
    `{virtualCatalogueControlGroupRef}`
    `{locationRef}`
     and 
    `{productRef}`
     event attributes, and the list of category references to generate all the possible quantity buffer control references:
  • `{virtualCatalogueControlGroupRef}:QUANTITY_BUFFER:{productRef}:{locationRef}`
  • `{virtualCatalogueControlGroupRef}:QUANTITY_BUFFER:{productRef}`
  • `{virtualCatalogueControlGroupRef}:QUANTITY_BUFFER:{locationRef}`
  • for 
    `category_ref`
     in each category →
    • `{virtualCatalogueControlGroupRef}:QUANTITY_BUFFER:{category_ref}`
  • The above step will result in three or more quantity buffer control references. The rule then tries to fetch controls in ACTIVE status with the above quantity buffer control references. If there are controls found, the rule picks the control with the lowest 
    `executionOrder`
     after sorting them in ascending order according to the 
    `executionOrder`
     attribute of each control. If the lowest buffer control has a value, this value is used as the final buffer value and it is added to the on-hand value of the inventory position to calculate the effective quantity of the virtual position. If no quantity buffer controls are found or the lowest quantity buffer control does not have any value set, the effective quantity of the virtual position will be the same as the on-hand value of the inventory position.

Version History

2023-08-11

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