ffscpq.ConfigurablePricingPluginglobal with sharing class ConfigurablePricingPlugin A class that contains plugins for configurable pricing. ffscpq.ConfigurablePricingPlugin.AbstractConfigurablePricingPluginglobal with sharing abstract class AbstractConfigurablePricingPlugin Provides an extension point for creating plugins to be executed when configuring pricing. Sample Code
//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.
/**
* This pricing plugin uses the Price_Per_Employee__c custom currency field to set a fixed price bill amount for role requests on estimate product instances.
* It calculates and populates the bill amount for each role request based on the value of this field.
*/
global with sharing class PricePerEmployeeCalculationPlugin extends ffscpq.ConfigurablePricingPlugin.AbstractConfigurablePricingPlugin {
global PricePerEmployeeCalculationPlugin() {
}
global override List<ffscpq.ConfigurablePricingPlugin.PricingFieldWrapper> getPricingFields() {
List<ffscpq.ConfigurablePricingPlugin.PricingFieldWrapper> fieldWrapper = new List<ffscpq.ConfigurablePricingPlugin.PricingFieldWrapper>();
// Adds the Price_Per_Employee__c field from the estimate product instance to the list of pricing fields.
fieldWrapper.add(
new ffscpq.ConfigurablePricingPlugin.PricingFieldWrapper(
ffscpq__Estimate_Product_Instance__c.SObjectType,
new Set<SObjectField>{
ffscpq__Estimate_Product_Instance__c.ffscpq__Price_Per_Employee__c
}
)
);
return fieldWrapper;
}
global override List<ffscpq.ConfigurablePricingPlugin.Response> calculate(
List<ffscpq.ConfigurablePricingPlugin.Request> requests
) {
List<ffscpq.ConfigurablePricingPlugin.Response> responses = new List<ffscpq.ConfigurablePricingPlugin.Response>();
// Iterates through each pricing request and creates a corresponding response object.
for (ffscpq.ConfigurablePricingPlugin.Request request : requests) {
ffscpq.ConfigurablePricingPlugin.Response response = new ffscpq.ConfigurablePricingPlugin.Response();
// Calculates and sets the bill amounts for each role request.
response.setRoleRequestBillAmounts(
getRoleRequestBillAmounts(request.getRoleRequests())
);
responses.add(response);
}
return responses;
}
private List<Decimal> getRoleRequestBillAmounts(
List<ffscpq__Estimate_Role_Request__c> roleRequests
) {
List<Decimal> roleRequestBillAmounts = new List<Decimal>();
if (roleRequests == null || roleRequests.isEmpty()) {
return roleRequestBillAmounts;
}
for (ffscpq__Estimate_Role_Request__c roleRequest : roleRequests) {
Decimal price = 0;
// Retrieves the Price_Per_Employee__c and adds it to the results list for each role request.
if (roleRequest.ffscpq__Estimate_Product__c != null) {
price = roleRequest.ffscpq__Estimate_Product__r.ffscpq__Price_Per_Employee__c ?? 0;
}
roleRequestBillAmounts.add(price);
}
return roleRequestBillAmounts;
}
}
Methods
calculateglobal abstract List<ffscpq.ConfigurablePricingPlugin.Response> calculate(List<ffscpq.ConfigurablePricingPlugin.Request> requests) Abstract method to be implemented by subclasses for calculating pricing logic. Input Parameters
Return ValueList of pricing ConfigurablePricingPlugin.Response. getPricingFieldsglobal virtual List<ffscpq.ConfigurablePricingPlugin.PricingFieldWrapper> getPricingFields() Returns the list of fields that when edited, trigger price recalculation. By default, it returns an empty list. Plugins can override this method to specify relevant fields. Return ValueList of ConfigurablePricingPlugin.PricingFieldWrapper. ffscpq.ConfigurablePricingPlugin.IConfigurablePricingPluginglobal interface IConfigurablePricingPlugin Deprecated: see ConfigurablePricingPlugin.AbstractConfigurablePricingPlugin MethodscalculateList<ConfigurablePricingPlugin.Response> calculate(List<ffscpq.ConfigurablePricingPlugin.Request> requests) ffscpq.ConfigurablePricingPlugin.Requestglobal with sharing class Request The request structure for configuring the pricing of estimate records. MethodsgetRoleRequestsglobal List<ffscpq__Estimate_Role_Request__c> getRoleRequests() Returns the list of role requests to be configured by the plugin. ffscpq.ConfigurablePricingPlugin.Responseglobal with sharing class Response The response structure for configuring the pricing of the estimate records. MethodsResponseglobal Response() setRoleRequestBillAmountsglobal void setRoleRequestBillAmounts(List<Decimal> roleRequestBillAmounts) Sets the bill amounts on the corresponding role requests provided in the request. Input Parameters
ffscpq.ConfigurablePricingPlugin.PricingFieldWrapperglobal with sharing class PricingFieldWrapper A fields class used to specify an SObject type and the set of related required fields for configuring pricing. Properties
Methods
PricingFieldWrapperglobal PricingFieldWrapper(SObjectType objectType, Set<SObjectField> fields) Initializes a PricingFieldWrapper with the SObject type and fields required for pricing calculations. Input Parameters
|