You need to sign in to do that
Don't have an account?
Hughbert Strong
CPQ Quoteline Test Class
All,
I need help writing a test class for this Apex Trigger that fires on the CPQ Quoteline. Can anyone help me out?
Apex Trigger:
trigger QLSummaryRollUps on SBQQ__QuoteLine__c (after insert,after update,after delete) {
list<SBQQ__QuoteLine__c> l;
if(Trigger.isInsert || Trigger.isUpdate)
{
l = Trigger.new;
}
if(Trigger.isDelete)
{
l = Trigger.old;
}
Decimal rec=0.00;
Decimal upf=0.00;
Decimal hware=0.00;
Decimal Nrec=0.00;
Decimal Nupf=0.00;
Decimal Nhware=0.00;
String qid;
for(SBQQ__QuoteLine__c q : l)
{
qid=q.SBQQ__Quote__c;
}
for(SBQQ__QuoteLine__c f : l)
{
if(f.Quote_Line_Grouping__c != null){
if(f.Quote_Line_Grouping__c == 'Recurring Fee')
{
rec+=f.Adjusted_List_Line_Item__c;
Nrec+=f.SBQQ__NetTotal__c;
}
if(f.Quote_Line_Grouping__c == 'Hardware')
{
hware+=f.Adjusted_List_Total__c;
Nhware+=f.SBQQ__NetTotal__c;
}
if(f.Quote_Line_Grouping__c == 'Upfront Fee')
{
upf+=f.Adjusted_List_Total__c;
Nupf+=f.SBQQ__NetTotal__c;
}
}
}
SBQQ__Quote__c q=[SELECT Id, Adjusted_List_Total_Recurring_Fee_2__c, Adjusted_List_Total_Hardware_2__c, Adjusted_List_Total_Upfront_Fee_2__c, Net_Total_Hardware_2__c, Net_Total_Recurring_Fee_2__c, Net_Total_Upfront_Fee_2__c FROM SBQQ__Quote__c WHERE Id =: qid];
q.Adjusted_List_Total_Recurring_Fee_2__c=rec;
q.Adjusted_List_Total_Hardware_2__c=hware;
q.Adjusted_List_Total_Upfront_Fee_2__c=upf;
q.Net_Total_Recurring_Fee_2__c=Nrec;
q.Net_Total_Hardware_2__c=Nhware;
q.Net_Total_Upfront_Fee_2__c=Nupf;
System.debug(rec);
System.debug(hware);
System.debug(upf);
System.debug(Nrec);
System.debug(Nhware);
System.debug(Nupf);
update q;
}
I need help writing a test class for this Apex Trigger that fires on the CPQ Quoteline. Can anyone help me out?
Apex Trigger:
trigger QLSummaryRollUps on SBQQ__QuoteLine__c (after insert,after update,after delete) {
list<SBQQ__QuoteLine__c> l;
if(Trigger.isInsert || Trigger.isUpdate)
{
l = Trigger.new;
}
if(Trigger.isDelete)
{
l = Trigger.old;
}
Decimal rec=0.00;
Decimal upf=0.00;
Decimal hware=0.00;
Decimal Nrec=0.00;
Decimal Nupf=0.00;
Decimal Nhware=0.00;
String qid;
for(SBQQ__QuoteLine__c q : l)
{
qid=q.SBQQ__Quote__c;
}
for(SBQQ__QuoteLine__c f : l)
{
if(f.Quote_Line_Grouping__c != null){
if(f.Quote_Line_Grouping__c == 'Recurring Fee')
{
rec+=f.Adjusted_List_Line_Item__c;
Nrec+=f.SBQQ__NetTotal__c;
}
if(f.Quote_Line_Grouping__c == 'Hardware')
{
hware+=f.Adjusted_List_Total__c;
Nhware+=f.SBQQ__NetTotal__c;
}
if(f.Quote_Line_Grouping__c == 'Upfront Fee')
{
upf+=f.Adjusted_List_Total__c;
Nupf+=f.SBQQ__NetTotal__c;
}
}
}
SBQQ__Quote__c q=[SELECT Id, Adjusted_List_Total_Recurring_Fee_2__c, Adjusted_List_Total_Hardware_2__c, Adjusted_List_Total_Upfront_Fee_2__c, Net_Total_Hardware_2__c, Net_Total_Recurring_Fee_2__c, Net_Total_Upfront_Fee_2__c FROM SBQQ__Quote__c WHERE Id =: qid];
q.Adjusted_List_Total_Recurring_Fee_2__c=rec;
q.Adjusted_List_Total_Hardware_2__c=hware;
q.Adjusted_List_Total_Upfront_Fee_2__c=upf;
q.Net_Total_Recurring_Fee_2__c=Nrec;
q.Net_Total_Hardware_2__c=Nhware;
q.Net_Total_Upfront_Fee_2__c=Nupf;
System.debug(rec);
System.debug(hware);
System.debug(upf);
System.debug(Nrec);
System.debug(Nhware);
System.debug(Nupf);
update q;
}
Please check once below code.
@isTest
public class Overview_QLSummaryRollUps_Test {
private static testMethod void testOverview()
{
SBQQ__Quote__c qut = new SBQQ__Quote__c();
Fill all mandatory fields
//Insert qut
SBQQ__QuoteLine__c sbq = new SBQQ__QuoteLine__c();
Fill all mandatory fields
//Insert sbq
}
}
Thanks
Varaprasad