I need to improve my code coverage please can any one help me out
Trigger:
trigger Rfleet_UpdateforecastAllCountry on Country_DCVF_Volume__c (after insert,after update,after delete) {
string TempYear;
Integer TempMonth;
Integer FinalVolume=0;
Integer FinalForecast=0;
set<id>Ikamids=new set<id>();
set<id>Accountids=new set<id>();
if(trigger.isinsert||trigger.isupdate ){
for(Country_DCVF_Volume__c Dcvfcount:trigger.new){
if(Dcvfcount.IKAM_Data__c!=null){
Ikamids.add(Dcvfcount.IKAM_Data__c);
Accountids.add(Dcvfcount.Parent_Account__c);
}
}
}
if(trigger.isdelete){
for(Country_DCVF_Volume__c Dcvfcount:trigger.old){
if(Dcvfcount.IKAM_Data__c!=null){
Ikamids.add(Dcvfcount.IKAM_Data__c);
Accountids.add(Dcvfcount.Parent_Account__c);
}
}
}
list<country_dcvf_volume__c>listVol=[select id,insertion_date__c, country__c, Year__c from country_dcvf_volume__c where IKAM_Data__c in:Ikamids and Parent_Account__c in:Accountids ORDER BY insertion_date__c desc limit 1];
for(country_dcvf_volume__c FirstList :listVol){
TempYear=string.Valueof(FirstList.Year__c);
TempMonth=integer.valueof(FirstList.insertion_date__c.month());
}
list<IKAM_Data__c>finalcount=new list<IKAM_Data__c>();
list<country_dcvf_volume__c> SecondSortedList=[select id,Country_forecast__c ,IKAM_Data__c, Delivered_volume__c from country_dcvf_volume__c where IKAM_Data__c in:Ikamids and Parent_Account__c in:Accountids and Year__c =:TempYear and CALENDAR_month(insertion_date__c)=:TempMonth ];
list<IKAM_Data__c>Ikamupdate=[select id,Countries_delivered_volume__c,Countries_forecast__c from IKAM_Data__c where id in:Ikamids ];
for(country_dcvf_volume__c FinalList :SecondSortedList){
for(IKAM_Data__c updateIkam:Ikamupdate){
FinalVolume +=integer.valueof(FinalList.Delivered_volume__c);
FinalForecast +=integer.valueof(FinalList.Country_forecast__c);
updateIkam.Countries_delivered_volume__c=FinalVolume;
updateIkam.Countries_forecast__c=FinalForecast ;
}
}
update Ikamupdate;
}
My test class:
@isTest
private class Rfleet_UpdateforecastAllCountry_Test {
static testmethod void Rfleet_UpdateforecastAllCountry_TestMethod(){
Country_DCVF_Volume__c ContryDCVF = new Country_DCVF_Volume__c(
CurrencyIsoCode='India',
Country__c='Algeria',
Parent_Account__c='001m000000Kg3ys',
Region__c='France',
Insertion_date__c=system.today(),
KAM__c='Ganz Bruno',
Delivered_volume__c=1.5,
IKAM_Data__c='a3em0000000DCsq'
);
insert ContryDCVF;
IKAM_Data__c ikam= new IKAM_Data__c(
Annual_global_deliveries_commitment__c=09.0,
Annual_deliveries_target__c=72,
Account__c='Bosch',
IKAM_Year__c=2015
);
insert ikam;
}
}
Best Answer
CurrencyIsoCode must be a three-letter code that identifies a country's currency, like USD stands for United States Dollars, or JPY for Japanese Yen.
Indian Rupee is INR.