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 sets the Net_Bill_Amount__c field on Estimate Product Instance or
* the Bill_Amount_Independent_Records__c field on Estimate to 10,000 and distributes the value
* evenly across all child role requests.
*/
global with sharing class SimpleFixedPricingPlugin extends ffscpq.ConfigurablePricingPlugin.AbstractConfigurablePricingPlugin {
private static final Decimal FIXED_TOTAL_AMOUNT = 10000;
global SimpleFixedPricingPlugin() {
}
global override List<ffscpq.ConfigurablePricingPlugin.Response> calculate(
List<ffscpq.ConfigurablePricingPlugin.Request> requests
) {
List<ffscpq.ConfigurablePricingPlugin.Response> responses = new List<ffscpq.ConfigurablePricingPlugin.Response>();
for (ffscpq.ConfigurablePricingPlugin.Request request : requests) {
ffscpq.ConfigurablePricingPlugin.Response response = new ffscpq.ConfigurablePricingPlugin.Response();
List<ffscpq__Estimate_Role_Request__c> roleRequests = request.getRoleRequests();
if (roleRequests == null || roleRequests.isEmpty()) {
response.setRoleRequestBillAmounts(new List<Decimal>());
responses.add(response);
continue;
}
// Calculate amount per role request
Integer numberOfRoleRequests = roleRequests.size();
Decimal amountPerRoleRequest = FIXED_TOTAL_AMOUNT / numberOfRoleRequests;
// Create list of bill amounts (same amount for each role request)
List<Decimal> billAmounts = new List<Decimal>();
for (Integer i = 0; i < numberOfRoleRequests; i++) {
billAmounts.add(amountPerRoleRequest);
}
response.setRoleRequestBillAmounts(billAmounts);
responses.add(response);
}
return responses;
}
global override List<ffscpq.ConfigurablePricingPlugin.PricingFieldWrapper> getPricingFields() {
// No fields affect this calculation since we always return 10,000
return new List<ffscpq.ConfigurablePricingPlugin.PricingFieldWrapper>();
}
}
Methods
calculateglobal abstract List<ffscpq.ConfigurablePricingPlugin.Response> calculate(List<ffscpq.ConfigurablePricingPlugin.Request> requests) Abstract method to be implemented by subclasses for calculating pricing logic. This is called once per transaction and groups each estimate product instance and independent records into a single request. 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 all the role requests on the associated estimate product instance or of all the associated role requests independent of estimate products 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
|