You are here:
CustomPricingPlanStepImplementation
Given a set of line items and attributes, use the pricing matrix to determine their prices. Called using VlocityOpenInterface.
Type
Strongly typed
Triggered When
A custom pricing step that calls CustomPricingPlanStepImpl is executed.
Called In
The PricingPlanService class.
Default Implementation
The CustomPricingPlanStepImplementation calls the GetMatrixPrice method, which contains the logic for using the pricing matrix to determine the price for a specified product and set of attributes.
Other Implementations
None
Input Parameters
A map containing the following key/value pairs:
-
ProcedureName: (Required) The name of the calculation procedure containing the matrix.
-
MatrixName: (Required) The name of the matrix containing the attribute-based prices.
-
RangeFields: (Optional) Used in range pricing. Semicolon-delimited list of numeric line item fields.
-
RangeAttributes: (Optional) Used in range pricing. Semicolon-delimited list of numeric range attributes.
-
Path{n}: (Optional) Used in target pricing to disambiguate products that have the same name. Path format: RootProduct<Parent1<Parent2<...<Product
Output Parameters
A map containing the pricing results for the specified products and attributes.
Sample Implementation
global with sharing class CustomPricingPlanStepImpl implements vlocity_cmt.VlocityOpenInterface {
global Boolean invokeMethod(String methodName,
Map<String, Object> input,
Map<String, Object> output,
Map<String, Object> options) {
if (methodName == 'GetMatrixPrice') {
getMatrixPrice(input, output, options);
}
return true;
}
private void getMatrixPrice(Map<String, Object> input,
Map<String, Object> output,
Map<String, Object> options) {
SObject parent = (SObject) vlocity_cmt.PricingPlanService.getFromPricingContext('Parent');
List<SObject> itemList = (List<SObject> ) vlocity_cmt.PricingPlanService.getFromPricingContext('LineItemList');
// Do nothing if there are no items
if (itemList == null || itemList.isEmpty()) return;
// If this is the first getMatrixPrice step, clear the external price flag
Boolean clearExternalPriceFlag = (Boolean) vlocity_cmt.PricingPlanService.getFromPricingContext('ClearExternalPriceFlag');
System.debug('ClearExternalPriceFlag: ' + clearExternalPriceFlag);
if (clearExternalPriceFlag == null) {
clearExternalPriceFlag = true;
// Do not clear the external price flag for subsequent calls to getMatrixPrice
vlocity_cmt.PricingPlanService.putInPricingContext('ClearExternalPriceFlag', false);
}
Map<String, Object> priceHelperInput = new Map<String, Object> ();
Map<String, Object> priceHelperOutput = new Map<String, Object> ();
Map<String, Object> priceHelperOptions = new Map<String, Object> ();
priceHelperInput.put('Parent', parent);
priceHelperInput.put('ItemList', itemList);
priceHelperInput.put('ClearExternalPriceFlag', clearExternalPriceFlag);
priceHelperInput.putAll(input);
// create the matrix input rows from the itemList
PricingPlanHelper priceHelper = new PricingPlanHelper();
priceHelper.invokeMethod('GetCalculationProcedurePrice', priceHelperInput, priceHelperOutput, priceHelperOptions);
if (priceHelperOutput.get('error') != null) {
output.put('error', priceHelperOutput.get('error'));
}
}
}
