Now let’s investigate how to pass parameters to the strategy calculation. We will begin with a pretty simple CostPlus calculation.
Let’s assume that we want to have the cost of the product and we want to calculate a price, which should be the cost plus €5 in this case.
-
Change the implementation of your strategy to accept a parameter:
Map calculatePrice( BigDecimal cost ) { BigDecimal price = cost + 5.0 return [ result : price, message : "OK", messageType : "Info" ] }-
Note: This example has no validation, so it will not check if we have a cost or not. In more complex examples you can build a logic to check this. If no cost is found, you can return a warning message for the pricing manager to investigate.
-
-
Set the Strategy Calculation Parameters:
-
Navigate to the Company Parameter PSP_EngineCalculationConfig.
-
Review the content of the Engine Calculation Parameters column for several strategies.
-
Those parameters represent the values which are passed to the strategy
calculatePricemethod, in the specified order. -
You can see there for example SKU, SECONDARY_KEY, FINAL_LIST_PRICE_ELEMENT_NAME, FINAL_PRICE_ELEMENT_NAME, DEPENDENCY_PROPERTIES, STRATEGY_NAME. For a full list, you can review the code of the element PriceManagerUtils of the calculation logic PriceBuilderCommonElementUtils, which is part of the installed Price Setting Accelerator.
-
-
For your strategy TrainingCost+, set the value for the Strategy Calculation Parameters field to "PRODUCT_COST" – this is one of the out-of-the-box parameters, so it will work only if you have a basic cost lookup configured and data is available for tested product: PSP Cost and Margin Module | Lookup.
-
-
Recalculate prices of your product in the Live Price Grid.
-
On the recalculated item, review the value of fields Cost and Final Price to make sure that the price is calculated as expected based on your strategy implementation.
-
Previous step: Set Messaging from Calculation Logic
Next step: Add Custom Parameter to Strategy Call