Custom Engines

In addition to using the predefined engines, you can also define your own strategies.

All you need to do is to place a function path to the function in some external Groovy Library (instead of an engine name in the PP StrategyDefinition), e.g. libs.MyLib.MyElement.MyFunction.

This function should return a calculated price or throw an exception. Its message will be shown in the PL/LPG.

Users may add their own parameters for the custom engine in the AdditionalCalculatorParameters element, according to the Groovy Documentation. All parameters should be closures that will be executed dynamically when needed. If the user data are already fetched and used in the PSP flow, we recommend using simple Closure, for example {return myVariable} to avoid fetching data again.

Possible return values of the engine-like function:

  • Thrown exception (will be handled and shown in Prices popup)

  • Map with keys:

    • “result” – Result as BigDecimal.

    • “message” – Message shown in the Prices popup.

    • “messageType” – How message/price will be shown. Possible values are “Info”, “Warning” and “Critical”.

    • “additionalInfo” – Values under that key will be stored in the strategy and they can be utilized for further customization.