• Kunal Bhardwaj 011
  • NEWBIE
  • 10 Points
  • Member since 2023

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 7
    Replies

I am using @isTEst but its asking me to add test methods to it.Here is the test class I am using.

@isTest
public class PromutuelQuarterlyReportsController_Test {

    public List<promutuelData> promutuels {get; set;}
    public Date startDatePromutuel {get; set;}
    public Date endDatePromutuel {get; set;}

    String[] statusList = new String[]{'In Progress', 'Completed'};
    String[] fixedFeesList = new String[]{'Above-ground Swimming Pool Fixed Fee',
                                        'CEP Xpress Investigation Type 1',
                                        'CEP Xpress Investigation Type 2',
                                        'CEP Xpress',
                                        'Failure Analysis Fixed Fees',
                                        'Fixed Fee Investigation',
                                        'Inground Swimming Pool Fixed Fee'};
   }
    public promutuelQuarterlyReportsController_Test(){
        System.debug('@@@promutuelQuarterlyReportsController called...');
        Test.StartTest(); 
        //set parameters - dates
        Date startDatePromutuel = Date.parse(ApexPages.currentPage().getParameters().get('startDatePromutuel'));
        Date endDatePromutuel =  Date.parse(ApexPages.currentPage().getParameters().get('endDatePromutuel'));
        System.debug('@@@startDatePromutuel =' + startDatePromutuel);
        System.debug('@@@endDatePromutuel =' + endDatePromutuel);

        Map<String,promutuelData> mapPromutuels = new Map<String,promutuelData>();
        List<promutuelData> listPromutuels = new List<promutuelData>();
        promutuels = new List<promutuelData>();
        Set<Id> projectBEPReleasedIds = new Set<Id>();
        Map<String,Decimal> mapProjBEPsReleased = new Map<String,Decimal>();
        
        //Retrieve all Projects with BEP Released from Billing Events by Principal
        List<Billing_event_by_principal__c> BEPs = [SELECT Name,
                                            cep_Release_Date__c,
                                            cep_Summary_Amount__c,
                                            cep_principal__r.cep_File_Number_Principal__c,
                                            cep_principal__r.cep_Policy_Number_Principal__c,
                                            cep_principal__r.cep_Principal_Billing_Percentage__c, 
                                            cep_principal__r.cep_Client_Billing_Percentage__c, 
                                            cep_principal__r.cep_Principal_Project__r.cep_Project_Number__c,
                                            cep_principal__r.cep_Principal_Project__r.Name,
                                            cep_principal__r.cep_Principal_Project__c,
                                            cep_principal__r.cep_Principal_Project__r.pse__Practice__r.cep_Practice_Translation_FR__c
                                            FROM Billing_event_by_principal__c
                                            WHERE cep_principal__r.cep_Principal_Project__r.pse__Stage__c IN :statusList AND
                                                  cep_principal__r.cep_Principal_Account__r.Name LIKE '%Promutuel%' AND
                                                  cep_Release_Date__c >= :startDatePromutuel AND cep_Release_Date__c <= :endDatePromutuel
                                            ORDER BY cep_principal__r.cep_Principal_Project__r.cep_Project_Number__c];    
        
        System.debug('@@@ BEPs=' + JSON.serializePretty(BEPs));
        System.debug('@@@ SIZE BEPs=' + BEPs.size());

        if (BEPs.size() > 0){
            for (Billing_event_by_principal__c bep : BEPs){
                projectBEPReleasedIds.add(bep.cep_principal__r.cep_Principal_Project__c);
                mapProjBEPsReleased.put(bep.cep_principal__r.cep_Principal_Project__c, 0);
            }
            
            for (Billing_event_by_principal__c bep : BEPs){
                mapProjBEPsReleased.put(bep.cep_principal__r.cep_Principal_Project__c, mapProjBEPsReleased.get(bep.cep_principal__r.cep_Principal_Project__c) + bep.cep_Summary_Amount__c);
            }
            System.debug('@@@ projectBEPReleasedIds=' + projectBEPReleasedIds);
            System.debug('@@@ mapProjBEPsReleased=' + mapProjBEPsReleased);                   
            
            for (Billing_event_by_principal__c bep : BEPs){
                //add values promutuel to map
                PromutuelData promutuel = new PromutuelData();
                promutuel.projectId = bep.cep_principal__r.cep_Principal_Project__c;
                promutuel.projectNumber = bep.cep_principal__r.cep_Principal_Project__r.cep_Project_Number__c;
                promutuel.fileNumber = bep.cep_principal__r.cep_File_Number_Principal__c;
                promutuel.policeNumber = bep.cep_principal__r.cep_Policy_Number_Principal__c;
                promutuel.practice = bep.cep_principal__r.cep_Principal_Project__r.pse__Practice__r.cep_Practice_Translation_FR__c;
                promutuel.totalFixedFees = 0;
                promutuel.totalTimeBilled=0;
                promutuel.totalDistance = 0;
                promutuel.totalStorage = 0;
                promutuel.clientParticipation = bep.cep_principal__r.cep_Client_Billing_Percentage__c;
                promutuel.principalParticipation = bep.cep_principal__r.cep_Principal_Billing_Percentage__c;
                ///promutuel.totalInvoiceNet = mapProjBEPsReleased.get(bep.cep_principal__r.cep_Principal_Project__c) * 
                promutuel.totalInvoiceNet = bep.cep_Summary_Amount__c * 
                                            bep.cep_principal__r.cep_Client_Billing_Percentage__c/100 * 
                                            bep.cep_principal__r.cep_Principal_Billing_Percentage__c/100;
                mapPromutuels.put(bep.cep_principal__r.cep_Principal_Project__c, promutuel);
                listPromutuels.add(promutuel);
          Test.StopTest();
            }
        }
        System.debug('@@@mapPromutuels=' + mapPromutuels);

        
        //Add Total time (hours) from Timecards to map
        AggregateResult[] timeResults = [SELECT pse__Project__c, Sum(pse__Total_Billable_Amount__c) totalTime
                                                FROM pse__Timecard_Header__c 
                                                WHERE pse__Total_Billable_Amount__c > 0 AND 
                                                    pse__Project__c IN :projectBEPReleasedIds AND 
                                                    cep_Billing_Event__c != null AND 
                                                    cep_Billing_Event__r.cep_Release_Date__c >= :startDatePromutuel AND 
                                                    cep_Billing_Event__r.cep_Release_Date__c <= :endDatePromutuel
                                                GROUP BY pse__Project__c];

        for (AggregateResult ar : timeResults){
            String projId = String.valueOf(ar.get('pse__Project__c'));
            Double total = Double.valueOf(ar.get('totalTime'));
            PromutuelData promutuel = mapPromutuels.get(projId);
            total = total * promutuel.clientParticipation/100 * promutuel.principalParticipation/100;
            promutuel.totalTimeBilled = total;
            mapPromutuels.put(projId, promutuel);
        }
        System.debug('***mapPromutuels=' + mapPromutuels);


        //Add Total Distance from expenses to map
        AggregateResult[] distanceResults = [SELECT pse__Project__c, Sum(pse__Distance__c) totalDistance 
                                                FROM pse__Expense__c 
                                                WHERE pse__Distance__c > 0 AND 
                                                    pse__Project__c IN :projectBEPReleasedIds AND
                                                    pse__Billing_Event__c != null AND 
                                                    pse__Billing_Event_Item__r.pse__Billing_Event__r.cep_Release_Date__c >= :startDatePromutuel AND 
                                                    pse__Billing_Event_Item__r.pse__Billing_Event__r.cep_Release_Date__c <= :endDatePromutuel
                                                GROUP BY pse__Project__c];

        for (AggregateResult ar : distanceResults){
            String projId = String.valueOf(ar.get('pse__Project__c'));
            Double total = Double.valueOf(ar.get('totalDistance'));
            PromutuelData promutuel = mapPromutuels.get(projId);
            total = total * promutuel.clientParticipation/100 * promutuel.principalParticipation/100;
            promutuel.totalDistance = total;
            mapPromutuels.put(projId, promutuel);
        }
        System.debug('***mapPromutuels=' + mapPromutuels);


        //Add Total Storage from Misc. Adjust. to map
        AggregateResult[] storageResults = [SELECT pse__Project__c, Sum(pse__Amount__c) totalStorage
                                            FROM pse__Miscellaneous_Adjustment__c 
                                            WHERE (cep_Miscellaneous_Adjustments_Type__r.Name = 'Entreposage/Storage' OR cep_Miscellaneous_Adjustments_Type__r.Name = 'Storage') AND
                                                  pse__Project__c IN :projectBEPReleasedIds AND
                                                  pse__Bill_Date__c >= :startDatePromutuel AND 
                                                  pse__Bill_Date__c <= :endDatePromutuel
                                            GROUP BY pse__Project__c];
    
        for (AggregateResult ar : storageResults){
            String projId = String.valueOf(ar.get('pse__Project__c'));
            Double total = Double.valueOf(ar.get('totalStorage'));
            PromutuelData promutuel = mapPromutuels.get(projId);
            total = total * promutuel.clientParticipation/100 * promutuel.principalParticipation/100;
            promutuel.totalStorage = total;
            mapPromutuels.put(projId, promutuel);
        }
        System.debug('***mapPromutuels=' + mapPromutuels);


        //Add Total Fixed Fees from Misc. Adjust. to map
        AggregateResult[] fixedFeesResults = [SELECT pse__Project__c, Sum(pse__Amount__c) totalFixedFees
                                            FROM pse__Miscellaneous_Adjustment__c 
                                            WHERE cep_Miscellaneous_Adjustments_Type__r.Name IN :fixedFeesList AND 
                                                  pse__Project__c IN :projectBEPReleasedIds AND
                                                  pse__Bill_Date__c >= :startDatePromutuel AND 
                                                  pse__Bill_Date__c <= :endDatePromutuel
                                            GROUP BY pse__Project__c];
    
        for (AggregateResult ar : fixedFeesResults){
            String projId = String.valueOf(ar.get('pse__Project__c'));
            Double total = Double.valueOf(ar.get('totalFixedFees'));
            PromutuelData promutuel = mapPromutuels.get(projId);
            total = total * promutuel.clientParticipation/100 * promutuel.principalParticipation/100;
            promutuel.totalFixedFees = total;
            mapPromutuels.put(projId, promutuel);
        }
        System.debug('***mapPromutuels=' + mapPromutuels);

        //Multiple lines Promutuel in the Project
        for (PromutuelData pd : listpromutuels){
            PromutuelData promutuel = pd;
            promutuel.totalTimeBilled = mapPromutuels.get(pd.projectId).totalTimeBilled;
            promutuel.totalDistance = mapPromutuels.get(pd.projectId).totalDistance;
            promutuel.totalStorage = mapPromutuels.get(pd.projectId).totalStorage;
            promutuel.totalFixedFees = mapPromutuels.get(pd.projectId).totalFixedFees;
            promutuels.add(promutuel);
        }

        ///promutuels = mapPromutuels.values();
        
    }

    // Promutuel data
    class PromutuelData {
    
        public String projectNumber {get; set;}
        public String fileNumber {get; set;}
        public String policeNumber {get; set;}
        public String practice {get; set;} 
        public Double totalFixedFees {get; set;} 
        public Double totalTimeBilled {get; set;}
        public Double totalDistance {get; set;}
        public Double totalStorage {get; set;}
        public Double clientParticipation {get; set;}
        public Double principalParticipation {get; set;}
        public Double totalInvoiceNet {get; set;}
        public Id projectId {get; set;}
        Test.StartTest(); 
        PromutuelData(){
            projectNumber = '-';
            fileNumber = '-';
            policeNumber = '-';
            practice = '-';
            totalFixedFees = 0; 
            totalTimeBilled = 0;
            totalDistance = 0;
            totalStorage = 0;
            clientParticipation = 0;
            principalParticipation = 0;
            totalInvoiceNet = 0;
            projectId = null;
       Test.StopTest();
        }
   }
}

I have created custom button using apex MetadataService. but it not showing in lightning, it showing only classic mode, how can it fix it?
  • September 06, 2023
  • Like
  • 0
I am new to LWC and trying to fetch the records in the Lightning Datatable, which is working fine. After that i am trying to insert a record into the same using the record edit form and using refreshApex to display the inserted record immediately.
Can someone help me with the same?
PFA the code snippet for the same
@wire (getAccData,{recordId: '$recordId'})
    getAccTable({data, error}){
        if(data){   
            this.tableData = data;
        }
        else{
            console.log(error);
        }
    }

Here, i am storing the data returned from apex in tableData and then calling the same table data in refreshApex. But it's not working.

handleSave(){
        insertAcc({name : this.name})
        .then((result) => {
          this.result = result;
          return refreshApex(this.tableData);
        })
        .catch((error) => {
          this.error = error;
        });
    }
I am using a soql query in my apex code.
User-added image
i was excepting that i will give me account name but it is giving me account id .

I created a SOAP Web Service in Salesforce that has multiple callback methods. Each of these methods is prefixed with the keyword "webservice", and they are intended to be accessed by external clients. However, I am currently working on implementing an authentication process to ensure that only authorized clients can access these methods.

Example code:

global with sharing class QBWebServicesV1 {

    // clientVersion Callback
    webservice static String clientVersion(String strVersion) {
        // Return your supported QBWC version
        return '';
    }

}

NOTE: Especially to Integrate QuickBook Desktop via Web Connector.

 

Any assistance, including code examples or references to Salesforce documentation, would be greatly appreciated.
Thank you for your support!

Hi All ,
 

Actually I am creating a flow to Update the related Incident when an Survey is created . So if Survey is created then Survey recived checkbox will be checked in ralted Incident .

But when ever I am opening my flow again it is asking to enter a valid values in Survey received checkbox as shown in screenshot below .

Even I changes it many time and flow works fine as expected but when I reopen the flow this error is shownUser-added image
 Thansks in Advance 
 

Hi Guys,

Can i do a subquery on lookup relation.

actually i have to find those account which has active subscriptions.when i am trying to writ the qury like this