• Umamageshwari Palanisamy
  • NEWBIE
  • 5 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 8
    Questions
  • 6
    Replies
 I have custom object called Opportunity car set object. In the object there are 5 fields. name, brand, model name(lookup to product),version name (lookup to product),price Depending upon the selection of model name and version name the price field should be updated. The model name and version name are sent as parameter to get the price value from web service
 
trigger Rfleet_OpptyUpdateC2GPrice on Opportunity_car_set__c (before insert,before update) {

Public String modelOppValue;
Public String versionOppValue;


  for(Opportunity_car_set__c oppcarset:[select id,Price_HT__c,Model__r.Name,Version__r.Name from Opportunity_car_set__c  where id in:trigger.new]){
   system.debug('oppcarset.id----------------->'+oppcarset.id);
   system.debug('oppcarset.Model__r.Name----------------->'+oppcarset.Model__r.Name);
   system.debug('oppcarset.Version__r.Name----------------->'+oppcarset.Version__r.Name);
   modelOppValue = oppcarset.Model__r.Name;
   versionOppValue = oppcarset.Version__r.Name; 
   //Rfleet_DZVersionPrice_CLS.doCallout(modelOppValue,versionOppValue);
   Rfleet_DZVersionPrice_CLS.chkVersionCallOut(modelOppValue,versionOppValue);

      system.debug('modelOppValue--------------------->'+ modelOppValue);
      system.debug('versionOppValue --------------------->'+ versionOppValue);
        }

}
My  apex class:
global class Rfleet_DZVersionPrice_CLS {
static String strModelName;
static String strVersionName;
static String strOppid;
@future(callout=true)
public static void chkVersionCallOut(string id,string modelName,string versionName) {
    strOppid =id;
    strModelName = modelName;
    strVersionName = versionName;
    System.debug('strModelName -------------------------------->'+strModelName);
    System.debug('strVersionName -------------------------------->'+strVersionName);
    Rfleet_DZC2GVersionPriceDetails_CLS dzVersionPrize = new Rfleet_DZC2GVersionPriceDetails_CLS(strOppid,strModelName,strVersionName);
    ProcessorControl.inFutureContext = true;
    Double VerPrice=dzVersionPrize.getVersionPrice();
    Opportunity_car_set__c opp=[SELECT Price_HT__c FROM Opportunity_car_set__c where id=:strOppid ];
    system.debug('opp>>'+ opp);
    opp.Price_HT__c=decimal.Valueof(VerPrice);
    system.debug('opp next>>'+ opp);
    Update opp;
}

}

Webservice class:
public class Rfleet_DZC2GVersionPriceDetails_CLS {
public String strJSON {get;set;}
public String strGeturl {get;set;}
public String strGetcountrycode {get;set;}
public String strGetCurrency {get;set;}
public String strModelCode {get;set;}
public String strVersionCode {get;set;}
public String strVersionDocUrl {get;set;}
public String strPriceListURL {get;set;}
public String strOppid {get;set;}
public double strversionPrice{get;set;}
public List<String> lstModelcalOut = new List<String>(); //to get list of model code
public List<String> lstDoCcalOut = new List<String>(); //to get list of docurls
public Map<String,String> mVersion     = new map<String,String>();  //Contains model code+doc url
Rfleet_JSON2ApexC2G_CLS obj = null;
public string strModel{get;set;}
public string strVersion{get;set;} 
public string strid{get;set;} 
public Rfleet_DZC2GVersionPriceDetails_CLS(string strOppid,String strModelName, String strVersionName) {

    Rfleet_CountryInfo__c cs = Rfleet_CountryInfo__c.getInstance('Algeria');
    strGeturl         =    cs.Rfleet_C2GURL__c;
    strGetcountrycode =    cs.Rfleet_CountryCode__c;
    strGetCurrency    =    cs.Rfleet_Currency__c;
    strModel=strModelName;
    strVersion=strVersionName;
    strid=strOppid;
    Opportunity_car_set__c opp=[SELECT Model__r.ProductCode,Version__r.Rfleet_C2G_version_code__c FROM Opportunity_car_set__c where Model__r.name =: strModel and Version__r.name =: strVersion and id=:strid];    
    strModelCode    = opp.Model__r.ProductCode;
    strVersionCode  = opp.Version__r.Rfleet_C2G_version_code__c;
    strOppid        = opp.id;
    system.debug('<<strOppid'+ strOppid);

}

//Common method to Parse the JSON
public String init(String strVersionURL) {
    try {
        Http http = new Http();
        HttpRequest httpReq = new HttpRequest();
        httpReq.setEndpoint(strVersionURL);
        httpReq.setHeader('Accept','application/JSON');
        httpReq.setMethod('GET');
        HttpResponse response = http.send(httpReq);
        strJSON= response.getBody();

    } catch (Exception ex) {
        system.debug('<<Method: init Exception ::'+ ex);
    } 
    return  strJSON;     
}

//Used for Getting ModelCode and Doc URL in Map
public Map<String, String> getJSONFromREST() {
    strJSON = init(strGeturl); 
    JSONParser parser = JSON.createParser(strJSON);
    while(parser.nextToken() !=null) {
        if (parser.getCurrentToken() == JSONToken.FIELD_NAME) {
            String fieldName = parser.getText();
            if(fieldName == 'modelSpecCode') { 
                parser.nextToken();
                lstModelcalOut.add(parser.getText());
            } 
            if(fieldName == 'doc') {
                parser.nextToken();
                lstDoCcalOut.add(parser.getText());
            } 
        }
    }
    for(integer i=0;i<lstModelcalOut.size();i++) {
        mVersion.put(lstModelcalOut.get(i),lstDoCcalOut.get(i));
    }
    system.debug('mVersion===>'+mVersion);
    return mVersion;       
}

//Used to get Version Price URL
public String getVersionPriceURL() {
     Map<string,String> mVersionVal=getJSONFromREST();
    if(mVersionVal.containsKey(strModelCode)) {
        strVersionDocUrl= mVersionVal.get(strModelCode);
    }
    strJSON = init(strVersionDocUrl); 
    JSONParser parser = JSON.createParser(strJSON);
    while (parser.nextToken() != null) {
            if (parser.getCurrentToken() == JSONToken.FIELD_NAME) {
                String fieldName = parser.getText();
                if(fieldName == 'pricesList') {
                    parser.nextToken();
                    strPriceListURL=parser.getText();
                    system.debug('strPriceListURL>>>>'+strPriceListURL);
                }
            }    
    }
    return strPriceListURL;         
}
public double getVersionPrice() {
       String strVersionPriceURL=getVersionPriceURL();
       String strJSON = init(strVersionPriceURL);
       obj = Rfleet_JSON2ApexC2G_CLS.parse(strJSON);
       List<Rfleet_JSON2ApexC2G_CLS.PriceList> listPriceList  = obj.PriceList;  
       for(Rfleet_JSON2ApexC2G_CLS.PriceList priceList : listPriceList) {
            String strPriceTypeReference = (String)priceList.priceType.reference;
            List<Rfleet_JSON2ApexC2G_CLS.VersionPriceList>  listVersionPriceList;
            if(strPriceTypeReference =='PVCHT') {
                listVersionPriceList = new List<Rfleet_JSON2ApexC2G_CLS.VersionPriceList>();
                listVersionPriceList = priceList.versionPriceList;
                for(integer i=0; i< listVersionPriceList.size(); i++) {
                    String strversionIdSpecCode = listVersionPriceList.get(i).versionIdSpecCode;
                    if(strversionIdSpecCode==strVersionCode) {
                      strversionPrice = listVersionPriceList.get(i).price;
                      system.debug('<<<<<<<<<VersionId and Price'+ strversionPrice);  
                    }
                    
                }
            } 
        }  
        system.debug('<<<<<<<<<VersionId outside Price'+ strversionPrice);
        return strversionPrice;
  
} 

}

apex - How to update a custom field while inserting and updating the record using trigger? - Salesforce Stack Exchangeapex class to prevent recursive run:**
public class ProcessorControl {  
     public static boolean inFutureContext = false;
}
My problem is:

While inserting  and modifying the record, price value is not updated.While modifying the record the value is updated after refreshing the page.please help me out!!!thanks in advance !!!



.
I have written apex class.Tge batch class is success but in the debug log there is no result.It shows 

"
03:50:14.4 (2862599069)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:44 03:50:14.4 (2862607983)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 03:50:14.4 (2862635997)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:64 03:50:14.4 (2862640267)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:44 03:50:14.4 (2862649133)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 03:50:14.4 (2862677248)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:68 03:50:14.4 (2862681548)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:44 03:50:14.4 (2862690612)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 03:50:14.4 (2862719222)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:72 03:50:14.4 (2862727335)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:44 03:50:14.4 (2862736722)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 03:50:14.4 (2862766378)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:76 03:50:14.4 (2862770764)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:44 03:50:14.4 (2862779853)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 03:50:14.4 (2862808777)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:80 03:50:14.4 (2862813192)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:44 03:50:14.4 (2862822196)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 03:50:14.882 (2882961812)|CUMULATIVE_LIMIT_USAGE 03:50:14.882 (2882961812)|LIMIT_USAGE_FOR_NS|(default)| Number of SOQL queries: 0 out of 200
"  like this.
How to overcome this issue.
public virtual class Rfleet_DZCallc2gMainProduct implements Database.Batchable<List<String>>, Database.AllowsCallouts { 

public string jsonStr {get;set;}
public string geturl;
public string getcountrycode;
public string getCurrency;
public string brand;
list<string> calOut=new list<string>();
Set<String> newPhase= new Set<String>(); // for adding all new phase strings
List<String> lsNewurl = new List<String>();
set<String> updatePhase= new set<String>(); // for update entries
List<product2> listProd = new List<product2>();
 
public Rfleet_DZCallc2gMainProduct(){

    Rfleet_CountryInfo__c cs = Rfleet_CountryInfo__c.getInstance('Algeria');
    geturl= cs.Rfleet_C2GURL__c;
    system.debug('c2gURL'+geturl);
    getcountrycode=cs.Rfleet_CountryCode__c;
    getCurrency=cs.Rfleet_Currency__c;
    system.debug('getCurrency<<<<<<<<<<<<'+getCurrency);
    }
private virtual List<String> getJSONFromREST() {

    system.debug('getcountrycode'+getcountrycode);
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint(geturl);
    req.setHeader('Accept','application/JSON');
    req.setMethod('GET');
    HttpResponse res = h.send(req);
    jsonStr= res.getBody();

    JSONParser parser = JSON.createParser(jsonStr);
    while (parser.nextToken() != null) {
    if (parser.getCurrentToken() == JSONToken.FIELD_NAME){
    String fieldName = parser.getText();
    if(fieldName == 'doc'){
    parser.nextToken();
    calOut.add(parser.getText());
    system.debug('calOut===>'+calOut); 
    }   
    }    
    }
    return calOut;
}
public Iterable<List<String>> start(Database.BatchableContext BC) {
    list<string>callc2gurl=getJSONFromREST();
    system.debug('callc2gurl'+callc2gurl);
    Rfleet_GetValues_DzC2G prodData = new Rfleet_GetValues_DzC2G(); 
    List<List<String>> urlData = new List<List<String>>();
        for(String dataUrl:callc2gurl){
            List<String> data = prodData.getData(dataUrl);
            data.add(dataUrl);
            System.debug('Add all url data======>'+data);
            urlData.add(data );
        } 
    System.debug('ALL Prod data======>'+urlData );  
    return urlData;
}
public void execute(Database.BatchableContext BC, List<List<String>> records) {
    Rfleet_GetValues_DzC2G prodData = new Rfleet_GetValues_DzC2G();
    System.debug('ALL Prorecords======>'+records);  
     List<product2> lsVersionProd = new List<product2>();
     List<product2> lsModelProd = new List<product2>();
        for(List<String> d:records){ 
            System.debug('ALL Prorecords======>'+d); 
            Map<string,String> VersionIdScrCode=prodData.getVersionIdScrCode(d[9]);  
            System.debug('VersionIdScrCode======>'+VersionIdScrCode);  
            Map<string,String> versionlabel=prodData.getVersionLabel(d[8]); 
            System.debug('ALL versionlabel======>'+versionlabel);
            List<List<String>> versionlabelIdScrcode=prodData.getversionlabelIdScrcode(versionlabel,VersionIdScrCode);   
            System.debug('ALL versionlabelIdScrcode======>'+versionlabelIdScrcode);  
            System.debug('versionlabelIdScrcodesize======>'+versionlabelIdScrcode.size());
          List<String> lsScpmodel= prodData.getModelScpLabel(d[8]); 
      
              for(List<string> p:versionlabelIdScrcode){            
                    Product2 newProd=new product2(); 
                    brand=d[4];  
                    newProd.ProductCode=p[2];
                    newProd.name=getcountrycode+'-'+p[1]+'-'+'strmodel';
                    newProd.CurrencyIsoCode=getCurrency;
                    newProd.SCP_code__c=p[2];
                    newProd.SCP_Label__c=p[1]; 
                    newProd.Country_code__c=getcountrycode;
                    
                    if(brand=='APL03'){brand='Reanult';}
                    if(brand=='APL05'){System.debug('brand<<<<<<<<<<'+brand);brand='Dacia';}
                    newProd.Brand__c=brand;
                    newProd.Rfleet_VersionCombination__c=getcountrycode+brand+p[2];
                     newProd.Rfleet_C2G_version_code__c=p[0];
                    newProd.Market__c='None';
                    newProd.Description=getcountrycode+'-'+brand+'-'+p[2];  
                    newProd.IsActive=true;
                    lsVersionProd .add(newProd);  
                    
                    System.debug('lsVersionProd inside<<<<<<<<<<'+lsVersionProd);   
                }
           
        } 
System.debug('lsVersionProd<<<<<<<<<<'+lsVersionProd); 
System.debug('lsVersionProdsizeee<<<<<<<<<<'+lsVersionProd.size()); 

try {

 upsert  lsModelProd Rfleet_ModelCombination__c; }    //Rfleet_VersionCombination__c;
catch (DMLException e){
  System.debug('retry!'); 
 }



}

}

the above is my code.Please help me out
The JSON structure I am using is as follows :

User-added image




I am trying to get the 'fr' inside the 'label' which is inside the 'version presentation'. I have tried so many times and here is my coding :

    public class GetRestfulExampleSucces {

public string jsonStr {get;set;}
public Pagereference getJSONFromREST() {
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('http://dz.co.rplug.renault.com/pres/BAWg');
        req.setHeader('Accept','application/JSON');
        req.setMethod('GET');
        HttpResponse res = h.send(req);
        jsonStr= res.getBody();
        List<String> calOut = new List<String>();
        system.debug('jsonStr>>>>>>>>>>>>'+jsonStr);
        JSONParser parser = JSON.createParser(jsonStr);
        while (parser.nextToken() != null) {
            if (parser.getCurrentToken() == JSONToken.FIELD_NAME){
                String fieldName = parser.getText();
                system.debug('fieldName >>>>>>>>>>>>'+fieldName );
                if(fieldName == 'versionsPresentation'){
                    while(parser.nextToken() != null){                   
                        if(parser.getCurrentToken() == JSONToken.FIELD_NAME){
                            String Mname = parser.getText();
                            system.debug('Mname >>>>>>>'+Mname );
                                if(Mname == 'fr'){
                                parser.nextToken();
                                 string version=parser.getText();
                                system.debug('version>>>>>>>'+version);
                                }
                        }
                    }
                }
            }
        }
    return null;
        }

}

 By using the above coding , I am getting again all the field values . Please provide me a solution for my query.

Thanks in advance !!!


 
I have wriiten a test class for an apex class which have a wrapper class.In the test class the wrapper class lines are not covered.Please help me out!
My apex class:
public with sharing class Rfleet_Dashboard_DeliveriesYear {

public Rfleet_Dashboard_DeliveriesYear(ApexPages.StandardController controller) {

  
   
System.Debug('>>>>>>>>>>>>>a value --> ' +selcoun);

recentdate=[SELECT Current_month__c FROM IKAM_Data__c where Current_month__c != null order by  Current_month__c Desc limit 1].Current_month__c ;
system.debug('date<<<<<<<<<'+recentdate.day());
recentyear=recentdate.year();
recentmonth=recentdate.month();


If(recentmonth==1){mOnthName='January';}
 else if(recentmonth==2){mOnthName='February';}
  else if(recentmonth==3){mOnthName='March';}
   else if(recentmonth==4){mOnthName='April';}
    else if(recentmonth==5){mOnthName='May';}
     else if(recentmonth==6){mOnthName='June';}
      else if(recentmonth==7){mOnthName='July';}
       else if(recentmonth==8){mOnthName='August';}
        else if(recentmonth==9){mOnthName='Sepetember';}
         else if(recentmonth==10){mOnthName='October';}
          else if(recentmonth==11){mOnthName='November';}
           else if(recentmonth==12){mOnthName='December';}
            else{}

france=false;
    europe=false;
    eurasia=false;
    asia=false;
    AMI=false;
    america=false;

    allcountry=true;
    }
 public String mOnthName{get;set;}
public Integer recentyear{get;set;}
public Integer recentmonth{get;set;}  
public boolean america{get;set;}
public boolean allcountry {get;set;}
public boolean AMI{get;set;}
public boolean asia{get;set;}
public boolean eurasia{get;set;}
public boolean europe{get;set;}
public boolean france{get;set;}
public string selcoun{get;set;} 
public Date recentdate{get;set;} 


public String getcont() {return selcoun;}

 
public class Month {
    public Decimal year {get; set;}
    public Decimal volume{get; set;}
    Month(Decimal year,Decimal volume) {this.year = year;this.volume= volume;}
}

public Month[] getMonths() {
    Month[] months = new Month[] {};
    System.Debug('>>>>>>>>>>>>>insid getmonths--> ' +selcoun);
    for (AggregateResult ar : [

SELECT sum( IKAM_Data__r.Countries_delivered_volume__c)Dvol,CALENDAR_YEAR(IKAM_Data__r.Current_month__c)Year FROM Country_DCVF_Volume__c  group by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) order by CALENDAR_YEAR(IKAM_Data__r.Current_month__c)]) {
    months.add(new Month((Decimal )ar.get('Year'),(Decimal)ar.get('Dvol')));
    }
    system.debug('------->'+months);
    return months;
}  

      
      
    public class Month1 {
    public Decimal year {get; set;}
    public Decimal volume{get; set;}
    Month1(Decimal year,Decimal volume) {this.year = year;this.volume= volume;}
}

public Month[] getMonths1() {
    Month[] months1 = new Month[] {};
      System.Debug('>>>>>>>>>>>>>insid getmonths1--> ' +selcoun);
    for (AggregateResult ar : [SELECT sum( IKAM_Data__r.Countries_delivered_volume__c)Dvol,CALENDAR_YEAR(IKAM_Data__r.Current_month__c)Year FROM Country_DCVF_Volume__c where region__c='americas' group by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) order by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) ]) {                                        
    months1.add(new Month((Decimal )ar.get('Year'),(Decimal)ar.get('Dvol')));
    }
    system.debug('------->'+months1);
    return months1;
} 

 public class Month2{
    public Decimal year {get; set;}
    public Decimal volume{get; set;}
    Month2(Decimal year,Decimal volume) {this.year = year;this.volume= volume;}
}

public Month[] getMonths2() {
    Month[] months2 = new Month[] {};
      System.Debug('>>>>>>>>>>>>>insid getmonths1--> ' +selcoun);
    for (AggregateResult ar : [SELECT sum( IKAM_Data__r.Countries_delivered_volume__c)Dvol,CALENDAR_YEAR(IKAM_Data__r.Current_month__c)Year FROM Country_DCVF_Volume__c where region__c='AMI' group by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) order by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) ]) {                                        
    months2.add(new Month((Decimal )ar.get('Year'),(Decimal)ar.get('Dvol')));
    }
    system.debug('------->'+months2);
    return months2;
} 
  public class Month3 {
    public Decimal year{get; set;}
    public Decimal volume{get; set;}
    Month3(Decimal year,Decimal volume) {this.year = year;this.volume= volume;}
}

public Month[] getMonths3() {
    Month[] months3 = new Month[] {};
      System.Debug('>>>>>>>>>>>>>insid getmonths1--> ' +selcoun);
    for (AggregateResult ar : [SELECT sum( IKAM_Data__r.Countries_delivered_volume__c)Dvol,CALENDAR_YEAR(IKAM_Data__r.Current_month__c)Year FROM Country_DCVF_Volume__c where region__c='Asia-Pacific' group by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) order by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) ]) {                                        
    months3.add(new Month((Decimal )ar.get('Year'),(Decimal)ar.get('Dvol')));
    }
    system.debug('------->'+months3);
    return months3;
}  

 public class Month4 {
    public Decimal year {get; set;}
    public Decimal volume{get; set;}
    Month4(Decimal year,Decimal volume) {this.year = year;this.volume= volume;}
}

public Month[] getMonths4() {
    Month[] months4 = new Month[] {};
      System.Debug('>>>>>>>>>>>>>insid getmonths1--> ' +selcoun);
    for (AggregateResult ar : [SELECT sum( IKAM_Data__r.Countries_delivered_volume__c)Dvol,CALENDAR_YEAR(IKAM_Data__r.Current_month__c)Year FROM Country_DCVF_Volume__c where region__c='Eurasia' group by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) order by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) ]) {                                        
    months4.add(new Month((Decimal )ar.get('Year'),(Decimal)ar.get('Dvol')));
    }
    system.debug('------->'+months4);
    return months4;
} 

 public class Month5 {
    public Decimal year {get; set;}
    public Decimal volume{get; set;}
    Month5(Decimal year,Decimal volume) {this.year = year;this.volume= volume;}
}

public Month[] getMonths5() {
    Month[] months5 = new Month[] {};
      System.Debug('>>>>>>>>>>>>>insid getmonths1--> ' +selcoun);
    for (AggregateResult ar : [SELECT sum( IKAM_Data__r.Countries_delivered_volume__c)Dvol,CALENDAR_YEAR(IKAM_Data__r.Current_month__c)Year FROM Country_DCVF_Volume__c where region__c='Europe G9' group by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) order by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) ]) {                                        
    months5.add(new Month((Decimal )ar.get('Year'),(Decimal)ar.get('Dvol')));
    }
    system.debug('------->'+months5);
    return months5;
} 

 public class Month6 {
    public Decimal year {get; set;}
    public Decimal volume{get; set;}
    Month6(Decimal year,Decimal volume) {this.year = year;this.volume= volume;}
}

public Month[] getMonths6() {
    Month[] months6 = new Month[] {};
      System.Debug('>>>>>>>>>>>>>insid getmonths1--> ' +selcoun);
    for (AggregateResult ar : [SELECT sum( IKAM_Data__r.Countries_delivered_volume__c)Dvol,CALENDAR_YEAR(IKAM_Data__r.Current_month__c)Year FROM Country_DCVF_Volume__c where region__c='France' group by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) order by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) ]) {                                        
    months6.add(new Month((Decimal )ar.get('Year'),(Decimal)ar.get('Dvol')));
    }
    system.debug('------->'+months6);
    return months6;
}
public List<SelectOption> getRegion() {
    List<SelectOption> options = new List<SelectOption>();
    
    options .add(new SelectOption('All countries','All countries'));
    Schema.DescribeFieldResult fieldResult = Country_DCVF_Volume__c.Region__c .getDescribe();
    List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
    for( Schema.PicklistEntry f : ple)
    {
    options.add(new SelectOption(f.getLabel(), f.getValue()));
    }
    return options;
}

      
public PageReference selectedcountry() {
    System.Debug('>>>>>>>>>>>>>insid pageref--> ' +selcoun);
     france=false;
    europe=false;
    eurasia=false;
    asia=false;
    AMI=false;
    america=false;
    allcountry=true;
    getMonths();
    return null;
}

public PageReference selectedcountry1() {

 allcountry=false;
   
    america=true;
   
    getMonths1();
    return null;
}

public PageReference selectedcountry2() {
      france=false;
    europe=false;
    eurasia=false;
    asia=false;
    AMI=true;
    america=false;
    allcountry=false;
    getMonths2();
    return null;
}

public PageReference selectedcountry3() {
    france=false;
    europe=false;
    eurasia=false;
    asia=true;
    AMI=false;
    america=false;
    allcountry=false;
    getMonths3();
    return null;
}
   public PageReference selectedcountry4() {
    france=false;
    europe=false;
    eurasia=true;
    asia=false;
    AMI=false;
    america=false;
    allcountry=false;
    getMonths4();
    return null;
}
  
  public PageReference selectedcountry5() {
   france=false;
    europe=true;
    eurasia=false;
    asia=false;
    AMI=false;
    america=false;
    allcountry=false;
    getMonths5();
    return null;
}
  
  public PageReference selectedcountry6() {
    france=true;
    europe=false;
    eurasia=false;
    asia=false;
    AMI=false;
    america=false;
    allcountry=false;
    getMonths6();
    return null;
}
  

 
 }

My test class:
@isTest
public class Rfleet_Dashboard_DeliveriesYear_Test {
    public static testMethod void deliverytest(){
         Id rType =[Select id from RecordType where sObjectType = 'Account' and name='RFLEET-ACC-DCVF-RT'].id;    
        account acc = new account(name='gfgf',montant__c=0.3,recordtypeid=rType);
        insert acc;
        acc.Name='hghg';
        update acc;
        
        
        IKAM_Data__c ikam = new IKAM_Data__c();
        ikam.Annual_deliveries_target__c=85;
        ikam.Annual_global_deliveries_commitment__c=90;
        ikam.Account__c=acc.id; // insert some account and use that id here 001m000000NPFrU
        ikam.IKAM_Year__c=2015;
        test.startTest();
        insert ikam;
         
       
      country_dcvf_volume__c con = new country_dcvf_volume__c();
        con.Country__c='Algeria';
        con.Region__c='France';
        con.Insertion_date__c=system.Today();
        con.KAM__c='Prabu';
        con.Country_forecast__c=3;
        con.Delivered_volume__c=1;
        con.Parent_Account__c=acc.id;  // insert some account and use that id here  001m000000NFrdp
        con.IKAM_Data__c=ikam.id;
        insert con;
         
        
        
        pagereference vfpage = page.Rfleet_Dashboard_DeliveriesYear_Vf;
        test.setCurrentPageReference(vfpage);
        apexpages.StandardController bre = new apexpages.StandardController(con);
       // Rfleet_Dashboard_DeliveriesYear.Month1 = new Rfleet_Dashboard_DeliveriesYear.Month1();
        Rfleet_Dashboard_DeliveriesYear controller = new Rfleet_Dashboard_DeliveriesYear(bre);
        
        
        controller.getcont();
        controller.getMonths();
        controller.getMonths1();
        controller.getMonths2();
        controller.getMonths3();
        controller.getMonths4();
        controller.getMonths5();
        controller.getMonths6();
        controller.getRegion();
        controller.selectedcountry();
        controller.selectedcountry1();
        controller.selectedcountry2();
        controller.selectedcountry3();
        controller.selectedcountry4();
        controller.selectedcountry5();
        controller.selectedcountry6();
        
       
      }
  
}

The wraper class lines are not covered in test class.The uncovered lines in test class are:
User-added image
I have written the test class for my apex class. The test class is not covered inside the aggregate functions. Please help me out !

My apex class:
public with sharing class Rfleet_DashboardcurrentYear{
public decimal Dvol{get;set;}
public decimal dElTarSum{get;set;}
public decimal tArRatioSum{get;set;}
public decimal dElComSum{get;set;}
public decimal cOmRatioSum{get;set;}
public decimal iKamForcastSum{get;set;}
public String mOnthName{get;set;}
public decimal cUrntMonth{get;set;}
public decimal cOunForcastSum{get;set;}
public decimal cOunForCastRatio{get;set;} 
public decimal cUrntYear{get;set;}
public String str{get;set;}
public String s{get;set;}
public String selectedval{get;set;}
public decimal iKamForcastRatio{get;set;} 
public decimal iKamForcastRatioIn;
public decimal cOunForCastRatioIn;
public decimal maxvalue{get;set;} 
public Rfleet_DashboardcurrentYear(ApexPages.StandardController controller) {
//Global deliveries Realized
    List<AggregateResult> tAr=[select SUM(Countries_delivered_volume__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    for (AggregateResult ar : tAr)  {
    Dvol=(decimal)ar.get('expr0');
     }
// Annual global deliveries target   
    AggregateResult[] tArRatio=[select SUM(Target_ratio__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    for (AggregateResult ar : tArRatio)  {
    Decimal tArRatioSumIn=(decimal) ar.get('expr0');
    tArRatioSum=tArRatioSumIn.setScale(0,System.Roundingmode.HALF_UP); 
    }

    AggregateResult[] dElTar=[select SUM(Annual_deliveries_target__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    for (AggregateResult ar : dElTar)  {
    dElTarSum=(decimal) ar.get('expr0');
    //system.debug('<<<<<<<a value'+dElTarSum);
    }
//Annual global deliveries Commitment
    AggregateResult[] cOmRatio=[select SUM(Commitment_Ratio__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    for (AggregateResult ar : cOmRatio)  {
    Decimal cOmRatioSumIn=(decimal) ar.get('expr0');
    //system.debug('<<<<<<<a value'+cOmRatioSumIn);
    if(cOmRatioSumIn!=null)
    cOmRatioSum=cOmRatioSumIn.setScale(0,System.Roundingmode.HALF_UP); 
    }


    AggregateResult[] dElCom=[select SUM(Annual_global_deliveries_commitment__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    for (AggregateResult ar : dElCom)  {
    dElComSum=(decimal) ar.get('expr0');
    //system.debug('<<<<<<<a value'+dElComSum);
    }
//Country Forecast

    AggregateResult[] cOunForcast=[select SUM(Countries_forecast__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    if(cOunForcast.size()>0)
    {
    for (AggregateResult ar : cOunForcast)  {
    cOunForcastSum=(decimal) ar.get('expr0');
    //system.debug('<<<<<<<a value'+cOunForcastSum);
    }
    }

    if(cOunForcastSum!=null)
    {
    cOunForCastRatioIn=(Dvol/cOunForcastSum)*100;
    cOunForCastRatio=cOunForCastRatioIn.setScale(0,System.Roundingmode.HALF_UP); 
    }

//Current year

    AggregateResult[] cUrntYr=[select CALENDAR_YEAR(Current_month__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    for (AggregateResult ar : cUrntYr)  {
    cUrntYear=(Integer) ar.get('expr0');
    //system.debug('<<<<<<<a value'+cUrntYear);
    }
    str=String.valueof(cUrntYear);

//Current month
    AggregateResult[] cUrntMon=[select CALENDAR_MONTH(Current_month__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_MONTH(Current_month__c) order by CALENDAR_MONTH(Current_month__c) desc limit 1];
    for (AggregateResult ar : cUrntMon)  {
    cUrntMonth=(Integer) ar.get('expr0');
    //system.debug('<<<<<<<a value'+cUrntMonth);
    }

If(cUrntMonth==1){mOnthName='January';}
else if(cUrntMonth==2){mOnthName='February';}
else if(cUrntMonth==3){mOnthName='March';}
else if(cUrntMonth==4){mOnthName='April';}
else if(cUrntMonth==5){mOnthName='May';}
else if(cUrntMonth==6){mOnthName='June';}
else if(cUrntMonth==7){mOnthName='July';}
else if(cUrntMonth==8){mOnthName='August';}
else if(cUrntMonth==9){mOnthName='September';}
else if(cUrntMonth==10){mOnthName='October';}
else if(cUrntMonth==11){mOnthName='November';}
else if(cUrntMonth==12){mOnthName='December';}
else{}

    AggregateResult[] iKamForcast=[select SUM(IKAM_forecast__c) from Account where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    if(iKamForcast.size()>0)
    {
    for (AggregateResult ar : iKamForcast)  {
    iKamForcastSum=(decimal) ar.get('expr0');
   // system.debug('<<<<<<<a value'+iKamForcastSum);
    }
    }
    

    if(iKamForcastSum!=null)
    {
    iKamForcastRatioIn=(Dvol/iKamForcastSum)*100;
    iKamForcastRatio=iKamForcastRatioIn.setScale(0,System.Roundingmode.HALF_UP); 
    }
    
      maxvalue= (dElTarSum>dElComSum&& dElTarSum>cOunForcastSum&& dElTarSum>iKamForcastSum) ? dElTarSum: ((dElComSum>cOunForcastSum && dElComSum>iKamForcastSum) ? dElComSum: ((cOunForcastSum>iKamForcastSum)?cOunForcastSum: iKamForcastSum)) ;  
    }  

 
}

My test class :
@isTest
public class Rfleet_DashboardcurrentYear_Test {    
static testMethod void DashboardcurrentYear(){
test.startTest();
        Id rType =[Select id from RecordType where sObjectType = 'Account' and name='RFLEET-ACC-DCVF-RT'].id;    
        Account acc = new Account(Name='Prabu',Montant__c=5,recordtypeid=rType);
        insert acc;
        system.debug('-------->acc value is ' + acc);
        IKAM_Data__c ikam=new IKAM_Data__c(Annual_deliveries_target__c=45,Annual_global_deliveries_commitment__c=98,IKAM_Year__c=2015,CurrencyIsoCode='INR',Account__c=acc.id);
        insert ikam;
        
        ApexPages.StandardController sc = new ApexPages.standardController(ikam);  
        Rfleet_DashboardcurrentYear accPageCtrl = new Rfleet_DashboardcurrentYear (new ApexPages.StandardController(ikam));     
             
      
        accPageCtrl.Dvol=6.8;   
        accPageCtrl.cOmRatioSum=34.5;
        accPageCtrl.cOunForCastRatio=23.3;
        accPageCtrl.cOunForcastSum=67.8;
        accPageCtrl.cUrntMonth=9.0;
        accPageCtrl.cUrntYear=2015.0;
        accPageCtrl.dElComSum=56.8;
        accPageCtrl.dElTarSum=89;     
        accPageCtrl.iKamForcastRatio=8.7;
        accPageCtrl.iKamForcastSum=56.7;
        accPageCtrl.mOnthName='january';
        accPageCtrl.iKamForcastRatioIn=9.8;
        accPageCtrl.cOunForCastRatioIn=6.7;
        accPageCtrl.tArRatioSum=5.6;
        accPageCtrl.selectedval='hjk';
        accPageCtrl.str='gjg';
        accPageCtrl.s='jh';
        test.stopTest();
}
}

 I have added the screenshot for uncovered lines in my apex class 
User-added image
I need to display the percentage in the gauge dashboard in visualforce page as mentioned below. User-added image

Is this possible ? If yes , provide me a good way to accomplish this
How to overcome the colour over-ridden issue in bar chart?

  User-added image

 

I need to display the reports as mentioned above. But the green value gets over-ridden by the yellow value like below .I have  specified "stacked=true".

User-added image




Here is my code :

Controller :

public with sharing class Rfleet_DashboardcurrentYear{
public decimal Dvol{get;set;}
public decimal Dvol1{get;set;}
public decimal dElTarSum{get;set;}
public decimal tArRatioSum{get;set;}
public decimal dElComSum{get;set;}
public decimal cOmRatioSum{get;set;}
public decimal iKamForcastSum{get;set;}
 public String mOnthName{get;set;}
public decimal cUrntMonth{get;set;}
 public decimal cOunForcastSum{get;set;}
   public decimal cOunForCastRatio{get;set;}
   public decimal cUrntYear{get;set;}
   public String str{get;set;}
     public String s{get;set;}
    
    
   
 public Rfleet_DashboardcurrentYear(){
 
 //Global deliveries Realized
       Dvol1=0;
    
       List<AggregateResult> tAr=[select SUM(Countries_delivered_volume__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ar : tAr)  {
            Dvol=(decimal)ar.get('expr0');
           system.debug('<<<<<<<a value'+Dvol);
       }
 // Annual global deliveries target  
       AggregateResult[] tArRatio=[select SUM(Target_ratio__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ar : tArRatio)  {
            tArRatioSum=(decimal) ar.get('expr0');
            system.debug('<<<<<<<a value'+tArRatioSum);
        }
       
       AggregateResult[] dElTar=[select SUM(Annual_deliveries_target__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ar : dElTar)  {
            dElTarSum=(decimal) ar.get('expr0');
            system.debug('<<<<<<<a value'+dElTarSum);
        }
//Annual global deliveries Commitment
        AggregateResult[] cOmRatio=[select SUM(Commitment_Ratio__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ar : cOmRatio)  {
            cOmRatioSum=(decimal) ar.get('expr0');
            system.debug('<<<<<<<a value'+cOmRatioSum);
        }
        decimal intround=cOmRatioSum.setScale(0,System.Roundingmode.HALF_UP);  
         s = ' '+intround+'%';
      
        AggregateResult[] dElCom=[select SUM(Annual_global_deliveries_commitment__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ar : dElCom)  {
           dElComSum=(decimal) ar.get('expr0');
          system.debug('<<<<<<<a value'+dElComSum);
        }
 //Country Forecast
 
        AggregateResult[] cOunForcast=[select SUM(Countries_forecast__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ar : cOunForcast)  {
            cOunForcastSum=(decimal) ar.get('expr0');
            system.debug('<<<<<<<a value'+cOunForcastSum);
        }
       
        cOunForCastRatio=(Dvol/cOunForcastSum)*100;
       
       
  //Current year
       
       AggregateResult[] cUrntYr=[select CALENDAR_YEAR(Current_month__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ar : cUrntYr)  {
            cUrntYear=(Integer) ar.get('expr0');
            system.debug('<<<<<<<a value'+cUrntYear);
        }
       
       str=String.valueof(cUrntYear);
       
 //Current month
    
 AggregateResult[] cUrntMon=[select CALENDAR_MONTH(Current_month__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_MONTH(Current_month__c)];
        for (AggregateResult ar : cUrntMon)  {
            cUrntMonth=(Integer) ar.get('expr0');
            system.debug('<<<<<<<a value'+cUrntMonth);
        }
 
If(cUrntMonth==1){mOnthName='Jan';}
 else if(cUrntMonth==2){mOnthName='Feb';}
  else if(cUrntMonth==3){mOnthName='Feb';}
   else if(cUrntMonth==4){mOnthName='Apr';}
    else if(cUrntMonth==5){mOnthName='May';}
     else if(cUrntMonth==6){mOnthName='June';}
      else if(cUrntMonth==7){mOnthName='July';}
       else if(cUrntMonth==8){mOnthName='Aug';}
        else if(cUrntMonth==9){mOnthName='Sep';}
         else if(cUrntMonth==10){mOnthName='Oct';}
          else if(cUrntMonth==11){mOnthName='Nov';}
           else if(cUrntMonth==12){mOnthName='Dec';}
            else{}

     
       AggregateResult[] iKamForcast=[select SUM(IKAM_forecast__c) from Account where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ard : iKamForcast)  {
           iKamForcastSum=(decimal) ard.get('expr0');
            system.debug('<<<<<<<a value'+iKamForcastSum);
        }       
 }  
}

VF Page Code:

<apex:page controller="Rfleet_DashboardcurrentYear" >
   <script>
 
 var dataArray = new Array();
       
         
           dataArray.push({'data1':{!Dvol1},'data2':{!Dvol},'name':'Deliveries volume\nrealized({!mOnthName} {!str})'});
           dataArray.push({'data1':{!tArRatioSum},'data2':{!dElTarSum}, 'name':'Annual global\ndeliveries\ntarget\n({!str})'});
             dataArray.push({'data1':{!cOmRatioSum},'data2':{!dElComSum}, 'name':'Annual global\ndeliveries\nCommitment\n({!str})'});
            dataArray.push({'data1':{!cOunForCastRatio},'data2':{!cOunForcastSum}, 'name':'Countries\nforecast({!str}\n {!mOnthName})'});
     
          </script>
 <apex:chart data="dataArray" height="400" width="500" colorSet="#FFB547,#9ACD32" >
  
<apex:axis type="Numeric" position="left"  grid="true" fields="data2"/>
<apex:axis type="Numeric" position="right"  fields="data1" minimum="0" maximum="100" steps="4"/>
<apex:axis type="Category" position="bottom" fields="name"/>


 
   <apex:barSeries orientation="vertical" axis="right" stacked="true" xField="name" yField="data1"  >
    <apex:chartLabel field="data1" display="insideEnd" orientation="horizontal"/>
      </apex:barSeries>
   
        
    <apex:barSeries orientation="vertical" axis="left" stacked="true" xField="name" yField="data2" >
     <apex:chartLabel field="data2" display="middle" orientation="horizontal"/>
    
              
         </apex:barSeries>
   
        
</apex:chart>
</apex:page>

Please provide me a solution for this . Thanks in advance !!!!
I need to store the organization business hours value in a field .. Is it possible to store that in a formula field ? If not , by any chance can we get the organization business hours through coding or something ? In my org , there are 33 countries and each country has different org business hours(monday - sunday)... Please help me out !! thanks in advance !!!
 I have custom object called Opportunity car set object. In the object there are 5 fields. name, brand, model name(lookup to product),version name (lookup to product),price Depending upon the selection of model name and version name the price field should be updated. The model name and version name are sent as parameter to get the price value from web service
 
trigger Rfleet_OpptyUpdateC2GPrice on Opportunity_car_set__c (before insert,before update) {

Public String modelOppValue;
Public String versionOppValue;


  for(Opportunity_car_set__c oppcarset:[select id,Price_HT__c,Model__r.Name,Version__r.Name from Opportunity_car_set__c  where id in:trigger.new]){
   system.debug('oppcarset.id----------------->'+oppcarset.id);
   system.debug('oppcarset.Model__r.Name----------------->'+oppcarset.Model__r.Name);
   system.debug('oppcarset.Version__r.Name----------------->'+oppcarset.Version__r.Name);
   modelOppValue = oppcarset.Model__r.Name;
   versionOppValue = oppcarset.Version__r.Name; 
   //Rfleet_DZVersionPrice_CLS.doCallout(modelOppValue,versionOppValue);
   Rfleet_DZVersionPrice_CLS.chkVersionCallOut(modelOppValue,versionOppValue);

      system.debug('modelOppValue--------------------->'+ modelOppValue);
      system.debug('versionOppValue --------------------->'+ versionOppValue);
        }

}
My  apex class:
global class Rfleet_DZVersionPrice_CLS {
static String strModelName;
static String strVersionName;
static String strOppid;
@future(callout=true)
public static void chkVersionCallOut(string id,string modelName,string versionName) {
    strOppid =id;
    strModelName = modelName;
    strVersionName = versionName;
    System.debug('strModelName -------------------------------->'+strModelName);
    System.debug('strVersionName -------------------------------->'+strVersionName);
    Rfleet_DZC2GVersionPriceDetails_CLS dzVersionPrize = new Rfleet_DZC2GVersionPriceDetails_CLS(strOppid,strModelName,strVersionName);
    ProcessorControl.inFutureContext = true;
    Double VerPrice=dzVersionPrize.getVersionPrice();
    Opportunity_car_set__c opp=[SELECT Price_HT__c FROM Opportunity_car_set__c where id=:strOppid ];
    system.debug('opp>>'+ opp);
    opp.Price_HT__c=decimal.Valueof(VerPrice);
    system.debug('opp next>>'+ opp);
    Update opp;
}

}

Webservice class:
public class Rfleet_DZC2GVersionPriceDetails_CLS {
public String strJSON {get;set;}
public String strGeturl {get;set;}
public String strGetcountrycode {get;set;}
public String strGetCurrency {get;set;}
public String strModelCode {get;set;}
public String strVersionCode {get;set;}
public String strVersionDocUrl {get;set;}
public String strPriceListURL {get;set;}
public String strOppid {get;set;}
public double strversionPrice{get;set;}
public List<String> lstModelcalOut = new List<String>(); //to get list of model code
public List<String> lstDoCcalOut = new List<String>(); //to get list of docurls
public Map<String,String> mVersion     = new map<String,String>();  //Contains model code+doc url
Rfleet_JSON2ApexC2G_CLS obj = null;
public string strModel{get;set;}
public string strVersion{get;set;} 
public string strid{get;set;} 
public Rfleet_DZC2GVersionPriceDetails_CLS(string strOppid,String strModelName, String strVersionName) {

    Rfleet_CountryInfo__c cs = Rfleet_CountryInfo__c.getInstance('Algeria');
    strGeturl         =    cs.Rfleet_C2GURL__c;
    strGetcountrycode =    cs.Rfleet_CountryCode__c;
    strGetCurrency    =    cs.Rfleet_Currency__c;
    strModel=strModelName;
    strVersion=strVersionName;
    strid=strOppid;
    Opportunity_car_set__c opp=[SELECT Model__r.ProductCode,Version__r.Rfleet_C2G_version_code__c FROM Opportunity_car_set__c where Model__r.name =: strModel and Version__r.name =: strVersion and id=:strid];    
    strModelCode    = opp.Model__r.ProductCode;
    strVersionCode  = opp.Version__r.Rfleet_C2G_version_code__c;
    strOppid        = opp.id;
    system.debug('<<strOppid'+ strOppid);

}

//Common method to Parse the JSON
public String init(String strVersionURL) {
    try {
        Http http = new Http();
        HttpRequest httpReq = new HttpRequest();
        httpReq.setEndpoint(strVersionURL);
        httpReq.setHeader('Accept','application/JSON');
        httpReq.setMethod('GET');
        HttpResponse response = http.send(httpReq);
        strJSON= response.getBody();

    } catch (Exception ex) {
        system.debug('<<Method: init Exception ::'+ ex);
    } 
    return  strJSON;     
}

//Used for Getting ModelCode and Doc URL in Map
public Map<String, String> getJSONFromREST() {
    strJSON = init(strGeturl); 
    JSONParser parser = JSON.createParser(strJSON);
    while(parser.nextToken() !=null) {
        if (parser.getCurrentToken() == JSONToken.FIELD_NAME) {
            String fieldName = parser.getText();
            if(fieldName == 'modelSpecCode') { 
                parser.nextToken();
                lstModelcalOut.add(parser.getText());
            } 
            if(fieldName == 'doc') {
                parser.nextToken();
                lstDoCcalOut.add(parser.getText());
            } 
        }
    }
    for(integer i=0;i<lstModelcalOut.size();i++) {
        mVersion.put(lstModelcalOut.get(i),lstDoCcalOut.get(i));
    }
    system.debug('mVersion===>'+mVersion);
    return mVersion;       
}

//Used to get Version Price URL
public String getVersionPriceURL() {
     Map<string,String> mVersionVal=getJSONFromREST();
    if(mVersionVal.containsKey(strModelCode)) {
        strVersionDocUrl= mVersionVal.get(strModelCode);
    }
    strJSON = init(strVersionDocUrl); 
    JSONParser parser = JSON.createParser(strJSON);
    while (parser.nextToken() != null) {
            if (parser.getCurrentToken() == JSONToken.FIELD_NAME) {
                String fieldName = parser.getText();
                if(fieldName == 'pricesList') {
                    parser.nextToken();
                    strPriceListURL=parser.getText();
                    system.debug('strPriceListURL>>>>'+strPriceListURL);
                }
            }    
    }
    return strPriceListURL;         
}
public double getVersionPrice() {
       String strVersionPriceURL=getVersionPriceURL();
       String strJSON = init(strVersionPriceURL);
       obj = Rfleet_JSON2ApexC2G_CLS.parse(strJSON);
       List<Rfleet_JSON2ApexC2G_CLS.PriceList> listPriceList  = obj.PriceList;  
       for(Rfleet_JSON2ApexC2G_CLS.PriceList priceList : listPriceList) {
            String strPriceTypeReference = (String)priceList.priceType.reference;
            List<Rfleet_JSON2ApexC2G_CLS.VersionPriceList>  listVersionPriceList;
            if(strPriceTypeReference =='PVCHT') {
                listVersionPriceList = new List<Rfleet_JSON2ApexC2G_CLS.VersionPriceList>();
                listVersionPriceList = priceList.versionPriceList;
                for(integer i=0; i< listVersionPriceList.size(); i++) {
                    String strversionIdSpecCode = listVersionPriceList.get(i).versionIdSpecCode;
                    if(strversionIdSpecCode==strVersionCode) {
                      strversionPrice = listVersionPriceList.get(i).price;
                      system.debug('<<<<<<<<<VersionId and Price'+ strversionPrice);  
                    }
                    
                }
            } 
        }  
        system.debug('<<<<<<<<<VersionId outside Price'+ strversionPrice);
        return strversionPrice;
  
} 

}

apex - How to update a custom field while inserting and updating the record using trigger? - Salesforce Stack Exchangeapex class to prevent recursive run:**
public class ProcessorControl {  
     public static boolean inFutureContext = false;
}
My problem is:

While inserting  and modifying the record, price value is not updated.While modifying the record the value is updated after refreshing the page.please help me out!!!thanks in advance !!!



.
The JSON structure I am using is as follows :

User-added image




I am trying to get the 'fr' inside the 'label' which is inside the 'version presentation'. I have tried so many times and here is my coding :

    public class GetRestfulExampleSucces {

public string jsonStr {get;set;}
public Pagereference getJSONFromREST() {
        Http h = new Http();
        HttpRequest req = new HttpRequest();
        req.setEndpoint('http://dz.co.rplug.renault.com/pres/BAWg');
        req.setHeader('Accept','application/JSON');
        req.setMethod('GET');
        HttpResponse res = h.send(req);
        jsonStr= res.getBody();
        List<String> calOut = new List<String>();
        system.debug('jsonStr>>>>>>>>>>>>'+jsonStr);
        JSONParser parser = JSON.createParser(jsonStr);
        while (parser.nextToken() != null) {
            if (parser.getCurrentToken() == JSONToken.FIELD_NAME){
                String fieldName = parser.getText();
                system.debug('fieldName >>>>>>>>>>>>'+fieldName );
                if(fieldName == 'versionsPresentation'){
                    while(parser.nextToken() != null){                   
                        if(parser.getCurrentToken() == JSONToken.FIELD_NAME){
                            String Mname = parser.getText();
                            system.debug('Mname >>>>>>>'+Mname );
                                if(Mname == 'fr'){
                                parser.nextToken();
                                 string version=parser.getText();
                                system.debug('version>>>>>>>'+version);
                                }
                        }
                    }
                }
            }
        }
    return null;
        }

}

 By using the above coding , I am getting again all the field values . Please provide me a solution for my query.

Thanks in advance !!!


 
I have wriiten a test class for an apex class which have a wrapper class.In the test class the wrapper class lines are not covered.Please help me out!
My apex class:
public with sharing class Rfleet_Dashboard_DeliveriesYear {

public Rfleet_Dashboard_DeliveriesYear(ApexPages.StandardController controller) {

  
   
System.Debug('>>>>>>>>>>>>>a value --> ' +selcoun);

recentdate=[SELECT Current_month__c FROM IKAM_Data__c where Current_month__c != null order by  Current_month__c Desc limit 1].Current_month__c ;
system.debug('date<<<<<<<<<'+recentdate.day());
recentyear=recentdate.year();
recentmonth=recentdate.month();


If(recentmonth==1){mOnthName='January';}
 else if(recentmonth==2){mOnthName='February';}
  else if(recentmonth==3){mOnthName='March';}
   else if(recentmonth==4){mOnthName='April';}
    else if(recentmonth==5){mOnthName='May';}
     else if(recentmonth==6){mOnthName='June';}
      else if(recentmonth==7){mOnthName='July';}
       else if(recentmonth==8){mOnthName='August';}
        else if(recentmonth==9){mOnthName='Sepetember';}
         else if(recentmonth==10){mOnthName='October';}
          else if(recentmonth==11){mOnthName='November';}
           else if(recentmonth==12){mOnthName='December';}
            else{}

france=false;
    europe=false;
    eurasia=false;
    asia=false;
    AMI=false;
    america=false;

    allcountry=true;
    }
 public String mOnthName{get;set;}
public Integer recentyear{get;set;}
public Integer recentmonth{get;set;}  
public boolean america{get;set;}
public boolean allcountry {get;set;}
public boolean AMI{get;set;}
public boolean asia{get;set;}
public boolean eurasia{get;set;}
public boolean europe{get;set;}
public boolean france{get;set;}
public string selcoun{get;set;} 
public Date recentdate{get;set;} 


public String getcont() {return selcoun;}

 
public class Month {
    public Decimal year {get; set;}
    public Decimal volume{get; set;}
    Month(Decimal year,Decimal volume) {this.year = year;this.volume= volume;}
}

public Month[] getMonths() {
    Month[] months = new Month[] {};
    System.Debug('>>>>>>>>>>>>>insid getmonths--> ' +selcoun);
    for (AggregateResult ar : [

SELECT sum( IKAM_Data__r.Countries_delivered_volume__c)Dvol,CALENDAR_YEAR(IKAM_Data__r.Current_month__c)Year FROM Country_DCVF_Volume__c  group by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) order by CALENDAR_YEAR(IKAM_Data__r.Current_month__c)]) {
    months.add(new Month((Decimal )ar.get('Year'),(Decimal)ar.get('Dvol')));
    }
    system.debug('------->'+months);
    return months;
}  

      
      
    public class Month1 {
    public Decimal year {get; set;}
    public Decimal volume{get; set;}
    Month1(Decimal year,Decimal volume) {this.year = year;this.volume= volume;}
}

public Month[] getMonths1() {
    Month[] months1 = new Month[] {};
      System.Debug('>>>>>>>>>>>>>insid getmonths1--> ' +selcoun);
    for (AggregateResult ar : [SELECT sum( IKAM_Data__r.Countries_delivered_volume__c)Dvol,CALENDAR_YEAR(IKAM_Data__r.Current_month__c)Year FROM Country_DCVF_Volume__c where region__c='americas' group by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) order by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) ]) {                                        
    months1.add(new Month((Decimal )ar.get('Year'),(Decimal)ar.get('Dvol')));
    }
    system.debug('------->'+months1);
    return months1;
} 

 public class Month2{
    public Decimal year {get; set;}
    public Decimal volume{get; set;}
    Month2(Decimal year,Decimal volume) {this.year = year;this.volume= volume;}
}

public Month[] getMonths2() {
    Month[] months2 = new Month[] {};
      System.Debug('>>>>>>>>>>>>>insid getmonths1--> ' +selcoun);
    for (AggregateResult ar : [SELECT sum( IKAM_Data__r.Countries_delivered_volume__c)Dvol,CALENDAR_YEAR(IKAM_Data__r.Current_month__c)Year FROM Country_DCVF_Volume__c where region__c='AMI' group by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) order by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) ]) {                                        
    months2.add(new Month((Decimal )ar.get('Year'),(Decimal)ar.get('Dvol')));
    }
    system.debug('------->'+months2);
    return months2;
} 
  public class Month3 {
    public Decimal year{get; set;}
    public Decimal volume{get; set;}
    Month3(Decimal year,Decimal volume) {this.year = year;this.volume= volume;}
}

public Month[] getMonths3() {
    Month[] months3 = new Month[] {};
      System.Debug('>>>>>>>>>>>>>insid getmonths1--> ' +selcoun);
    for (AggregateResult ar : [SELECT sum( IKAM_Data__r.Countries_delivered_volume__c)Dvol,CALENDAR_YEAR(IKAM_Data__r.Current_month__c)Year FROM Country_DCVF_Volume__c where region__c='Asia-Pacific' group by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) order by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) ]) {                                        
    months3.add(new Month((Decimal )ar.get('Year'),(Decimal)ar.get('Dvol')));
    }
    system.debug('------->'+months3);
    return months3;
}  

 public class Month4 {
    public Decimal year {get; set;}
    public Decimal volume{get; set;}
    Month4(Decimal year,Decimal volume) {this.year = year;this.volume= volume;}
}

public Month[] getMonths4() {
    Month[] months4 = new Month[] {};
      System.Debug('>>>>>>>>>>>>>insid getmonths1--> ' +selcoun);
    for (AggregateResult ar : [SELECT sum( IKAM_Data__r.Countries_delivered_volume__c)Dvol,CALENDAR_YEAR(IKAM_Data__r.Current_month__c)Year FROM Country_DCVF_Volume__c where region__c='Eurasia' group by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) order by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) ]) {                                        
    months4.add(new Month((Decimal )ar.get('Year'),(Decimal)ar.get('Dvol')));
    }
    system.debug('------->'+months4);
    return months4;
} 

 public class Month5 {
    public Decimal year {get; set;}
    public Decimal volume{get; set;}
    Month5(Decimal year,Decimal volume) {this.year = year;this.volume= volume;}
}

public Month[] getMonths5() {
    Month[] months5 = new Month[] {};
      System.Debug('>>>>>>>>>>>>>insid getmonths1--> ' +selcoun);
    for (AggregateResult ar : [SELECT sum( IKAM_Data__r.Countries_delivered_volume__c)Dvol,CALENDAR_YEAR(IKAM_Data__r.Current_month__c)Year FROM Country_DCVF_Volume__c where region__c='Europe G9' group by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) order by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) ]) {                                        
    months5.add(new Month((Decimal )ar.get('Year'),(Decimal)ar.get('Dvol')));
    }
    system.debug('------->'+months5);
    return months5;
} 

 public class Month6 {
    public Decimal year {get; set;}
    public Decimal volume{get; set;}
    Month6(Decimal year,Decimal volume) {this.year = year;this.volume= volume;}
}

public Month[] getMonths6() {
    Month[] months6 = new Month[] {};
      System.Debug('>>>>>>>>>>>>>insid getmonths1--> ' +selcoun);
    for (AggregateResult ar : [SELECT sum( IKAM_Data__r.Countries_delivered_volume__c)Dvol,CALENDAR_YEAR(IKAM_Data__r.Current_month__c)Year FROM Country_DCVF_Volume__c where region__c='France' group by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) order by CALENDAR_YEAR(IKAM_Data__r.Current_month__c) ]) {                                        
    months6.add(new Month((Decimal )ar.get('Year'),(Decimal)ar.get('Dvol')));
    }
    system.debug('------->'+months6);
    return months6;
}
public List<SelectOption> getRegion() {
    List<SelectOption> options = new List<SelectOption>();
    
    options .add(new SelectOption('All countries','All countries'));
    Schema.DescribeFieldResult fieldResult = Country_DCVF_Volume__c.Region__c .getDescribe();
    List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
    for( Schema.PicklistEntry f : ple)
    {
    options.add(new SelectOption(f.getLabel(), f.getValue()));
    }
    return options;
}

      
public PageReference selectedcountry() {
    System.Debug('>>>>>>>>>>>>>insid pageref--> ' +selcoun);
     france=false;
    europe=false;
    eurasia=false;
    asia=false;
    AMI=false;
    america=false;
    allcountry=true;
    getMonths();
    return null;
}

public PageReference selectedcountry1() {

 allcountry=false;
   
    america=true;
   
    getMonths1();
    return null;
}

public PageReference selectedcountry2() {
      france=false;
    europe=false;
    eurasia=false;
    asia=false;
    AMI=true;
    america=false;
    allcountry=false;
    getMonths2();
    return null;
}

public PageReference selectedcountry3() {
    france=false;
    europe=false;
    eurasia=false;
    asia=true;
    AMI=false;
    america=false;
    allcountry=false;
    getMonths3();
    return null;
}
   public PageReference selectedcountry4() {
    france=false;
    europe=false;
    eurasia=true;
    asia=false;
    AMI=false;
    america=false;
    allcountry=false;
    getMonths4();
    return null;
}
  
  public PageReference selectedcountry5() {
   france=false;
    europe=true;
    eurasia=false;
    asia=false;
    AMI=false;
    america=false;
    allcountry=false;
    getMonths5();
    return null;
}
  
  public PageReference selectedcountry6() {
    france=true;
    europe=false;
    eurasia=false;
    asia=false;
    AMI=false;
    america=false;
    allcountry=false;
    getMonths6();
    return null;
}
  

 
 }

My test class:
@isTest
public class Rfleet_Dashboard_DeliveriesYear_Test {
    public static testMethod void deliverytest(){
         Id rType =[Select id from RecordType where sObjectType = 'Account' and name='RFLEET-ACC-DCVF-RT'].id;    
        account acc = new account(name='gfgf',montant__c=0.3,recordtypeid=rType);
        insert acc;
        acc.Name='hghg';
        update acc;
        
        
        IKAM_Data__c ikam = new IKAM_Data__c();
        ikam.Annual_deliveries_target__c=85;
        ikam.Annual_global_deliveries_commitment__c=90;
        ikam.Account__c=acc.id; // insert some account and use that id here 001m000000NPFrU
        ikam.IKAM_Year__c=2015;
        test.startTest();
        insert ikam;
         
       
      country_dcvf_volume__c con = new country_dcvf_volume__c();
        con.Country__c='Algeria';
        con.Region__c='France';
        con.Insertion_date__c=system.Today();
        con.KAM__c='Prabu';
        con.Country_forecast__c=3;
        con.Delivered_volume__c=1;
        con.Parent_Account__c=acc.id;  // insert some account and use that id here  001m000000NFrdp
        con.IKAM_Data__c=ikam.id;
        insert con;
         
        
        
        pagereference vfpage = page.Rfleet_Dashboard_DeliveriesYear_Vf;
        test.setCurrentPageReference(vfpage);
        apexpages.StandardController bre = new apexpages.StandardController(con);
       // Rfleet_Dashboard_DeliveriesYear.Month1 = new Rfleet_Dashboard_DeliveriesYear.Month1();
        Rfleet_Dashboard_DeliveriesYear controller = new Rfleet_Dashboard_DeliveriesYear(bre);
        
        
        controller.getcont();
        controller.getMonths();
        controller.getMonths1();
        controller.getMonths2();
        controller.getMonths3();
        controller.getMonths4();
        controller.getMonths5();
        controller.getMonths6();
        controller.getRegion();
        controller.selectedcountry();
        controller.selectedcountry1();
        controller.selectedcountry2();
        controller.selectedcountry3();
        controller.selectedcountry4();
        controller.selectedcountry5();
        controller.selectedcountry6();
        
       
      }
  
}

The wraper class lines are not covered in test class.The uncovered lines in test class are:
User-added image
I have written the test class for my apex class. The test class is not covered inside the aggregate functions. Please help me out !

My apex class:
public with sharing class Rfleet_DashboardcurrentYear{
public decimal Dvol{get;set;}
public decimal dElTarSum{get;set;}
public decimal tArRatioSum{get;set;}
public decimal dElComSum{get;set;}
public decimal cOmRatioSum{get;set;}
public decimal iKamForcastSum{get;set;}
public String mOnthName{get;set;}
public decimal cUrntMonth{get;set;}
public decimal cOunForcastSum{get;set;}
public decimal cOunForCastRatio{get;set;} 
public decimal cUrntYear{get;set;}
public String str{get;set;}
public String s{get;set;}
public String selectedval{get;set;}
public decimal iKamForcastRatio{get;set;} 
public decimal iKamForcastRatioIn;
public decimal cOunForCastRatioIn;
public decimal maxvalue{get;set;} 
public Rfleet_DashboardcurrentYear(ApexPages.StandardController controller) {
//Global deliveries Realized
    List<AggregateResult> tAr=[select SUM(Countries_delivered_volume__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    for (AggregateResult ar : tAr)  {
    Dvol=(decimal)ar.get('expr0');
     }
// Annual global deliveries target   
    AggregateResult[] tArRatio=[select SUM(Target_ratio__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    for (AggregateResult ar : tArRatio)  {
    Decimal tArRatioSumIn=(decimal) ar.get('expr0');
    tArRatioSum=tArRatioSumIn.setScale(0,System.Roundingmode.HALF_UP); 
    }

    AggregateResult[] dElTar=[select SUM(Annual_deliveries_target__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    for (AggregateResult ar : dElTar)  {
    dElTarSum=(decimal) ar.get('expr0');
    //system.debug('<<<<<<<a value'+dElTarSum);
    }
//Annual global deliveries Commitment
    AggregateResult[] cOmRatio=[select SUM(Commitment_Ratio__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    for (AggregateResult ar : cOmRatio)  {
    Decimal cOmRatioSumIn=(decimal) ar.get('expr0');
    //system.debug('<<<<<<<a value'+cOmRatioSumIn);
    if(cOmRatioSumIn!=null)
    cOmRatioSum=cOmRatioSumIn.setScale(0,System.Roundingmode.HALF_UP); 
    }


    AggregateResult[] dElCom=[select SUM(Annual_global_deliveries_commitment__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    for (AggregateResult ar : dElCom)  {
    dElComSum=(decimal) ar.get('expr0');
    //system.debug('<<<<<<<a value'+dElComSum);
    }
//Country Forecast

    AggregateResult[] cOunForcast=[select SUM(Countries_forecast__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    if(cOunForcast.size()>0)
    {
    for (AggregateResult ar : cOunForcast)  {
    cOunForcastSum=(decimal) ar.get('expr0');
    //system.debug('<<<<<<<a value'+cOunForcastSum);
    }
    }

    if(cOunForcastSum!=null)
    {
    cOunForCastRatioIn=(Dvol/cOunForcastSum)*100;
    cOunForCastRatio=cOunForCastRatioIn.setScale(0,System.Roundingmode.HALF_UP); 
    }

//Current year

    AggregateResult[] cUrntYr=[select CALENDAR_YEAR(Current_month__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    for (AggregateResult ar : cUrntYr)  {
    cUrntYear=(Integer) ar.get('expr0');
    //system.debug('<<<<<<<a value'+cUrntYear);
    }
    str=String.valueof(cUrntYear);

//Current month
    AggregateResult[] cUrntMon=[select CALENDAR_MONTH(Current_month__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_MONTH(Current_month__c) order by CALENDAR_MONTH(Current_month__c) desc limit 1];
    for (AggregateResult ar : cUrntMon)  {
    cUrntMonth=(Integer) ar.get('expr0');
    //system.debug('<<<<<<<a value'+cUrntMonth);
    }

If(cUrntMonth==1){mOnthName='January';}
else if(cUrntMonth==2){mOnthName='February';}
else if(cUrntMonth==3){mOnthName='March';}
else if(cUrntMonth==4){mOnthName='April';}
else if(cUrntMonth==5){mOnthName='May';}
else if(cUrntMonth==6){mOnthName='June';}
else if(cUrntMonth==7){mOnthName='July';}
else if(cUrntMonth==8){mOnthName='August';}
else if(cUrntMonth==9){mOnthName='September';}
else if(cUrntMonth==10){mOnthName='October';}
else if(cUrntMonth==11){mOnthName='November';}
else if(cUrntMonth==12){mOnthName='December';}
else{}

    AggregateResult[] iKamForcast=[select SUM(IKAM_forecast__c) from Account where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
    if(iKamForcast.size()>0)
    {
    for (AggregateResult ar : iKamForcast)  {
    iKamForcastSum=(decimal) ar.get('expr0');
   // system.debug('<<<<<<<a value'+iKamForcastSum);
    }
    }
    

    if(iKamForcastSum!=null)
    {
    iKamForcastRatioIn=(Dvol/iKamForcastSum)*100;
    iKamForcastRatio=iKamForcastRatioIn.setScale(0,System.Roundingmode.HALF_UP); 
    }
    
      maxvalue= (dElTarSum>dElComSum&& dElTarSum>cOunForcastSum&& dElTarSum>iKamForcastSum) ? dElTarSum: ((dElComSum>cOunForcastSum && dElComSum>iKamForcastSum) ? dElComSum: ((cOunForcastSum>iKamForcastSum)?cOunForcastSum: iKamForcastSum)) ;  
    }  

 
}

My test class :
@isTest
public class Rfleet_DashboardcurrentYear_Test {    
static testMethod void DashboardcurrentYear(){
test.startTest();
        Id rType =[Select id from RecordType where sObjectType = 'Account' and name='RFLEET-ACC-DCVF-RT'].id;    
        Account acc = new Account(Name='Prabu',Montant__c=5,recordtypeid=rType);
        insert acc;
        system.debug('-------->acc value is ' + acc);
        IKAM_Data__c ikam=new IKAM_Data__c(Annual_deliveries_target__c=45,Annual_global_deliveries_commitment__c=98,IKAM_Year__c=2015,CurrencyIsoCode='INR',Account__c=acc.id);
        insert ikam;
        
        ApexPages.StandardController sc = new ApexPages.standardController(ikam);  
        Rfleet_DashboardcurrentYear accPageCtrl = new Rfleet_DashboardcurrentYear (new ApexPages.StandardController(ikam));     
             
      
        accPageCtrl.Dvol=6.8;   
        accPageCtrl.cOmRatioSum=34.5;
        accPageCtrl.cOunForCastRatio=23.3;
        accPageCtrl.cOunForcastSum=67.8;
        accPageCtrl.cUrntMonth=9.0;
        accPageCtrl.cUrntYear=2015.0;
        accPageCtrl.dElComSum=56.8;
        accPageCtrl.dElTarSum=89;     
        accPageCtrl.iKamForcastRatio=8.7;
        accPageCtrl.iKamForcastSum=56.7;
        accPageCtrl.mOnthName='january';
        accPageCtrl.iKamForcastRatioIn=9.8;
        accPageCtrl.cOunForCastRatioIn=6.7;
        accPageCtrl.tArRatioSum=5.6;
        accPageCtrl.selectedval='hjk';
        accPageCtrl.str='gjg';
        accPageCtrl.s='jh';
        test.stopTest();
}
}

 I have added the screenshot for uncovered lines in my apex class 
User-added image
How to overcome the colour over-ridden issue in bar chart?

  User-added image

 

I need to display the reports as mentioned above. But the green value gets over-ridden by the yellow value like below .I have  specified "stacked=true".

User-added image




Here is my code :

Controller :

public with sharing class Rfleet_DashboardcurrentYear{
public decimal Dvol{get;set;}
public decimal Dvol1{get;set;}
public decimal dElTarSum{get;set;}
public decimal tArRatioSum{get;set;}
public decimal dElComSum{get;set;}
public decimal cOmRatioSum{get;set;}
public decimal iKamForcastSum{get;set;}
 public String mOnthName{get;set;}
public decimal cUrntMonth{get;set;}
 public decimal cOunForcastSum{get;set;}
   public decimal cOunForCastRatio{get;set;}
   public decimal cUrntYear{get;set;}
   public String str{get;set;}
     public String s{get;set;}
    
    
   
 public Rfleet_DashboardcurrentYear(){
 
 //Global deliveries Realized
       Dvol1=0;
    
       List<AggregateResult> tAr=[select SUM(Countries_delivered_volume__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ar : tAr)  {
            Dvol=(decimal)ar.get('expr0');
           system.debug('<<<<<<<a value'+Dvol);
       }
 // Annual global deliveries target  
       AggregateResult[] tArRatio=[select SUM(Target_ratio__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ar : tArRatio)  {
            tArRatioSum=(decimal) ar.get('expr0');
            system.debug('<<<<<<<a value'+tArRatioSum);
        }
       
       AggregateResult[] dElTar=[select SUM(Annual_deliveries_target__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ar : dElTar)  {
            dElTarSum=(decimal) ar.get('expr0');
            system.debug('<<<<<<<a value'+dElTarSum);
        }
//Annual global deliveries Commitment
        AggregateResult[] cOmRatio=[select SUM(Commitment_Ratio__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ar : cOmRatio)  {
            cOmRatioSum=(decimal) ar.get('expr0');
            system.debug('<<<<<<<a value'+cOmRatioSum);
        }
        decimal intround=cOmRatioSum.setScale(0,System.Roundingmode.HALF_UP);  
         s = ' '+intround+'%';
      
        AggregateResult[] dElCom=[select SUM(Annual_global_deliveries_commitment__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ar : dElCom)  {
           dElComSum=(decimal) ar.get('expr0');
          system.debug('<<<<<<<a value'+dElComSum);
        }
 //Country Forecast
 
        AggregateResult[] cOunForcast=[select SUM(Countries_forecast__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ar : cOunForcast)  {
            cOunForcastSum=(decimal) ar.get('expr0');
            system.debug('<<<<<<<a value'+cOunForcastSum);
        }
       
        cOunForCastRatio=(Dvol/cOunForcastSum)*100;
       
       
  //Current year
       
       AggregateResult[] cUrntYr=[select CALENDAR_YEAR(Current_month__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ar : cUrntYr)  {
            cUrntYear=(Integer) ar.get('expr0');
            system.debug('<<<<<<<a value'+cUrntYear);
        }
       
       str=String.valueof(cUrntYear);
       
 //Current month
    
 AggregateResult[] cUrntMon=[select CALENDAR_MONTH(Current_month__c) from IKAM_Data__c where Current_month__c=this_year group by CALENDAR_MONTH(Current_month__c)];
        for (AggregateResult ar : cUrntMon)  {
            cUrntMonth=(Integer) ar.get('expr0');
            system.debug('<<<<<<<a value'+cUrntMonth);
        }
 
If(cUrntMonth==1){mOnthName='Jan';}
 else if(cUrntMonth==2){mOnthName='Feb';}
  else if(cUrntMonth==3){mOnthName='Feb';}
   else if(cUrntMonth==4){mOnthName='Apr';}
    else if(cUrntMonth==5){mOnthName='May';}
     else if(cUrntMonth==6){mOnthName='June';}
      else if(cUrntMonth==7){mOnthName='July';}
       else if(cUrntMonth==8){mOnthName='Aug';}
        else if(cUrntMonth==9){mOnthName='Sep';}
         else if(cUrntMonth==10){mOnthName='Oct';}
          else if(cUrntMonth==11){mOnthName='Nov';}
           else if(cUrntMonth==12){mOnthName='Dec';}
            else{}

     
       AggregateResult[] iKamForcast=[select SUM(IKAM_forecast__c) from Account where Current_month__c=this_year group by CALENDAR_YEAR(Current_month__c)];
        for (AggregateResult ard : iKamForcast)  {
           iKamForcastSum=(decimal) ard.get('expr0');
            system.debug('<<<<<<<a value'+iKamForcastSum);
        }       
 }  
}

VF Page Code:

<apex:page controller="Rfleet_DashboardcurrentYear" >
   <script>
 
 var dataArray = new Array();
       
         
           dataArray.push({'data1':{!Dvol1},'data2':{!Dvol},'name':'Deliveries volume\nrealized({!mOnthName} {!str})'});
           dataArray.push({'data1':{!tArRatioSum},'data2':{!dElTarSum}, 'name':'Annual global\ndeliveries\ntarget\n({!str})'});
             dataArray.push({'data1':{!cOmRatioSum},'data2':{!dElComSum}, 'name':'Annual global\ndeliveries\nCommitment\n({!str})'});
            dataArray.push({'data1':{!cOunForCastRatio},'data2':{!cOunForcastSum}, 'name':'Countries\nforecast({!str}\n {!mOnthName})'});
     
          </script>
 <apex:chart data="dataArray" height="400" width="500" colorSet="#FFB547,#9ACD32" >
  
<apex:axis type="Numeric" position="left"  grid="true" fields="data2"/>
<apex:axis type="Numeric" position="right"  fields="data1" minimum="0" maximum="100" steps="4"/>
<apex:axis type="Category" position="bottom" fields="name"/>


 
   <apex:barSeries orientation="vertical" axis="right" stacked="true" xField="name" yField="data1"  >
    <apex:chartLabel field="data1" display="insideEnd" orientation="horizontal"/>
      </apex:barSeries>
   
        
    <apex:barSeries orientation="vertical" axis="left" stacked="true" xField="name" yField="data2" >
     <apex:chartLabel field="data2" display="middle" orientation="horizontal"/>
    
              
         </apex:barSeries>
   
        
</apex:chart>
</apex:page>

Please provide me a solution for this . Thanks in advance !!!!