/***********************************************************************************************************************
* Component Name   : GNS_ACDDRefresh

***********************************************************************************************************************/
public with sharing class GNS_ACDDRefresh {
    public ApexPages.StandardController stdController1;
    public boolean profileRec{get;set;}
    private final SObject sObj;
    public final Deal_Protocol__c dp1;
    
    private final Deal_Protocol__c dpFullyCloned;
    private final static String YES = 'Yes';
    private final static String NO = 'No';
    private final static String REJECTED = 'Rejected';
    private final static String APPROVED = 'Approved';
    public boolean isMarketFieldEditable {get;private set;}
    public boolean isActiveDP{get;private set;}
    private final ID dealProtocolRecId;
    //Arshi: Added for controlling the acddrefresh for not completed DPs
    public boolean isCompiledDP {get;private set;}
    public boolean isCompleteDP{get;private set;}
    public boolean isShowComplDate {get;private set;}
    public Boolean isAdmin { get; set; }
     public Boolean dispAwardField { get; set; } //!--Arshi US2220461

    public void disable(){
system.debug('isdisabled')  ; 
      //  dp1 = new Deal_Protocol__c() ;
    }
    public GNS_ACDDRefresh(ApexPages.StandardController std)
    {


        if (!Test.isRunningTest()) {
            List<String> fields = new List<String>{'Status__c','Zip_file_of_all_evidence_attached__c','Accounting_Q1__c','Accounting_Q2__c','Accounting_Q3__c','Accounting_Q4__c','Accounting_Q5__c',
                                  'Accounting_Q6__c','Accounting_Q7__c','Accounting_Q8__c','Accounting_Q9__c','Accounting_Reviewer__c','Accounting_Score__c',
                                  'Accounting_Reviewer_Comment__c','Accounting_Decision__c','Accounting_Last_Modifiedby__c','AET_Q1__c','AET_Q2__c','AET_Q3__c',
                                  'AET_Q4__c','AET_Q5__c','AET_Q6__c','AET_Q7__c','AET_Reviewer__c','AET_Score__c','AET_Reviewer_Comment__c','AET_Decision__c',
                                  'AET_Last_Modifiedby__c','Capabilities_Q1__c','Capabilities_Q3__c','Capabilities_Q4__c','Capabilities_Q5__c','Capabilities_Q6__c',
                                  'Capabilities_Q7__c','Capabilities_Q8__c','Capabilities_Q9__c','Capabilities_Q10__c','Capabilities_Reviewer__c',
                                  'Capabilities_Score__c','Capabilities_Reviewer_Comment__c','Capabilities_Decision__c','Capabilities_Last_Modifiedby__c',
                                  'Controllership_Q1__c','Controllership_Q2__c','Controllership_Q3__c','Controllership_Q4__c','Controllership_Q5__c',
                                  'Controllership_Q6__c','Controllership_Q7__c','Controllership_Q8__c','Controllership_Q9__c','Controllership_Reviewer__c','Controllership_Score__c','Controllership_Reviewer_Comment__c','Controllership_Decision__c','Controllership_Last_Modifiedby__c'//};
                                  //Arshi: added these fields for controlling ACDD behavior
                                  ,'Status_Date__c','Deal_Protocol_Status__c','Submission_Date__c',
                                  'RAQ_Review_Completion_Date__c','Last_Date_for_Review__c','Reason_for_Review__c','isNewDpRecord__c'
                                  ,'Is_there_Variable_Pricing__c','Will_there_be_any_Upfront_Payments__c', 'Pricing_Details__c','Upfront_Payments__c'
                                  ,'mrp_1__c', 'mrp_2__c','mrp_3__c','mrp_4__c','mrp_5__c','mrp_additional5__c','mrp_6__c','mrp_7__c','mrp_additional7__c','mrp_8__c'
                                  ,'mrp_additional8__c','mrp_9__c','mrp_10__c','mrp_additional10__c','tech_1__c','tech_additional1__c','tech_2__c','tech_additional2__c'
                                  ,'tech_3__c','tech_additional3__c','tech_4__c','tech_additional4__c','tech_5__c','icsOps_2__c','icsOps_additional2__c','icsOps_3__c'
                                  ,'icsOps_4__c','icsOps_5__c','icsOps_6__c','icsOps_additional6__c','icsOps_7__c','icsOps_8__c','icsOps_9__c'
                                  ,'icsOps_10__c','icsOps_11__c','icsOps_additional11__c','icsOps_12__c','icsOps_13__c','icsOps_additional13__c','icsOps_14__c'
                                  ,'contr_2__c','contr_4__c','contr_additional4__c','contr_5__c','contr_additional5__c','contr_8__c','contr_11__c','Partner_Certification_Statement_Date__c'
                                  //Arshi mapping the DP approval section value to the ACDD refreshed record
                                  ,'Deal_Sign_Off_Decision__c','Market_VP_Director_Approval_Decision__c','Local_Market_Finance_Approver_Decision__c',
                                  'Local_Market_GCO_Approver_Decision__c','Deal_Sign_Off_Completion_Date__c','Market_VP_Director_Approval_Type__c',
                                  'Market_VP_Director_Approval_Due_DateTime__c','Local_Market_Finance_Approval_Type__c','Local_Market_Finance_ApprovalDueDateTime__c',
                                  'Local_Market_GCO_Approval_Type__c','Local_Market_GCO_Approval_DueDateTime__c','Local_Market_GCO_Approver__c',
                                  'Local_Market_Finance_Approver__c','Market_VP_Director_Approver__c','Fulfillment_monitoring__c','Payment_Team__c','Internal_Reporting_requirements_inc_SLA__c','External_Reporting_requirements_inc_SLA__c',
                                   'have_process_for_managing_Prepaid_invent__c','Will_the_deal_require_100_new_awards__c','Payment_Team_Engaged__c','GCO_Approval_Submitted_Date__c','VP_Approval_Submitted_Date__c','LFO_Approval_Submitted_Date__c'};
            std.addFields(fields);
        }

        stdController1 = std;
        profileRec = true;
        isActiveDP = true;
        //Arshi
        isCompleteDP = true;
        isCompiledDP = true;
        isMarketFieldEditable = true;
        sObj = stdController1.getRecord();
        this.dp1 = (Deal_Protocol__c)stdController1.getRecord();
        dealProtocolRecId = dp1.ID;
        //dpFullyCloned = new Deal_Protocol__c();
        dpFullyCloned = dp1.clone();
        List<Profile> proflist = [select id,name from profile where name in ('MR-ReadOnly-Prop','MR-ReadOnly','MR Business Admin (Read Only)',
                                                                             'MR ReadOnly-GNS (decrypted)','MR ReadOnly-GNS (Encrypted)',
                                                                            'MR ReadOnly-Hybrid (decrypted)','MR ReadOnly-Hybrid (Encrypted)')];
        for(Profile pro : proflist)
            
        {
            
            if(pro.id == userinfo.getProfileId())
            {
                dp1.addError('Read Only users are not authorised to submit Deal Protocol records. If you require Edit access please contact the System administrator or contact the MR Deal Protocol mailbox.');
                profileRec = false;
                return;
            }
        }
        //Arshi: Only DPs with completed status are allowed for refresh
        if(dp1.Status__c=='Expired'){
            dp1.addError('Please use Active Deal Protocol for ACDD Refresh');
            isActiveDP = false;
            return;
          }else if(dp1.Deal_Protocol_Status__c == REJECTED ){
            dp1.addError('ACDD Refresh is not possible on a Rejected record.  Please submit a new Deal Protocol');
            isCompleteDP = false;
            return;
        }else if(dp1.Deal_Protocol_Status__c != REJECTED && dp1.Deal_Protocol_Status__c != 'Complete' ){
            dp1.addError('Deal Protocol is being compiled.  Enter details in the ACDD section of the record');
            isCompiledDP = false;
            return;
        }

        if(dp1.Name.contains('_REF_')){
            string dpName = dp1.Name.substringBeforeLast('_');
            Integer nameIncrement = Integer.valueOf(dp1.Name.substringAfterLast('_'));
            nameIncrement+=1;
            dp1.Name = dpName+'_'+nameIncrement;
        }else{
            dp1.Name =  dp1.Name+'_REF_1';
        }
        //dp1.Pricing_Details__c =null;
        dp1.Submit_Deal_Protocol_record_for_Review__c = false;
        dp1.Deal_Project_Manager__c = null;
        dp1.ACDD_Status__c = 'Pending';
        dp1.Qualify_for_AEMP_10__c = 'No';
        dp1.TLM_Reference__c = null;
        dp1.Partner_Certification_Statement_Complete__c = null;
        dp1.Partner_Certification_Statement_Date__c = null;
        dp1.Due_Diligence_Required__c = null;
        dp1.ICSComplianceDecision__c = null;
        dp1.ICS_Compliance_Decision_Date__c = null;
        dp1.GlobalComplianceDecision__c = null;
        dp1.Global_Comp_Exception_Decision_Date__c = null;
        dp1.Seeking_an_Exception_to_Policy__c = false;
        dp1.ArcherExceptionId__c = null;
        dp1.TypeofACDD__c = null;
        dp1.HasRiskRankingChangedFromLastACDD__c = null;
        dp1.RiskRankingAnswer__c = null;
        dp1.Status__c =  'Active';
        dp1.StatusDate__c = system.now();
        //Arshi:
       // dp1.Is_there_Variable_Pricing__c  = null;
        isAdmin = false;
      // dp1.isdisabled__c = false;

        Profile adminProfile = [SELECT Id,Name FROM Profile WHERE Name = 'MR-Business Admin'];
        if(adminProfile.id == UserInfo.getProfileId())
        { isAdmin= true;}
         if(dp1.Type_of_Negotiation__c == 'New Partner' &&
           ( dp1.Type_of_Partner__c.containsIgnoreCase('Merchandise') || dp1.Type_of_Partner__c.containsIgnoreCase('Voucher') ||
           dp1.Type_of_Partner__c.containsIgnoreCase('Gift Card') || dp1.Type_of_Partner__c.containsIgnoreCase('E-Code'))){
               dispAwardField  = true;
           }else{
               dispAwardField   = false;
           }
    }

    //Called when user clicks Back To Deal Protocol Record button
    public pagereference backToRecord()
    {
        return new ApexPages.StandardController(sObj).view();
    }

    //Called when user clicks Save Button
    public pagereference save()
    {   Savepoint sPoint = Database.setSavepoint();
        Deal_Protocol__c dpClone = new Deal_Protocol__c();
        dpClone = (Deal_Protocol__c)stdController1.getRecord();
        if(dpClone.Qualify_for_AEMP_10__c <> NO){
            dp1.Qualify_for_AEMP_10__c.addError('Please select NO');
            return null;
        }
        if(dpClone.ICSComplianceDecision__c <> null && !dpClone.Seeking_an_Exception_to_Policy__c &&
           (dpClone.ICSComplianceDecision__c.equalsIgnoreCase('Approved') || dpClone.ICSComplianceDecision__c.equalsIgnoreCase(REJECTED))) {
               dpClone.GlobalComplianceDecision__c = 'N/A';
        }
        // Arshi added below lines to add key contract term section on questionnaire fields
        dpClone.mrp_7__c = dpClone.Is_there_Variable_Pricing__c  ;
        dpClone.mrp_additional7__c = dpClone.Pricing_Details__c ;
        dpClone.mrp_5__c = dpClone.Will_there_be_any_Upfront_Payments__c ;
        dpClone.mrp_additional5__c = String.valueOf(dpClone.Upfront_Payments__c)  ;
        if(dpClone.Will_there_be_any_Upfront_Payments__c =='No'){
            dpClone.Upfront_Payments__c= null;
        }
        if(dpClone.Is_there_Variable_Pricing__c == 'No'){
            dpClone.Pricing_Details__c='';
        }
        //End changes by Arshi
        Deal_Protocol__c oldDealProtocol = new Deal_Protocol__c(id=dealProtocolRecId, Status__c = 'Expired');
        //Changes by Arshi for getting the prepopulated deal status section:
        dpClone.Submission_Date__c=dpFullyCloned.Submission_Date__c;
        dpClone.Reason_for_Review__c=dpFullyCloned.Reason_for_Review__c;
        dpClone.RAQ_Review_Completion_Date__c=dpFullyCloned.RAQ_Review_Completion_Date__c;
        dpClone.Last_Date_for_Review__c=dpFullyCloned.Last_Date_for_Review__c;
        //Arshi: Restrict submit for review for ACDD refreshed records
        dpClone.Submit_Deal_Protocol_record_for_Review__c=true;
        //Harshit : added to show the same questionnaire as before
        dpClone.isNewDpRecord__c=dpFullyCloned.isNewDpRecord__c;
        //UAT defect - Arshi
        if (!dpClone.Seeking_an_Exception_to_Policy__c){
            if(((dpClone.PartnerAnswerYestoQuestionnaire__c <> null && dpClone.PartnerAnswerYestoQuestionnaire__c.equalsIgnoreCase(NO)) 
            || String.isNotEmpty(dpClone.TLM_Reference__c) || (dpClone.RiskRankingAnswer__c <> null &&  dpClone.RiskRankingAnswer__c.equalsIgnoreCase(NO)))
            ||(dpClone.HasRiskRankingChangedFromLastACDD__c <> null && dpClone.HasRiskRankingChangedFromLastACDD__c == NO)
            || ((dpClone.PartnerAnswerYestoQuestionnaire__c <> null && dpClone.PartnerAnswerYestoQuestionnaire__c.equalsIgnoreCase(YES)) &&
            (dpClone.ICSComplianceDecision__c <> null && (dpClone.ICSComplianceDecision__c.equalsIgnoreCase(APPROVED) || dpClone.ICSComplianceDecision__c.equalsIgnoreCase(REJECTED))) && 
            (dpClone.GlobalComplianceDecision__c <> null && dpClone.GlobalComplianceDecision__c.equalsIgnoreCase('N/A'))) ){
             dpClone.Status_Date__c = system.Today();    
              } } else {
                 if(dpClone.GlobalComplianceDecision__c <> null && (dpClone.GlobalComplianceDecision__c.equalsIgnoreCase(APPROVED)|| dpClone.GlobalComplianceDecision__c.equalsIgnoreCase(REJECTED))){
                      dpClone.Status_Date__c = system.Today();   
                 }}
        //Harshit added below code to copy values from old record to new refreshed record : US2702444
        dpClone.Local_Market_Finance_Approver_Decision__c=dpFullyCloned.Local_Market_Finance_Approver_Decision__c;
        dpClone.Local_Market_GCO_Approver_Decision__c=dpFullyCloned.Local_Market_GCO_Approver_Decision__c;
        dpClone.Market_VP_Director_Approval_Decision__c =dpFullyCloned.Market_VP_Director_Approval_Decision__c;
        dpClone.Deal_Sign_Off_Decision__c=dpFullyCloned.Deal_Sign_Off_Decision__c;
        dpClone.Deal_Sign_Off_Completion_Date__c=dpFullyCloned.Deal_Sign_Off_Completion_Date__c;
        dpClone.Market_VP_Director_Approval_Type__c=dpFullyCloned.Market_VP_Director_Approval_Type__c;
        dpClone.Market_VP_Director_Approval_Due_DateTime__c=dpFullyCloned.Market_VP_Director_Approval_Due_DateTime__c;
        dpClone.Local_Market_Finance_Approval_Type__c =dpFullyCloned.Local_Market_Finance_Approval_Type__c;
        dpClone.Local_Market_Finance_ApprovalDueDateTime__c=dpFullyCloned.Local_Market_Finance_ApprovalDueDateTime__c;
        dpClone.Local_Market_GCO_Approval_Type__c=dpFullyCloned.Local_Market_GCO_Approval_Type__c;
        dpClone.Local_Market_GCO_Approval_DueDateTime__c=dpFullyCloned.Local_Market_GCO_Approval_DueDateTime__c;
        dpClone.Local_Market_GCO_Approver__c=dpFullyCloned.Local_Market_GCO_Approver__c;
        dpClone.Local_Market_Finance_Approver__c=dpFullyCloned.Local_Market_Finance_Approver__c;
        dpClone.Market_VP_Director_Approver__c =dpFullyCloned.Market_VP_Director_Approver__c;
        dpClone.Fulfillment_monitoring__c =dpFullyCloned.Fulfillment_monitoring__c;
        dpClone.Payment_Team__c =dpFullyCloned.Payment_Team__c;
        dpClone.Internal_Reporting_requirements_inc_SLA__c =dpFullyCloned.Internal_Reporting_requirements_inc_SLA__c;
        dpClone.External_Reporting_requirements_inc_SLA__c =dpFullyCloned.External_Reporting_requirements_inc_SLA__c;
        dpClone.have_process_for_managing_Prepaid_invent__c =dpFullyCloned.have_process_for_managing_Prepaid_invent__c;
        dpClone.Will_the_deal_require_100_new_awards__c =dpFullyCloned.Will_the_deal_require_100_new_awards__c;
        dpClone.Payment_Team_Engaged__c =dpFullyCloned.Payment_Team_Engaged__c;
        dpClone.VP_Approval_Submitted_Date__c =dpFullyCloned.VP_Approval_Submitted_Date__c;
        dpClone.LFO_Approval_Submitted_Date__c =dpFullyCloned.LFO_Approval_Submitted_Date__c;
        dpClone.GCO_Approval_Submitted_Date__c =dpFullyCloned.GCO_Approval_Submitted_Date__c;
        //-- Harshit Changes ends --////////////////////////
        dpClone.id = null;
        pagereference pReference = null;
            try
            {   insert dpClone;
                update oldDealProtocol;
            }catch(Exception e)
            {   Database.rollback( sPoint );
                return null;
            }
            pReference = new pagereference('/'+dpClone.Id+'?inline=false');
            pReference.setRedirect(true);
        return pReference;
    }

  /**
   * @function     :   reRenderAction
   * @description  :   for taking action when record value is changing
   * @return       :   void
   */
   public void reRenderAction(){
      System.debug('checkreRenderAction>>');

        if(dp1.Qualify_for_AEMP_10__c <> NO && dp1.TypeofACDD__c!='New ACDD'){
            dp1.Qualify_for_AEMP_10__c.addError('Please select NO');
        }
     
      else if (dp1.HasRiskRankingChangedFromLastACDD__c <> null ){
                                           System.debug('checkseconddropdownelsecondition>>');

           getACDDValues();
       }
       else if (dp1.RiskRankingAnswer__c <> null   ){
         System.debug('checkreRenderAction2>>');

           getDueDiligence();
       }
       
       else{
         //getACDDOldValues(); 
        // getDueDiligence();
         changeSeekingException();
     
        }
       
       
    }

    /**
    * @function     :   getACDDOldValues
    * @description  :   for setting ACDD Fields based on Risk Ranking Factor
    * @return       :   void
    */
    public void getACDDOldValues() {
                                System.debug('getabcdvalue>>');

         //Arshi
         boolean resetForm = true;
        if(dp1.TypeofACDD__c == 'New Market'){
        System.debug('dp1.HasRiskRankingChangedFromLastACDD__c>>'+dp1.HasRiskRankingChangedFromLastACDD__c);

 
            if(dp1.HasRiskRankingChangedFromLastACDD__c<> null && dp1.HasRiskRankingChangedFromLastACDD__c == NO) 
            {
 
            System.debug('checkif>>');

                isMarketFieldEditable = false;
                //dp1.ACDD_Status__c = dpFullyCloned.ACDD_Status__c;
                dp1.RiskRankingAnswer__c = dpFullyCloned.RiskRankingAnswer__c;
                system.debug('dp1.RiskRankingAnswer__c>>>'+dp1.RiskRankingAnswer__c);
                dp1.Partner_Certification_Statement_Complete__c =dpFullyCloned.Partner_Certification_Statement_Complete__c ;
                system.debug('dp1.Partner_Certification_Statement_Complete__c>>>'+dp1.Partner_Certification_Statement_Complete__c);
                dp1.Partner_Certification_Statement_Date__c = dpFullyCloned.Partner_Certification_Statement_Date__c;
                system.debug('dp1.Partner_Certification_Statement_Date__c>>>'+dp1.Partner_Certification_Statement_Date__c);
                dp1.PartnerAnswerYestoQuestionnaire__c = dpFullyCloned.PartnerAnswerYestoQuestionnaire__c;
                system.debug('dp1.PartnerAnswerYestoQuestionnaire__c>>>'+dp1.PartnerAnswerYestoQuestionnaire__c);
                dp1.Seeking_an_Exception_to_Policy__c = dpFullyCloned.Seeking_an_Exception_to_Policy__c;
                system.debug('dp1.Seeking_an_Exception_to_Policy__c>>>'+dp1.Seeking_an_Exception_to_Policy__c);
                dp1.ICSComplianceDecision__c = dpFullyCloned.ICSComplianceDecision__c;
                system.debug('dp1.ICSComplianceDecision__c>>>'+dp1.ICSComplianceDecision__c);
                dp1.ICS_Compliance_Decision_Date__c = dpFullyCloned.ICS_Compliance_Decision_Date__c;
                system.debug('dp1.ICS_Compliance_Decision_Date__c>>>'+dp1.ICS_Compliance_Decision_Date__c);
                dp1.Global_Comp_Exception_Decision_Date__c = dpFullyCloned.Global_Comp_Exception_Decision_Date__c;
                system.debug('dp1.Global_Comp_Exception_Decision_Date__c>>>'+dp1.Global_Comp_Exception_Decision_Date__c);
                dp1.GlobalComplianceDecision__c = dpFullyCloned.GlobalComplianceDecision__c;
                system.debug('dp1.GlobalComplianceDecision__c>>>'+dp1.GlobalComplianceDecision__c);
                dp1.ArcherExceptionId__c = dpFullyCloned.ArcherExceptionId__c;
                system.debug('dp1.ArcherExceptionId__c>>>'+dp1.ArcherExceptionId__c);
                //Arshi
                resetForm= false;
                 dp1.Due_Diligence_Required__c = 'were';
            }
            
           /* else{
                isMarketFieldEditable = true;
                dp1.Partner_Certification_Statement_Complete__c = null;
                dp1.RiskRankingAnswer__c = null;
                dp1.Partner_Certification_Statement_Date__c = null;
                dp1.PartnerAnswerYestoQuestionnaire__c = null;
                dp1.Seeking_an_Exception_to_Policy__c = false;
                dp1.ICSComplianceDecision__c = null;
                dp1.ICS_Compliance_Decision_Date__c = null;
                dp1.Global_Comp_Exception_Decision_Date__c = null;
                dp1.GlobalComplianceDecision__c = null;
                dp1.ArcherExceptionId__c = null;
                //Arshi
                dp1.Due_Diligence_Required__c = 'Partner must complete and sign the ACDD Questionnaire';
            }*/
        }else{
            resetForm= true;
        }
        if(resetForm){
            isMarketFieldEditable = true;
            dp1.Partner_Certification_Statement_Complete__c = null;
            dp1.RiskRankingAnswer__c = null;
            dp1.Partner_Certification_Statement_Date__c = null;
            dp1.PartnerAnswerYestoQuestionnaire__c = null;
            dp1.Seeking_an_Exception_to_Policy__c = false;
            dp1.ICSComplianceDecision__c = null;
            dp1.ICS_Compliance_Decision_Date__c = null;
            dp1.Global_Comp_Exception_Decision_Date__c = null;
            dp1.GlobalComplianceDecision__c = null;
            dp1.ArcherExceptionId__c = null;
            //Arshi
            isShowComplDate =false;
            dp1.Due_Diligence_Required__c = '';
        }
           
    }
    

    /**
    * @function     :   getACDDValues
    * @description  :   for setting ACDD Fields based on Risk Ranking Factor
    * @return       :   void
    * monika add this method to fix the production issue - (case no.-00905597 )
    */
    public void getACDDValues() {
                                System.debug('getabcdvalue>>');
         boolean resetForm = true;
        if(dp1.TypeofACDD__c == 'New Market'){
        System.debug('dp1.HasRiskRankingChangedFromLastACDD__c>>'+dp1.HasRiskRankingChangedFromLastACDD__c);

 
            if(dp1.HasRiskRankingChangedFromLastACDD__c<> null && dp1.HasRiskRankingChangedFromLastACDD__c == NO) 
            {
 
            System.debug('checkif>>');

                isMarketFieldEditable = false;
                dp1.isdisabled__c	= false;
                //dp1.ACDD_Status__c = dpFullyCloned.ACDD_Status__c;
                dp1.RiskRankingAnswer__c = dpFullyCloned.RiskRankingAnswer__c;
                system.debug('dp1.RiskRankingAnswer__c>>>'+dp1.RiskRankingAnswer__c);
                dp1.Partner_Certification_Statement_Complete__c =dpFullyCloned.Partner_Certification_Statement_Complete__c ;
                system.debug('dp1.Partner_Certification_Statement_Complete__c>>>'+dp1.Partner_Certification_Statement_Complete__c);
                dp1.Partner_Certification_Statement_Date__c = dpFullyCloned.Partner_Certification_Statement_Date__c;
                system.debug('dp1.Partner_Certification_Statement_Date__c>>>'+dp1.Partner_Certification_Statement_Date__c);
                dp1.PartnerAnswerYestoQuestionnaire__c = dpFullyCloned.PartnerAnswerYestoQuestionnaire__c;
                system.debug('dp1.PartnerAnswerYestoQuestionnaire__c>>>'+dp1.PartnerAnswerYestoQuestionnaire__c);
                dp1.Seeking_an_Exception_to_Policy__c = dpFullyCloned.Seeking_an_Exception_to_Policy__c;
                system.debug('dp1.Seeking_an_Exception_to_Policy__c>>>'+dp1.Seeking_an_Exception_to_Policy__c);
                dp1.ICSComplianceDecision__c = dpFullyCloned.ICSComplianceDecision__c;
                system.debug('dp1.ICSComplianceDecision__c>>>'+dp1.ICSComplianceDecision__c);
                dp1.ICS_Compliance_Decision_Date__c = dpFullyCloned.ICS_Compliance_Decision_Date__c;
                system.debug('dp1.ICS_Compliance_Decision_Date__c>>>'+dp1.ICS_Compliance_Decision_Date__c);
                dp1.Global_Comp_Exception_Decision_Date__c = dpFullyCloned.Global_Comp_Exception_Decision_Date__c;
                system.debug('dp1.Global_Comp_Exception_Decision_Date__c>>>'+dp1.Global_Comp_Exception_Decision_Date__c);
                dp1.GlobalComplianceDecision__c = dpFullyCloned.GlobalComplianceDecision__c;
                system.debug('dp1.GlobalComplianceDecision__c>>>'+dp1.GlobalComplianceDecision__c);
                dp1.ArcherExceptionId__c = dpFullyCloned.ArcherExceptionId__c;
                system.debug('dp1.ArcherExceptionId__c>>>'+dp1.ArcherExceptionId__c);
                //Arshi
                resetForm= false;
                 dp1.Due_Diligence_Required__c = 'were';
            }
            
           /* else{
                isMarketFieldEditable = true;
                dp1.Partner_Certification_Statement_Complete__c = null;
                dp1.RiskRankingAnswer__c = null;
                dp1.Partner_Certification_Statement_Date__c = null;
                dp1.PartnerAnswerYestoQuestionnaire__c = null;
                dp1.Seeking_an_Exception_to_Policy__c = false;
                dp1.ICSComplianceDecision__c = null;
                dp1.ICS_Compliance_Decision_Date__c = null;
                dp1.Global_Comp_Exception_Decision_Date__c = null;
                dp1.GlobalComplianceDecision__c = null;
                dp1.ArcherExceptionId__c = null;
                //Arshi
                dp1.Due_Diligence_Required__c = 'Partner must complete and sign the ACDD Questionnaire';
            }*/
        }else{
            resetForm= true;
        }
        if(resetForm){
            isMarketFieldEditable = true;
            dp1.Partner_Certification_Statement_Complete__c = null;
            dp1.RiskRankingAnswer__c = null;
            dp1.Partner_Certification_Statement_Date__c = null;
            dp1.PartnerAnswerYestoQuestionnaire__c = null;
            dp1.Seeking_an_Exception_to_Policy__c = false;
            dp1.ICSComplianceDecision__c = null;
            dp1.ICS_Compliance_Decision_Date__c = null;
            dp1.Global_Comp_Exception_Decision_Date__c = null;
            dp1.GlobalComplianceDecision__c = null;
            dp1.ArcherExceptionId__c = null;
            //Arshi
            isShowComplDate =false;
            dp1.Due_Diligence_Required__c = '';
        }
           
    }
    /**
    * @function     :   getDueDiligence
    * @description  :   for setting Due Diligence data
    * @return       :   void
    */
    private void getDueDiligence() {
        if(dp1.Qualify_for_AEMP_10__c <> null) {
                        System.debug('dp1.HasRiskRankingChangedFromLastACDD__c>>'+dp1.HasRiskRankingChangedFromLastACDD__c);
System.debug('dp1.TypeofACDD__c>>'+dp1.TypeofACDD__c);
            if (dp1.RiskRankingAnswer__c <> null && dp1.RiskRankingAnswer__c.equalsIgnoreCase(YES) &&
                    dp1.Qualify_for_AEMP_10__c.equalsIgnoreCase(NO)) {
                dp1.Due_Diligence_Required__c = 'Partner must complete and sign the ACDD Questionnaire';
            }else if(dp1.RiskRankingAnswer__c <> null && dp1.RiskRankingAnswer__c.equalsIgnoreCase(NO) &&
                    dp1.Qualify_for_AEMP_10__c.equalsIgnoreCase(NO)) {
                dp1.Due_Diligence_Required__c = 'No further action required for Anti-Corruption Due Diligence';
            }else {
                dp1.Due_Diligence_Required__c = '';
            }
        }else {
            dp1.Due_Diligence_Required__c = '';
        }
    }
    /**
    * @function     :   changeSeekingException
    * @description  :   Dynamically change the field values on certain field value change
    * @return       :   void
    */
    private void changeSeekingException(){
    //Arshi
     isShowComplDate =false;
        if(dp1.Partner_Certification_Statement_Complete__c <> null && dp1.Seeking_an_Exception_to_Policy__c &&
                !dp1.Partner_Certification_Statement_Complete__c.equalsIgnoreCase(NO)){
            dp1.Seeking_an_Exception_to_Policy__c = false;
        }
        if(dp1.RiskRankingAnswer__c <> null && !dp1.RiskRankingAnswer__c.equalsIgnoreCase(YES)){
            dp1.Partner_Certification_Statement_Complete__c ='';
            dp1.Seeking_an_Exception_to_Policy__c = false;
        }
        if(dp1.Qualify_for_AEMP_10__c <> null && dp1.Qualify_for_AEMP_10__c.equalsIgnoreCase(NO)){
            dp1.TLM_Reference__c = null;
        }
        if(dp1.PartnerAnswerYestoQuestionnaire__c <> null && dp1.PartnerAnswerYestoQuestionnaire__c.equalsIgnoreCase(NO) ||
                (dp1.Partner_Certification_Statement_Complete__c <> null && !dp1.Seeking_an_Exception_to_Policy__c &&
                        dp1.Partner_Certification_Statement_Complete__c.equalsIgnoreCase(NO))){
            dp1.ICSComplianceDecision__c = '';
        }
        //Arshi
        if(dp1.RiskRankingAnswer__c <> null &&
          !dp1.RiskRankingAnswer__c .equalsIgnoreCase(NO)){
              isShowComplDate = true;
          }
    }
}