You need to sign in to do that
Don't have an account?
RICARDO PALMA
Test coverage 0% in a Controller Extension
Hi,
I'm having a hard time covering this Controller Extension, any example code?
Thanks!!!
public with sharing class currentbilling {
public final Account acc {get; set;}
public integer countActRec {get; set;}
public Object sumAmount{set;get;}
Set<ID> countr = new Set<ID>();
public currentbilling(ApexPages.StandardController controller) {
this.acc = (Account)controller.getRecord();
}
public List<OpportunityLineItem> oppoproRecords{get;set;}
public void FetchData() {
oppoproRecords = [SELECT Id, Opportunityid, Opportunity.Name , PricebookEntry.Product2.Name , Discounted_Rate__c, Advertiser_Account__c, Opportunity.Contract_End_Date__c FROM OpportunityLineItem Where Advertiser_Account__c = :acc.id and Opportunity.StageName = 'Contract Executed' and (Cancellation_Date__c = null or Cancellation_Date__c > Today) ];
if(oppoproRecords.isEmpty()){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'There is no executed opportunities with actives products for this account.'));
}
for (OpportunityLineItem rec : oppoproRecords) {
countr.add(rec.Opportunityid);
}
countActRec = [SELECT count() From Opportunity Where id in :countr];
AggregateResult[] groupedResults = [SELECT SUM(Discounted_Rate__c)aver FROM OpportunityLineItem Where Advertiser_Account__c = :acc.id and Opportunity.StageName = 'Contract Executed' and (Cancellation_Date__c = null or Cancellation_Date__c > Today)];
sumAmount = groupedResults[0].get('aver');
}
}
------------
I'm having a hard time covering this Controller Extension, any example code?
Thanks!!!
public with sharing class currentbilling {
public final Account acc {get; set;}
public integer countActRec {get; set;}
public Object sumAmount{set;get;}
Set<ID> countr = new Set<ID>();
public currentbilling(ApexPages.StandardController controller) {
this.acc = (Account)controller.getRecord();
}
public List<OpportunityLineItem> oppoproRecords{get;set;}
public void FetchData() {
oppoproRecords = [SELECT Id, Opportunityid, Opportunity.Name , PricebookEntry.Product2.Name , Discounted_Rate__c, Advertiser_Account__c, Opportunity.Contract_End_Date__c FROM OpportunityLineItem Where Advertiser_Account__c = :acc.id and Opportunity.StageName = 'Contract Executed' and (Cancellation_Date__c = null or Cancellation_Date__c > Today) ];
if(oppoproRecords.isEmpty()){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'There is no executed opportunities with actives products for this account.'));
}
for (OpportunityLineItem rec : oppoproRecords) {
countr.add(rec.Opportunityid);
}
countActRec = [SELECT count() From Opportunity Where id in :countr];
AggregateResult[] groupedResults = [SELECT SUM(Discounted_Rate__c)aver FROM OpportunityLineItem Where Advertiser_Account__c = :acc.id and Opportunity.StageName = 'Contract Executed' and (Cancellation_Date__c = null or Cancellation_Date__c > Today)];
sumAmount = groupedResults[0].get('aver');
}
}
------------
Hi Ricardo,
Please try below code. Some fields are missing but this should work.
Thanks,
Manohar
All Answers
Hi Ricardo,
Please try below code. Some fields are missing but this should work.
Thanks,
Manohar