A new custom callback class is supported to calculate and set the Transaction Price for specified Agreement Line Items.
To add the custom class
Go to Setup > App Setup > Develop > Apex Classes.
Click New.
Enter the sample callback class code.
This is just a sample callback class to calculate Transaction Price. You may change the code as per your requirements.
global interface IRevenueCalculation
{
/**
* Calculate and set the Transaction Price for the specified Agreement Line Items.
* There is no need to call "Upsert" as that will performed by the Revenue
* Configuration/Integration package.
*
* @param agreementLineItms The list of Agreement Line Items to update.
* It is expected the Transaction Price will be set on each Agreement Line
* Item.
* @param agreemnt The corresponding Agreement.
*/
void calculateTransactionPrice(
List<Apttus__AgreementLineItem__c> agreementLineItems,
Apttus__APTS_Agreement__c agreemnt);
}
public with sharing class TestRevenueCalculationCallback
implements CustomClass.IRevenueCalculation {
public void calculateTransactionPrice(List<Apttus__AgreementLineItem__c> agreementLineItems,
Apttus__APTS_Agreement__c agreemnt) {
Decimal totalNetPrice = 0.0;
for(Apttus__AgreementLineItem__c lineItemSO :agreementLineItems) {
totalNetPrice += lineItemSO.Apttus__NetPrice__c;
lineItemSO.TransactionPrice__c = lineItemSO.Apttus__NetPrice__c;
}
if(totalNetPrice > 1000) {
for(Apttus__AgreementLineItem__c lineItemSO :agreementLineItems) {
lineItemSO.TransactionPrice__c = (lineItemSO.Apttus__NetPrice__c - (lineItemSO.Apttus__NetPrice__c / 100)).setScale(RuntimeContext.DEFAULT_SCALE);
}
}
}
}
CODE
4. Click Save.
To register your custom callback class, go to Setup > App Setup > Develop > Custom Settings and click Manage beside Revenue System Properties. Click Edit for System Properties and enter the name of your custom callback class in Revenue Calculation Callback.