You need to sign in to do that
Don't have an account?
aress
test class for this soql code
Need TEST CLASS for following
Description: Display sum of all closed Opportunity amount for current year
public class FiscalYear {
public static Map<Integer,Decimal> getSumOfOpportunities() {
Map<Integer,Decimal> opportunityMap = new Map<Integer,Decimal>();
List<AggregateResult> opportunityList = [
SELECT
CALENDAR_YEAR(CloseDate) YEAR,
sum(Amount) SUM
FROM
Opportunity
WHERE
isClosed = true
GROUP BY
CALENDAR_YEAR(CloseDate)
];
for( AggregateResult opportunityRecord : opportunityList ) {
if( opportunityRecord.get('YEAR').equals(System.today().year()) ) {
System.debug('Sum of all closed Opportunity amount for current fiscal year: '
+ opportunityRecord.get('SUM'));
}
opportunityMap.put((Integer)opportunityRecord.get('YEAR'), (Decimal)opportunityRecord.get('SUM'));
}
System.debug(opportunityList);
System.debug(opportunityMap);
return opportunityMap;
}
}
Description: Display sum of all closed Opportunity amount for current year
public class FiscalYear {
public static Map<Integer,Decimal> getSumOfOpportunities() {
Map<Integer,Decimal> opportunityMap = new Map<Integer,Decimal>();
List<AggregateResult> opportunityList = [
SELECT
CALENDAR_YEAR(CloseDate) YEAR,
sum(Amount) SUM
FROM
Opportunity
WHERE
isClosed = true
GROUP BY
CALENDAR_YEAR(CloseDate)
];
for( AggregateResult opportunityRecord : opportunityList ) {
if( opportunityRecord.get('YEAR').equals(System.today().year()) ) {
System.debug('Sum of all closed Opportunity amount for current fiscal year: '
+ opportunityRecord.get('SUM'));
}
opportunityMap.put((Integer)opportunityRecord.get('YEAR'), (Decimal)opportunityRecord.get('SUM'));
}
System.debug(opportunityList);
System.debug(opportunityMap);
return opportunityMap;
}
}
Hope it will help you
Thanks
Akshay