Related Pricing Callback allows you to apply custom logic to calculate the related pricing. This callback is invoked while CPQ is calculating related pricing after the main pricing is calculated.

To use the Related Pricing Callback you must create a custom Apex class that implements the Apttus_Config2.CustomClass.IRelatedPricingCallback interface and register the custom apex class with Related Pricing Callback Class. You must write your custom logic in the custom apex class.

The following methods are available in the Apttus_Config2.CustomClass.IRelatedPricingCallback interface:

Method
Signature
Description
computeBasePrice()Apttus_Config2.CustomClass.RelatedPriceResult computeBasePrice(Apttus_Config2.ProductConfiguration, Apttus_Config2.LineItem, List)You can use this method to apply custom logic for related pricing calculation and override the default CPQ related pricing logic. 


If you have defined Pricing Callback class, Related Pricing Callback is always invoked after the Pricing Callback is executed.

Example

In the following sample code, Related Pricing Callback to calculates the price on related line items. 

global with sharing class APTS_RelatedPricingCallBack implements Apttus_Config2.CustomClass.IRelatedPricingCallback {
    /**
        * Callback to compute the related price for the related line item
        * @param cart the cart object associated with the related line item
        * @param relLineItemMO the related line item to compute the base price for
        * @param breakups the list of price breakup sobjects associated with the related line item
        * @return the related price result
    */
    public Apttus_Config2.CustomClass.RelatedPriceResult computeBasePrice(Apttus_Config2.ProductConfiguration cart, Apttus_Config2.LineItem relLineItemMO, List<Apttus_Config2__PriceBreakup__c> breakups)
    {
        Apttus_Config2.CustomClass.RelatedPriceResult relPriceResult = new Apttus_Config2.CustomClass.RelatedPriceResult();
          
        //Apttus_Config2__ProductConfiguration__c cartSO =  cart.getConfigSO();
        Apttus_Config2__LineItem__c liSO = relLineItemMO.getLineItemSO(); 
        system.debug('Net Price-->' + liSO.Apttus_Config2__NetPrice__c + ' ChargeType-->' + liSO.Apttus_Config2__ChargeType__c + ' Base Price-->' + liSO.Apttus_Config2__BasePrice__c);
        system.debug('breakups-->' + breakups);
        
        Decimal softwareFeesNetprice = 0;
        if(breakups != null)
        {
            for(Apttus_Config2__PriceBreakup__c b : breakups)
            {
                if(b.Apttus_Config2__BreakupType__c == 'Total' && liSO.Apttus_Config2__ChargeType__c == 'Maintenance Fee')
                {
                    softwareFeesNetprice  += b.Apttus_Config2__RelatedNetPrice__c;
                }
            }
        }   
        
        system.debug('softwareFeesNetprice : ' +softwareFeesNetprice+ ' liSO.Maintenance_Level_Value__c ' + liSO.Maintenance_Level_Value__c);
        if(liSO.Apttus_Config2__ChargeType__c == 'Maintenance Fee' && liSO.Maintenance_Level_Value__c != null)
        {
            relPriceResult.BasePrice = (softwareFeesNetprice * liSO.Maintenance_Level_Value__c)/100; 
        }
        system.debug('relPriceResult.BasePrice : ' +relPriceResult.BasePrice);
        system.debug('##-- EXIT RELATED PRICING CALLBACK');
        return relPriceResult; 
    }
}
CODE