• Ammar P 9
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
public class SpecialPricingMassSubmissionForApproval {
    public List<Special_Pricing__c> selLst;
    
    // Constructor
    public SpecialPricingMassSubmissionForApproval(ApexPages.StandardSetController cntlr){
        selLst = cntlr.getSelected();
    }
    
    public pageReference sendForApproval(){
        system.debug('selLst : '+ selLst);
        if(selLst.isEmpty()){
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.Error, 'Please select atleast 1 record for submission!!');
            ApexPages.addMessage(msg);
            return null;
        }
        List<Approval.ProcessSubmitRequest> requests = new List<Approval.ProcessSubmitRequest> ();
        for (Special_Pricing__c spObj: selLst) {
            Approval.ProcessSubmitRequest appReq = new Approval.ProcessSubmitRequest();
            appReq.setComments('Submitting request for approval ');
            appReq.setObjectId(spObj.Id);
            requests.add(appReq);
        }
        
        Approval.ProcessResult[] processResults = null;
        try {
            processResults = Approval.process(requests, true);
            return new ApexPages.Action('{!List}').invoke();
            
        }catch (Exception e) {
            System.debug('Exception Is ' + e.getMessage());
            if(e.getMessage().contains('ALREADY_IN_PROCESS, This record is currently in an approval process')){
                e.setMessage('Approval Process is already in progress!!');
            }
            ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.Error, e.getMessage());
            ApexPages.addMessage(msg);
            //return null;
        }
        return null;
    }
    
    public pageReference back(){
        return new ApexPages.Action('{!List}').invoke();
    }
}
Apex class code:
public with sharing class TrackOrderController {
    public string ordernum {get; set;}
    public date orderDate {get; set;}
    public List<Order> Order {get; set;}
    public List<OrderItem> status {get; set;}
    public List<string> vrs {public get; private set;}
    public List<string> pro {public get; private set;} 
    public List<integer> index {public get; private set;}
    
    public PageReference findOrder()
    {
        try{
      
        Order = [SELECT id FROM Order where PoNumber=:ordernum and PoDate =: orderdate ];
        status = [SELECT Product_name__c,Vehicle_Request_Status1__c FROM OrderItem WHERE OrderId =: Order[0].Id];
        system.debug('size-->'+status.size());
        vrs = new List<String>();
        index = new List<integer>();   
        for(integer i=0; i<status.size(); i++){
            index.add(i);
            if(status[i].Vehicle_Request_Status1__c != null){
            vrs.add(status[i].Vehicle_Request_Status1__c);
            }else{
                vrs.add('Null');
            }
        }
           
        system.debug(status);
        system.debug('vrs list--->'+vrs);
        system.debug('index list--->'+index);
        pro = new List<string>();
        for(integer i=0; i<status.size(); i++){
             pro.add(status[i].Product_name__c);
        }

        system.debug('pro list--->'+pro);
        return null;
        }
        catch(Exception ex){ ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please check purchase number and date')); return null; }
    }
    public PageReference reset() {
        PageReference newpage = new PageReference(System.currentPageReference().getURL());
    newpage.setRedirect(true);
    return newpage;
    }
}


Test class:
@isTest(SeeAllData=true)
public class TrackOrderControllerTest {
    
static testMethod void findOrder(){
  
      Account acc = New Account();
        acc.name = 'test';
        acc.CR_Number__c = '1234567890';
        acc.CustomerName__c = 'test acc';
        acc.CR_Date_English__c = Date.newInstance(2016, 12, 9);
        acc.CR_Capital__c = 12426;
        acc.Current_Revenue__c = 1233;
        acc.Special_Admin_Rate__c = 123456;
        acc.Security_Type__c = 'ghayth';
        acc.ID_Issuer__c = 'asdasd';
        acc.CR_City__c = 'asdasd';
        acc.Workforce__c = 'sdadad';
        acc.In_Business__c = 'sdasdasdas';
        acc.Nationality_of_Business__c = 'India';
        acc.Arabic_Date__c = Date.newInstance(2016, 10, 7);
        acc.Company_Establishment__c = 'sdads';
        acc.Bank2__c = 'sdfdsf';
        acc.City_Region__c = 'sadf';
        insert acc;  
        
        Product2 newProduct = new Product2();
        newProduct.name = 'abc';
        newProduct.Varient__c = 'asd';
        newProduct.Make__c = 'AMI';
        newProduct.Model__c = 'SEMI TRAILER';
        newProduct.ModelYear__c = 2018;
        newProduct.Fuel_Type__c = 'Petrol';
        newProduct.Transmission__c = 'Powershift';
        newProduct.Internal_Purchase_Price__c = 25;
        newProduct.Registration_Fee__c = 25;
        Insert newProduct;
        
         Pricebook2 customPB = new Pricebook2(Name='Custom Pricebook', isActive=true);
        insert customPB;
        
        PricebookEntry customPrice = new PricebookEntry(
            Pricebook2Id = customPB.Id, Product2Id =newProduct.Id,
            UnitPrice = 12000, IsActive = true);
        insert customPrice;
        
    Order ord = new Order ();
    ord.AccountId =acc.Id;
        ord.PoNumber='PO67543';
        ord.PoDate = Date.newInstance(2016, 10, 5);
        ord.Status ='Draft';
        ord.EffectiveDate= system.today();
        ord.Pricebook2Id = customPB.Id;
    insert ord;
    
    OrderItem orditem = new OrderItem();
    orditem.OrderId = ord.Id;
        Orditem.Vehicle_Request_Status1__c ='PO Approved';
        orditem.PricebookEntryId =customPrice.Id;
        orditem.UnitPrice= 678;
        orditem.Quantity= 7;
    insert orditem;
        
      
    /*  list<OrderItem>status=new List<OrderItem>();
        list<integer>index=new List<integer>();
        status = [SELECT Product_name__c,Vehicle_Request_Status1__c FROM OrderItem WHERE OrderId =: ord.Id];
    for(integer i=0; i<status.size(); i++){
            index.add(i);
        } */
         PageReference testPage = Page.TrackOrder;
         Test.setCurrentPage(testPage);
         testPage.getParameters().put('Id', String.valueOf(ord.Id));
    Test.StartTest(); 
      ApexPages.StandardController sc = new ApexPages.StandardController(ord);
            TrackOrderController  testord = new TrackOrderController();
      testord.findOrder();
      testord.reset ();

    Test.StopTest();
        
  }
}
Apex Trigger:
trigger ContactTrigger on Contact (before insert,after insert) {
if(Trigger.isInsert && Trigger.isAfter){
        ContactTriggerHelper.UpdateOpportunity(Trigger.New);
    }
}
Apex Class:
public class Activelineitem {
    @AuraEnabled
    Public static void ActiveProduct(String oppId, String ProductId, Integer leasePeriod, Integer productQuantity, Decimal AdminSlab, OpportunityLineItem oli, List<OpportunityLineItem> oliList){
        List<OpportunityLineItem> updateOpplineItem = new List<OpportunityLineItem>();
        system.debug('leasePeriod from main class--->>'+leasePeriod);
        List<Opportunity> opplst = [Select AccountId from opportunity where id =: oppId];
        List<Special_Pricing__c> spclList = [Select id,name,Valid_thru__c,AccountLookup__c,Opportunity_Product__r.Product2Id,Approval_status__c
                                             From Special_Pricing__c where AccountLookup__c =: opplst[0].AccountId LIMIT 100];
        system.debug('spclList--->>>>'+spclList);
        //Check for valid special pricing record
        List<Special_Pricing__c> specialPricingRec = new List<Special_Pricing__c>();
        for(Special_Pricing__c spcl : spclList){
            if(spcl.Opportunity_Product__r.Product2Id == ProductId && spcl.Approval_status__c=='Approved by CFO'){
               
                if(spcl.Valid_thru__c == null){
                    specialPricingRec.add(spcl);
                    system.debug('Active product-->'+spcl.Name);
                }
            }
        }
        system.debug('specialPricingRec-->'+specialPricingRec);
        List<Special_Pricing_Set__c> spSetList = new List<Special_Pricing_Set__c>();
        if(specialPricingRec.size() > 0){
            spSetList = [Select id, name,Is_Activecorrect__c From Special_Pricing_Set__c Where Special_Pricing__c=:specialPricingRec[0].id AND Is_Activecorrect__c=:True];
        }
         system.debug('spSetList-->'+spSetList);
        if(spSetList.size() > 0){
            String BreakEvenRecordId = fetchSPBreakEvenDetails(ProductId,AdminSlab,leasePeriod,spSetList[0].id);
            system.debug('BreakEvenRecordId--->>'+BreakEvenRecordId);
            if(!String.isEmpty(BreakEvenRecordId)){
                if(leasePeriod == 1){
                    oli.SP_Break_Even_Ist_year__c = BreakEvenRecordId;
                    oli.SP_Break_Even_2nd_year__c = NULL;
                    oli.SP_Break_Even_3rd_year__c = NULL;
                    oli.SP_Break_Even_4th_year__c = NULL;
                    oli.SP_Break_Even_5th_year__c = NULL;
                   
                }
                if(leasePeriod == 2){
                    oli.SP_Break_Even_Ist_year__c = NULL;
                    oli.SP_Break_Even_2nd_year__c = BreakEvenRecordId;
                    oli.SP_Break_Even_3rd_year__c = NULL;
                    oli.SP_Break_Even_4th_year__c = NULL;
                    oli.SP_Break_Even_5th_year__c = NULL;
                   
                }
                if(leasePeriod == 3){
                    oli.SP_Break_Even_Ist_year__c = NULL;
                    oli.SP_Break_Even_2nd_year__c = NULL;
                    oli.SP_Break_Even_3rd_year__c = BreakEvenRecordId;
                    oli.SP_Break_Even_4th_year__c = NULL;
                    oli.SP_Break_Even_5th_year__c = NULL;
                   
                }
                if(leasePeriod == 4){
                    oli.SP_Break_Even_Ist_year__c = NULL;
                    oli.SP_Break_Even_2nd_year__c = NULL;
                    oli.SP_Break_Even_3rd_year__c = NULL;
                    oli.SP_Break_Even_4th_year__c = BreakEvenRecordId;
                    oli.SP_Break_Even_5th_year__c = NULL;
                   
                }
                if(leasePeriod == 5){
                    oli.SP_Break_Even_Ist_year__c = NULL;
                    oli.SP_Break_Even_2nd_year__c = NULL;
                    oli.SP_Break_Even_3rd_year__c = NULL;
                    oli.SP_Break_Even_4th_year__c = NULL;
                    oli.SP_Break_Even_5th_year__c = BreakEvenRecordId;
                   
                }
                oli.Special_Pricing_Applied__c = true;
                updateOpplineItem.add(oli);
                update oli;
                OpportunityLineItemHelper1.insertOpportunityLineItem(updateOpplineItem);
            }
           
        }
       
        //Update Accessories
        Map<String, Special_Pricing_Tier_Set__c> oliSpMap = new Map<String, Special_Pricing_Tier_Set__c>();
        Id recordTypeId = Schema.SObjectType.Special_Pricing_Tier_set__c.getRecordTypeInfosByName().get('Accessories').getRecordTypeId();
        //system.debug('oliList -->>'+oliList);
        if(oliList.size() > 0 && spSetList.size() > 0){
            for(OpportunityLineItem oliItem : oliList){
                Special_Pricing_Tier_Set__c spt = new Special_Pricing_Tier_Set__c();
                spt.RecordTypeId = recordTypeId;
                spt.Product__c = ProductId;
                spt.Special_Pricing_Set__c = spSetList[0].id;
                spt.One_year__c = TRUE;
                spt.Two_year__c = TRUE;
                spt.Three_year__c = TRUE;
                spt.Four_year__c = TRUE;
                spt.Five_year__c = TRUE;
                spt.Accessories_Name__c = oliItem.Accessories__r.Accessories_Name__c;
                spt.Cost_per_month__c = oliItem.Accessories__r.Cost_per_month__c;
                spt.Monthly_Charge__c = oliItem.Accessories__r.Monthly_Charge__c;
                oliSpMap.put(oliItem.Id, spt);
            }
            system.debug('oliSpMap -->>'+oliSpMap);
            try{
                insert oliSpMap.values();
            }
            catch(Exception e){
                system.debug('Exception--->>'+e.getMessage());
            }
            //system.debug('oliSpMap===>>'+oliSpMap);
            Map<String,OpportunityLineItem> oliMap = new Map<String,OpportunityLineItem>();
            for(OpportunityLineItem oliItem : [Select Id, Name,Break_Even_1st_year__c,Break_Even_2nd_year__c,Break_Even_3rd_year__c,
                                               Break_Even_4th_year__c,Break_Even_5th_year__c,Accessories__c,Lease_Period__c
                                               From OpportunityLineItem Where Id IN:oliSpMap.keySet()]){
                                                   oliMap.put(oliItem.Id, oliItem);
                                               }
            List<OpportunityLineItem> updateOli = new List<OpportunityLineItem>();
            for(String oliVal : oliSpMap.keySet()){
                OpportunityLineItem oliUpdate = new OpportunityLineItem();
                oliUpdate = oliMap.get(oliVal);
                oliUpdate.Accessories_Sp__c = oliSpMap.get(oliVal).Id;
               
                // add lease amount
                if(oliUpdate.Lease_Period__c == '1'){                    
                    oliUpdate.SP_Break_Even_Ist_year__c = oliSpMap.get(oliVal).Id;
                    oliUpdate.SP_Break_Even_2nd_year__c = NULL;
                    oliUpdate.SP_Break_Even_3rd_year__c = NULL;
                    oliUpdate.SP_Break_Even_4th_year__c = NULL;
                    oliUpdate.SP_Break_Even_5th_year__c = NULL;                    
                   
                }
                if(oliUpdate.Lease_Period__c == '2'){
                    oliUpdate.SP_Break_Even_Ist_year__c = NULL;
                    oliUpdate.SP_Break_Even_2nd_year__c = NULL;
                    oliUpdate.SP_Break_Even_3rd_year__c = oliSpMap.get(oliVal).Id;
                    oliUpdate.SP_Break_Even_4th_year__c = NULL;
                    oliUpdate.SP_Break_Even_5th_year__c = NULL;
                   
                }
                if(oliUpdate.Lease_Period__c == '3'){
                    oliUpdate.SP_Break_Even_Ist_year__c = NULL;
                    oliUpdate.SP_Break_Even_2nd_year__c = NULL;
                    oliUpdate.SP_Break_Even_3rd_year__c = oliSpMap.get(oliVal).Id;
                    oliUpdate.SP_Break_Even_4th_year__c = NULL;
                    oliUpdate.SP_Break_Even_5th_year__c = NULL;
                   
                }
                if(oliUpdate.Lease_Period__c == '4'){
                    oliUpdate.SP_Break_Even_Ist_year__c = NULL;
                    oliUpdate.SP_Break_Even_2nd_year__c = NULL;
                    oliUpdate.SP_Break_Even_3rd_year__c = NULL;
                    oliUpdate.SP_Break_Even_4th_year__c = oliSpMap.get(oliVal).Id;
                    oliUpdate.SP_Break_Even_5th_year__c = NULL;
                   
                }
                if(oliUpdate.Lease_Period__c == '5'){
                    oliUpdate.SP_Break_Even_Ist_year__c = NULL;
                    oliUpdate.SP_Break_Even_2nd_year__c = NULL;
                    oliUpdate.SP_Break_Even_3rd_year__c = NULL;
                    oliUpdate.SP_Break_Even_4th_year__c = NULL;
                    oliUpdate.SP_Break_Even_5th_year__c = oliSpMap.get(oliVal).Id;
                   
                }
                oliUpdate.Special_Pricing_Applied__c = true;
                updateOli.add(oliUpdate);
            }
            try{
                update updateOli;
            }
            catch(Exception e){
                system.debug('Exception -->>'+e.getMessage());
            }
            OpportunityLineItemHelper1.insertOpportunityLineItem(updateOli);
        }
    }
   
   
    @AuraEnabled
    Public static String fetchSPBreakEvenDetails(String ProductId, Decimal AdminSlab, Integer leasePeriod, String spSetId){
        system.debug('ProductId-->>'+ProductId);
        system.debug('AdminSlab-->>'+AdminSlab);
        system.debug('leasePeriod-->>'+leasePeriod);
        system.debug('spSetId-->>'+spSetId);
        if(leasePeriod == 1){
            List<Special_Pricing_Tier_Set__c> spriceTierSetList = new List<Special_Pricing_Tier_Set__c>();
            spriceTierSetList = [Select Id, Name From Special_Pricing_Tier_Set__c Where Special_Pricing_Set__r.Special_Pricing__r.Opportunity_Product__r.Product2Id =:ProductId AND Special_Pricing_Set__c=:spSetId
                                 AND One_year__c=TRUE AND Two_year__c=FALSE AND Three_year__c=FALSE AND Four_year__c=FALSE
                                 AND Five_year__c=FALSE LIMIT 1];
            if(spriceTierSetList.size() >0 ){
                return spriceTierSetList[0].id;
            }
            else{
                return '';
            }
        }
        else if(leasePeriod == 2){
            List<Special_Pricing_Tier_Set__c> spriceTierSetList = new List<Special_Pricing_Tier_Set__c>();
            spriceTierSetList = [Select Id, Name From Special_Pricing_Tier_Set__c Where Special_Pricing_Set__r.Special_Pricing__r.Opportunity_Product__r.Product2Id =:ProductId AND Special_Pricing_Set__c=:spSetId AND One_year__c=TRUE AND
                                 Two_year__c=TRUE AND Three_year__c=FALSE AND Four_Year__c=FALSE AND Five_year__c=FALSE LIMIT 1];
           
            if(spriceTierSetList.size() >0 ){
                return spriceTierSetList[0].id;
            }
            else{
                return '';
            }
        }
        else if(leasePeriod == 3){
            List<Special_Pricing_Tier_Set__c> spriceTierSetList = new List<Special_Pricing_Tier_Set__c>();
            spriceTierSetList = [Select Id, Name From Special_Pricing_Tier_Set__c Where Special_Pricing_Set__r.Special_Pricing__r.Opportunity_Product__r.Product2Id =:ProductId AND Special_Pricing_Set__c=:spSetId AND One_year__c=TRUE AND
                                 Two_year__c=TRUE AND Three_year__c=TRUE AND Four_Year__c=FALSE AND Five_Year__c=FALSE LIMIT 1];
           
            if(spriceTierSetList.size() >0 ){
                return spriceTierSetList[0].id;
            }
            else{
                return '';
            }
        }
        else if(leasePeriod == 4){
            List<Special_Pricing_Tier_Set__c> spriceTierSetList = new List<Special_Pricing_Tier_Set__c>();
            spriceTierSetList = [Select Id, Name From Special_Pricing_Tier_Set__c Where Special_Pricing_Set__r.Special_Pricing__r.Opportunity_Product__r.Product2Id =:ProductId AND Special_Pricing_Set__c=:spSetId AND One_year__c=TRUE AND
                                 Two_year__c=TRUE AND Three_year__c=TRUE AND Four_Year__c=TRUE AND Five_Year__c=FALSE LIMIT 1];
           
            if(spriceTierSetList.size() >0 ){
                return spriceTierSetList[0].id;
            }
            else{
                return '';
            }
        }
        else if(leasePeriod == 5){
            List<Special_Pricing_Tier_Set__c> spriceTierSetList = new List<Special_Pricing_Tier_Set__c>();
            spriceTierSetList = [Select Id, Name From Special_Pricing_Tier_Set__c Where Special_Pricing_Set__r.Special_Pricing__r.Opportunity_Product__r.Product2Id =:ProductId AND Special_Pricing_Set__c=:spSetId AND One_year__c=TRUE AND
                                 Two_year__c=TRUE AND Three_year__c=TRUE AND Four_Year__c=TRUE AND Five_Year__c=TRUE LIMIT 1];
           
            if(spriceTierSetList.size() >0 ){
                return spriceTierSetList[0].id;
            }
            else{
                return '';
            }
        }
        else{
            return '';
        }
    }
}
Apex class code:
public with sharing class TrackOrderController {
    public string ordernum {get; set;}
    public date orderDate {get; set;}
    public List<Order> Order {get; set;}
    public List<OrderItem> status {get; set;}
    public List<string> vrs {public get; private set;}
    public List<string> pro {public get; private set;} 
    public List<integer> index {public get; private set;}
    
    public PageReference findOrder()
    {
        try{
      
        Order = [SELECT id FROM Order where PoNumber=:ordernum and PoDate =: orderdate ];
        status = [SELECT Product_name__c,Vehicle_Request_Status1__c FROM OrderItem WHERE OrderId =: Order[0].Id];
        system.debug('size-->'+status.size());
        vrs = new List<String>();
        index = new List<integer>();   
        for(integer i=0; i<status.size(); i++){
            index.add(i);
            if(status[i].Vehicle_Request_Status1__c != null){
            vrs.add(status[i].Vehicle_Request_Status1__c);
            }else{
                vrs.add('Null');
            }
        }
           
        system.debug(status);
        system.debug('vrs list--->'+vrs);
        system.debug('index list--->'+index);
        pro = new List<string>();
        for(integer i=0; i<status.size(); i++){
             pro.add(status[i].Product_name__c);
        }

        system.debug('pro list--->'+pro);
        return null;
        }
        catch(Exception ex){ ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Please check purchase number and date')); return null; }
    }
    public PageReference reset() {
        PageReference newpage = new PageReference(System.currentPageReference().getURL());
    newpage.setRedirect(true);
    return newpage;
    }
}


Test class:
@isTest(SeeAllData=true)
public class TrackOrderControllerTest {
    
static testMethod void findOrder(){
  
      Account acc = New Account();
        acc.name = 'test';
        acc.CR_Number__c = '1234567890';
        acc.CustomerName__c = 'test acc';
        acc.CR_Date_English__c = Date.newInstance(2016, 12, 9);
        acc.CR_Capital__c = 12426;
        acc.Current_Revenue__c = 1233;
        acc.Special_Admin_Rate__c = 123456;
        acc.Security_Type__c = 'ghayth';
        acc.ID_Issuer__c = 'asdasd';
        acc.CR_City__c = 'asdasd';
        acc.Workforce__c = 'sdadad';
        acc.In_Business__c = 'sdasdasdas';
        acc.Nationality_of_Business__c = 'India';
        acc.Arabic_Date__c = Date.newInstance(2016, 10, 7);
        acc.Company_Establishment__c = 'sdads';
        acc.Bank2__c = 'sdfdsf';
        acc.City_Region__c = 'sadf';
        insert acc;  
        
        Product2 newProduct = new Product2();
        newProduct.name = 'abc';
        newProduct.Varient__c = 'asd';
        newProduct.Make__c = 'AMI';
        newProduct.Model__c = 'SEMI TRAILER';
        newProduct.ModelYear__c = 2018;
        newProduct.Fuel_Type__c = 'Petrol';
        newProduct.Transmission__c = 'Powershift';
        newProduct.Internal_Purchase_Price__c = 25;
        newProduct.Registration_Fee__c = 25;
        Insert newProduct;
        
         Pricebook2 customPB = new Pricebook2(Name='Custom Pricebook', isActive=true);
        insert customPB;
        
        PricebookEntry customPrice = new PricebookEntry(
            Pricebook2Id = customPB.Id, Product2Id =newProduct.Id,
            UnitPrice = 12000, IsActive = true);
        insert customPrice;
        
    Order ord = new Order ();
    ord.AccountId =acc.Id;
        ord.PoNumber='PO67543';
        ord.PoDate = Date.newInstance(2016, 10, 5);
        ord.Status ='Draft';
        ord.EffectiveDate= system.today();
        ord.Pricebook2Id = customPB.Id;
    insert ord;
    
    OrderItem orditem = new OrderItem();
    orditem.OrderId = ord.Id;
        Orditem.Vehicle_Request_Status1__c ='PO Approved';
        orditem.PricebookEntryId =customPrice.Id;
        orditem.UnitPrice= 678;
        orditem.Quantity= 7;
    insert orditem;
        
      
    /*  list<OrderItem>status=new List<OrderItem>();
        list<integer>index=new List<integer>();
        status = [SELECT Product_name__c,Vehicle_Request_Status1__c FROM OrderItem WHERE OrderId =: ord.Id];
    for(integer i=0; i<status.size(); i++){
            index.add(i);
        } */
         PageReference testPage = Page.TrackOrder;
         Test.setCurrentPage(testPage);
         testPage.getParameters().put('Id', String.valueOf(ord.Id));
    Test.StartTest(); 
      ApexPages.StandardController sc = new ApexPages.StandardController(ord);
            TrackOrderController  testord = new TrackOrderController();
      testord.findOrder();
      testord.reset ();

    Test.StopTest();
        
  }
}
Apex Trigger:
trigger ContactTrigger on Contact (before insert,after insert) {
if(Trigger.isInsert && Trigger.isAfter){
        ContactTriggerHelper.UpdateOpportunity(Trigger.New);
    }
}