Services Estimator API Developer Reference

ffscpq.ConfigurablePricingPlugin

global with sharing class ConfigurablePricingPlugin

A class that contains plugins for configurable pricing.

ffscpq.ConfigurablePricingPlugin.AbstractConfigurablePricingPlugin

global with sharing abstract class AbstractConfigurablePricingPlugin

Provides an extension point for creating plugins to be executed when configuring pricing.
To set up a plugin, create an Estimate Pricing Method record with an Apex Plugin Class Name that matches an Apex class that extends ffscpq.ConfigurablePricingPlugin.AbstractConfigurablePricingPlugin.
The code snippet below demonstrates a plugin implementation for configuring the pricing of role requests.

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.
        // Each request represents one estimate product instance.
        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

calculate

global 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 into a single request.

Input Parameters

Name Type Description
requests List<ffscpq.ConfigurablePricingPlugin.Request> List of ConfigurablePricingPlugin.Request.

Return Value

List of pricing ConfigurablePricingPlugin.Response.

getPricingFields

global 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 Value

List of ConfigurablePricingPlugin.PricingFieldWrapper.

ffscpq.ConfigurablePricingPlugin.IConfigurablePricingPlugin

global interface IConfigurablePricingPlugin

Deprecated: see ConfigurablePricingPlugin.AbstractConfigurablePricingPlugin

Methods

calculate

List<ConfigurablePricingPlugin.Response> calculate(List<ffscpq.ConfigurablePricingPlugin.Request> requests)

ffscpq.ConfigurablePricingPlugin.Request

global with sharing class Request

The request structure for configuring the pricing of estimate records.

Methods

getRoleRequests

global List<ffscpq__Estimate_Role_Request__c> getRoleRequests()

Returns the list of all the role requests on the associated estimate product instance to be configured by the plugin.

ffscpq.ConfigurablePricingPlugin.Response

global with sharing class Response

The response structure for configuring the pricing of the estimate records.

Methods

Response

global Response()

setRoleRequestBillAmounts

global void setRoleRequestBillAmounts(List<Decimal> roleRequestBillAmounts)

Sets the bill amounts on the corresponding role requests provided in the request.

Input Parameters

Name Type Description
roleRequestBillAmounts List<Decimal> The list of bill amounts to be set on the corresponding role requests provided in the request.

ffscpq.ConfigurablePricingPlugin.PricingFieldWrapper

global with sharing class PricingFieldWrapper

A fields class used to specify an SObject type and the set of related required fields for configuring pricing.

Properties

Name Type Description
objectType SObjectType The type of SObject containing the specified fields.
fields Set<SObjectField> The set of required fields from the SObject needed for pricing calculations.

Methods

PricingFieldWrapper

global PricingFieldWrapper()

Creates an empty PricingFieldWrapper object.

PricingFieldWrapper

global PricingFieldWrapper(SObjectType objectType, Set<SObjectField> fields)

Initializes a PricingFieldWrapper with the SObject type and fields required for pricing calculations.

Input Parameters

Name Type Description
objectType SObjectType The type of SObject containing the specified fields.
fields Set<SObjectField> The set of required fields from the SObject needed for pricing calculations.
© Copyright 2009–2025 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.