pse.RateCardMatchingServiceglobal with sharing class RateCardMatchingService Service providing methods to match rate cards to RateCardMatcherItems. EnumsDatedResourceRateType
Methods
getDatedResourceRateTypeglobal static pse.RateCardMatchingService.DatedResourceRateType getDatedResourceRateType(String rateTypeAsString) Get the RateCardType for a given string. Null strings are treated as FIXED_RATE RateCardTypes. Input Parameters
Return ValueReturns 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); matchRateCardsglobal static List<pse.RateCardMatcherItem> matchRateCards(List<pse.RateCardMatcherItem> items) Attempt to match rate cards to the given list of RateCardMatcherItems. Input Parameters
Return ValueReturns 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;
}
}
matchRateCardsglobal 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
Return ValueReturns 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.MatchingConfigurationglobal virtual with sharing class MatchingConfiguration implements RateCardMatcher.MatcherConfiguration Matching configuration defining options that the pse.RateCardMatchingService can run with. Methods
hasPluginglobal Boolean hasPlugin() Does the Configuration have a plugin. Return ValueReturns 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(); getPluginglobal virtual pse.RateCardMatcherPlugin.IFinalRateCardChoicePlugin getPlugin() Gets the pse.RateCardMatcherPlugin.IFinalRateCardChoicePlugin plugin for the matcher. Return ValueReturns 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(); isStandardRateCardMatchingDisabledglobal virtual Boolean isStandardRateCardMatchingDisabled() Is rate card matching disabled. Return ValueReturns 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(); chooseRateCardsWithPluginOnlyglobal virtual Boolean chooseRateCardsWithPluginOnly() Return ValueReturns 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(); unableToMatchRateCardsglobal Boolean unableToMatchRateCards() Return ValueReturns 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(); |