Professional Services Automation Apex API Developer Reference

pse.RateCardMatchingService

global with sharing class RateCardMatchingService

Service providing methods to match rate cards to RateCardMatcherItems.

Enums

DatedResourceRateType

Value Description
DATED_RATE_COST Dated resource cost rate card.
DATED_RATE_BILL Dated resource bill rate card.
FIXED_RATE Rate card without dated resource rates.

Methods

getDatedResourceRateType

global static pse.RateCardMatchingService.DatedResourceRateType getDatedResourceRateType(String rateTypeAsString)

Get the RateCardType for a given string. Null strings are treated as FIXED_RATE RateCardTypes.

Input Parameters

Name Type Description
rateTypeAsString String The string to get the RateCardType for.

Return Value

Returns the RateCardType for the given string. Will return null if given an unrecognized string.

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.

pse__Rate_Card__c aRateCard = [SELECT Id, Name, pse__Dated_Resource_Rate_Type__c FROM pse__Rate_Card__c LIMIT 1];

pse.RateCardMatchingService.DatedResourceRateType result = pse.RateCardMatchingService.getDatedResourceRateType(aRateCard.pse__Dated_Resource_Rate_Type__c);

matchRateCards

global static List<pse.RateCardMatcherItem> matchRateCards(List<pse.RateCardMatcherItem> items)

Attempt to match rate cards to the given list of RateCardMatcherItems.

Input Parameters

Name Type Description
items List<pse.RateCardMatcherItem> The RateCardMatcherItems to match rate cards to.

Return Value

Returns the RateCardMatcherItems that rate cards were matched to.

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.

pse__Resource_Request__c resourceRequest = [
                SELECT
                    pse__AccountId__c,
                    pse__Region__c,
                    pse__Region__r.pse__Region_ID_Chain__c,
                    pse__Resource_Role__c,
                    pse__Start_Date__c,
                    pse__Project__r.pse__Rate_Card_Percentage_Discount__c,
                    pse__Project__r.pse__Rate_Card_Discount_Limit__c,
                    pse__CurrencyIsoCode,
                    pse__Practice__c,
                    pse__Practice__r.pse__Practice_ID_Chain__c,
                    pse__Group__c,
                    pse__Group__r.pse__Group_ID_Chain__c,
                    pse__Project__r.pse__Rate_Card_Set__c,
                    pse__Use_Dated_Resource_Bill_Rates__c,
                    pse__Use_Dated_Resource_Cost_Rates__c,
                    pse__Rate_Card__c
                FROM pse__Resource_Request__c
                LIMIT 1
            ];

List<pse.RateCardMatcherItem> rateCardMatcherItems = new List<pse.RateCardMatcherItem>();
pse.RateCardMatcherItem rateCardMatcherItem = new ExampleMatcherItem();

rateCardMatcherItem.setRecord(resourceRequest);
rateCardMatcherItem.setAccountId(resourceRequest.pse__AccountId__c);
rateCardMatcherItem.setRegionId(resourceRequest.pse__Region__c);
rateCardMatcherItem.setRegionIdChain(resourceRequest.pse__Region__r.pse__Region_ID_Chain__c);
rateCardMatcherItem.setRole(resourceRequest.pse__Resource_Role__c);
rateCardMatcherItem.setStartDate(resourceRequest.pse__Start_Date__c);
rateCardMatcherItem.setProjectOpportunityDiscountRate(resourceRequest.pse__Project__r.pse__Rate_Card_Percentage_Discount__c);
rateCardMatcherItem.setProjectOpportunityDiscountLimitAmount(resourceRequest.pse__Project__r.pse__Rate_Card_Discount_Limit__c);
rateCardMatcherItem.setCurrencyIsoCode(resourceRequest.pse__CurrencyIsoCode);
rateCardMatcherItem.setPracticeId(resourceRequest.pse__Practice__c);
rateCardMatcherItem.setPracticeIdChain(resourceRequest.pse__Practice__r.pse__Practice_ID_Chain__c);
rateCardMatcherItem.setGroupId(resourceRequest.pse__Group__c);
rateCardMatcherItem.setGroupIdChain(resourceRequest.pse__Group__r.pse__Group_ID_Chain__c);
rateCardMatcherItem.setRateCardSetId(resourceRequest.pse__Project__r.pse__Rate_Card_Set__c);
rateCardMatcherItem.setUseDatedResourceBillRates(resourceRequest.pse__Use_Dated_Resource_Bill_Rates__c);
rateCardMatcherItem.setUseDatedResourceCostRates(resourceRequest.pse__Use_Dated_Resource_Cost_Rates__c);

rateCardMatcherItems.add(rateCardMatcherItem);

pse.RateCardMatchingService.matchRateCards(rateCardMatcherItems);


///Example implementation of RateCardMatcherItem

private class ExampleMatcherItem extends RateCardMatcherItem {
        private Boolean isDirty = false;

        public override void onMatch(
            Rate_Card__c rateCard,
            RateCardMatchingService.DatedResourceRateType rateCardType
        ) {
            this.isDirty = true;
            pse__Resource_Request__c resourceRequest = (pse__Resource_Request__c) getRecord();
            resourceRequest.pse__Rate_Card__c = rateCard.Id;
        }

        public override void onNoMatch(RateCardMatchingService.DatedResourceRateType rateCardType)
        {
            this.isDirty = true;
            pse__Resource_Request__c resourceRequest = (pse__Resource_Request__c) getRecord();
            resourceRequest.pse__Rate_Card__c = null;
        }

        public override Boolean isDirty()
        {
            return this.isDirty;
        }
    }

matchRateCards

global static List<pse.RateCardMatcherItem> matchRateCards(List<pse.RateCardMatcherItem> items, pse.RateCardMatchingService.MatchingConfiguration configuration)

Attempt to match rate cards to the given list of RateCardMatcherItems.

Input Parameters

Name Type Description
items List<pse.RateCardMatcherItem> The RateCardMatcherItems to match rate cards to.
configuration pse.RateCardMatchingService.MatchingConfiguration A configuration object defining parameters for how this rate card matching process runs.

Return Value

Returns the RateCardMatcherItems that rate cards were matched to.

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.

pse__Resource_Request__c resourceRequest = [
                SELECT
                    pse__AccountId__c,
                    pse__Region__c,
                    pse__Region__r.pse__Region_ID_Chain__c,
                    pse__Resource_Role__c,
                    pse__Start_Date__c,
                    pse__Project__r.pse__Rate_Card_Percentage_Discount__c,
                    pse__Project__r.pse__Rate_Card_Discount_Limit__c,
                    pse__CurrencyIsoCode,
                    pse__Practice__c,
                    pse__Practice__r.pse__Practice_ID_Chain__c,
                    pse__Group__c,
                    pse__Group__r.pse__Group_ID_Chain__c,
                    pse__Project__r.pse__Rate_Card_Set__c,
                    pse__Use_Dated_Resource_Bill_Rates__c,
                    pse__Use_Dated_Resource_Cost_Rates__c,
                    pse__Rate_Card__c
                FROM pse__Resource_Request__c
                LIMIT 1
            ];

List<pse.RateCardMatcherItem> rateCardMatcherItems = new List<pse.RateCardMatcherItem>();
pse.RateCardMatcherItem rateCardMatcherItem = new ExampleMatcherItem();

rateCardMatcherItem.setRecord(resourceRequest);
rateCardMatcherItem.setAccountId(resourceRequest.pse__AccountId__c);
rateCardMatcherItem.setRegionId(resourceRequest.pse__Region__c);
rateCardMatcherItem.setRegionIdChain(resourceRequest.pse__Region__r.pse__Region_ID_Chain__c);
rateCardMatcherItem.setRole(resourceRequest.pse__Resource_Role__c);
rateCardMatcherItem.setStartDate(resourceRequest.pse__Start_Date__c);
rateCardMatcherItem.setProjectOpportunityDiscountRate(resourceRequest.pse__Project__r.pse__Rate_Card_Percentage_Discount__c);
rateCardMatcherItem.setProjectOpportunityDiscountLimitAmount(resourceRequest.pse__Project__r.pse__Rate_Card_Discount_Limit__c);
rateCardMatcherItem.setCurrencyIsoCode(resourceRequest.pse__CurrencyIsoCode);
rateCardMatcherItem.setPracticeId(resourceRequest.pse__Practice__c);
rateCardMatcherItem.setPracticeIdChain(resourceRequest.pse__Practice__r.pse__Practice_ID_Chain__c);
rateCardMatcherItem.setGroupId(resourceRequest.pse__Group__c);
rateCardMatcherItem.setGroupIdChain(resourceRequest.pse__Group__r.pse__Group_ID_Chain__c);
rateCardMatcherItem.setRateCardSetId(resourceRequest.pse__Project__r.pse__Rate_Card_Set__c);
rateCardMatcherItem.setUseDatedResourceBillRates(resourceRequest.pse__Use_Dated_Resource_Bill_Rates__c);
rateCardMatcherItem.setUseDatedResourceCostRates(resourceRequest.pse__Use_Dated_Resource_Cost_Rates__c);

rateCardMatcherItems.add(rateCardMatcherItem);

pse.RateCardMatchingService.MatchingConfiguration matchingConfiguration = new pse.RateCardMatchingService.MatchingConfiguration();
pse.RateCardMatchingService.matchRateCards(rateCardMatcherItems, matchingConfiguration);

///Example implementation of RateCardMatcherItem

private class ExampleMatcherItem extends RateCardMatcherItem {
        private Boolean isDirty = false;

        public override void onMatch(
            Rate_Card__c rateCard,
            RateCardMatchingService.DatedResourceRateType rateCardType
        ) {
            this.isDirty = true;
            pse__Resource_Request__c resourceRequest = (pse__Resource_Request__c) getRecord();
            resourceRequest.pse__Rate_Card__c = rateCard.Id;
        }

        public override void onNoMatch(RateCardMatchingService.DatedResourceRateType rateCardType)
        {
            this.isDirty = true;
            pse__Resource_Request__c resourceRequest = (pse__Resource_Request__c) getRecord();
            resourceRequest.pse__Rate_Card__c = null;
        }

        public override Boolean isDirty()
        {
            return this.isDirty;
        }
    }

pse.RateCardMatchingService.MatchingConfiguration

global virtual with sharing class MatchingConfiguration implements RateCardMatcher.MatcherConfiguration

Matching configuration defining options that the pse.RateCardMatchingService can run with.

Methods

MatchingConfiguration

global MatchingConfiguration()

MatchingConfiguration constructor.

hasPlugin

global Boolean hasPlugin()

Does the Configuration have a plugin.

Return Value

Returns true if the Configuration has a plugin.

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.

pse.RateCardMatchingService.MatchingConfiguration matchingConfiguration = new pse.RateCardMatchingService.MatchingConfiguration();
Boolean result = matchingConfiguration.hasPlugin();

getPlugin

global virtual pse.RateCardMatcherPlugin.IFinalRateCardChoicePlugin getPlugin()

Gets the pse.RateCardMatcherPlugin.IFinalRateCardChoicePlugin plugin for the matcher.
The plugin will be retrieved from the fferpcore__Plugin__mdt record with a fferpcore__ExtensionPoint__c of pse.RateCardMatcherPlugin.IFinalRateCardChoicePlugin, and a fferpcore__ClassName__c that matches an Apex class that implements that interface. See pse.RateCardMatcherPlugin for more information.

Return Value

Returns the plugin related to this matcher configuration.

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.

pse.RateCardMatchingService.MatchingConfiguration matchingConfiguration = new pse.RateCardMatchingService.MatchingConfiguration();
pse.RateCardMatcherPlugin.IFinalRateCardChoicePlugin  result = matchingConfiguration.getPlugin();

isStandardRateCardMatchingDisabled

global virtual Boolean isStandardRateCardMatchingDisabled()

Is rate card matching disabled.

Return Value

Returns true if rate card matching is disabled.

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.

pse.RateCardMatchingService.MatchingConfiguration matchingConfiguration = new pse.RateCardMatchingService.MatchingConfiguration();
Boolean result = matchingConfiguration.isStandardRateCardMatchingDisabled();

chooseRateCardsWithPluginOnly

global virtual Boolean chooseRateCardsWithPluginOnly()

Return Value

Returns true if rate cards should be chosen using the plugin only.

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.

pse.RateCardMatchingService.MatchingConfiguration matchingConfiguration = new pse.RateCardMatchingService.MatchingConfiguration();
Boolean result = matchingConfiguration.chooseRateCardsWithPluginOnly();

unableToMatchRateCards

global Boolean unableToMatchRateCards()

Return Value

Returns true when rate card matching is disabled and no plugin is provided. RateCardMatcher has no strategy to match ratecards.

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.

pse.RateCardMatchingService.MatchingConfiguration matchingConfiguration = new pse.RateCardMatchingService.MatchingConfiguration();
Boolean result = matchingConfiguration.unableToMatchRateCards();
© Copyright 2009–2025 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.