• Jasril Dane Caliwag
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 4
    Replies
here is the after insert code in my account trigger handler:
 
public override  void afterInsert(){
        String childTransferUser = JSON.serialize(trigger.New);
        if(!Test.isRunningTest()){
            childAccount(childTransferUser);
        }
        createAccShare(Trigger.New);
   
        //Check if owner is WOWLink Site Guest User
        //if yes change the owner to SELECT Id from User WHERE Profile = 'API Only' AND Role != null
    }

please help me out
here is my code:
 
global static String setExperienceId(String expId) {    
        // Return null if there is no error, else it will return the error message 
        try {
            if (expId != null) {
                Site.setExperienceId(expId);               
            }
            return null; 
        } catch (Exception ex) {
            return ex.getMessage();            
        }        
    }

 
here is my class: 
public class VendorCreationController implements Database.AllowsCallouts, Queueable{
    public String retURL {get; set;}
    public Boolean canProceed {get; set;}
    public String errorMessage {get; set;}
    public Case caseInfo {get; set;}
    public String recordStatus {get; set;}
    
    private String accString;
    private String caseString;

    public VendorCreationController(ApexPages.StandardController controller){
        caseInfo = (Case)controller.getRecord();
    }  

    public PageReference changeStatus() {
        //Check and get case information
        try{
            caseInfo = [SELECT Id, Status, Sub_Status__c, Supplier_Product_Article__c, SAP_Sync_Status__c FROM Case WHERE Id =: caseInfo.Id];
        }catch(Exception e){
            caseInfo = null;
        }
        //check if caseInfo is not null
        if(caseInfo != null){
            try{
                //Case Status
                recordStatus = caseInfo.Status;
                
                //Validate case status/case SAP status
                if (caseInfo.SAP_Sync_Status__c == Label.Sync_in_Progress) {                        
                    canProceed = false;
                    errorMessage = Label.Case_is_already_Sync_in_Progress;
                } 
                else if (caseInfo.Status == Label.In_Review) {                        
                    canProceed = false;
                    errorMessage = Label.Case_is_In_Review;
                } 
                else if (caseInfo.SAP_Sync_Status__c == Label.Sync_Complete) {                        
                    canProceed = false;
                    errorMessage = Label.Case_is_already_Sync_Completed;
                }     
                else {       
                    canProceed = true;
                    caseInfo.SAP_Sync_Status__c = Label.Sync_in_Progress;
                    caseInfo.Status = Label.Sync_with_SAP;
                    update caseInfo;                    
                }   
                
                retURL = '/' + caseInfo.Id;
                PageReference redirectPage = new PageReference(retURL);
                redirectPage.setRedirect(true);
                return redirectPage;
            }catch(Exception e){
                canProceed = false;
                errorMessage = e.getMessage();
                retURL = '/' + caseInfo.Id;
                PageReference redirectPage = new PageReference(retURL);
                redirectPage.setRedirect(true);
                return redirectPage;
            }
            
        }
        return null;
    }
    

    //constructor
    public VendorCreationController(String accStr, String caseStr) {
        this.caseString = caseStr;
        this.accString = accStr;
    }
    

    public void execute(QueueableContext context) {
        Account acc = new Account();
        Case caseRec = new Case();
        Case newCaseRec = new Case();
        Contact conRec = new Contact();
        
        //Custom settings for integration
        Integration_Management__c integrationManagement;
        
        //Check if endpoint url is present
        try{
            integrationManagement = Integration_Management__c.getValues(Label.Vendor_Creation);        
        }catch(Exception e){
            integrationManagement = null;
            //log exception to application log utility
            ApplicationLogUtility.logError('VendorCreationController', 'sendToSAP', e, e.getMessage(), '', 0);
            ApplicationLogUtility.commitLog();
        }
        //Check if endpoint is present in the custom settings
        if(integrationManagement !=null){
            try{
                acc = (Account) JSON.deserialize(accString, Account.Class);
                caseRec = (Case) JSON.deserialize(caseString, Case.Class);
            }catch(Exception e){
                acc = null;
                caseRec = null;
            }
            if(acc != null && caseRec !=null){
                try{
                    newCaseRec = [SELECT Id, ContactId, Status, SAP_Sync_Status__c FROM Case WHERE Id=: caseRec.Id];    
                }catch(Exception e){
                    newCaseRec = null;
                }
                
                if(newCaseRec !=null){
                    try{
                        conRec = [SELECT Id, Phone, HomePhone, OtherPhone, Fax, Email FROM Contact WHERE Id=: newCaseRec.ContactId];            
                    }catch(Exception e){
                        conRec = null;
                    }
                }
                
                try{
                    system.debug('VendorCreationController caseRec: ' + caseRec);            
                    system.debug('VendorCreationController conRec: ' + conRec);
                    system.debug('VendorCreationController sendToSAP enter');
                    sapComDocumentSapRfcFunctionsVendor.Z_VEN_CREATION_BINDING bob = new sapComDocumentSapRfcFunctionsVendor.Z_VEN_CREATION_BINDING();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_LFA1 IS_LFA1_FIELDS = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_LFA1();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_LFB1 IS_LFB1_FIELDS = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_LFB1();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_LFM1 IS_LFM1_FIELDS = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_LFM1();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_POSTAL_ADD ADDRESS_FLDS = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_POSTAL_ADD();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_COMM COMM_FIELDS = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_COMM();
                    
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_PHONE_TT phone = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_PHONE_TT();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_FAX_TT fax = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_FAX_TT();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_EMAIL_TT email = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_EMAIL_TT();
                    
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_PHONE contactPhone = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_PHONE();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_FAX contactFax = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_FAX();
                    sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_EMAIL contactEmail = new sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_EMAIL();
                    
                    if(conRec !=null){
                        contactPhone.TELEPHONE =checkIfNull(conRec.Phone, 30);
                        contactPhone.COUNTRY = '';
                        contactPhone.EXTENSION = '';
                        if(contactPhone.TELEPHONE!=''){
                            contactPhone.STD_NO = 'X';
                        }
                        
                        contactFax.COUNTRY = '';
                        contactFax.FAX =checkIfNull(conRec.Fax, 30);
                        if(contactFax.FAX!=''){
                            contactFax.STD_NO = 'X';
                        }
                        
                        contactEmail.E_MAIL =checkIfNull(conRec.Email, 241);
                        if(contactEmail.E_MAIL!=''){
                            contactEmail.STD_NO = 'X';
                        }
                        
                        List<sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_PHONE> phoneList = new List<sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_PHONE>(); 
                        phoneList.add(contactPhone);
                        phone.item = phoneList;
                        
                        List<sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_EMAIL> emailList = new List<sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_EMAIL>(); 
                        emailList.add(contactEmail);
                        email.item = emailList;
                        
                        List<sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_FAX> faxList = new List<sapComDocumentSapRfcFunctionsVendor.ZMAS_VEN_CR_FAX>(); 
                        faxList.add(contactFax);
                        fax.item = faxList;
                        
                        COMM_FIELDS.PHONE = phone;
                        COMM_FIELDS.FAX = fax;
                        COMM_FIELDS.EMAIL = email;
                        system.debug('VendorCreationController sendToSAP COMM_FIELDS: ' + COMM_FIELDS);
                        
                    }
                    
                    IS_LFA1_FIELDS.STCEG=checkIfNull(acc.ABN__c, 20);
                    
                    IS_LFA1_FIELDS.BEGRU=Label.SMKT; //Need confirmation (defaulted)
                    IS_LFA1_FIELDS.KTOKK=Label.SMKT; //Account Group needs to be added (Questionnaire)   
                    
                    IS_LFA1_FIELDS.STCEG= checkIfNull(acc.ABN__c, 20);
                    IS_LFA1_FIELDS.COMM_FIELDS = COMM_FIELDS;
                    ADDRESS_FLDS.NAME= checkIfNull(acc.TradingName__c, 40);
                    ADDRESS_FLDS.CITY=checkIfNull(acc.BillingCity, 40);
                    ADDRESS_FLDS.POSTL_COD1=checkIfNull(acc.BillingPostalCode, 10);
                    ADDRESS_FLDS.STREET=checkIfNull(acc.BillingStreet, 60);
                    //ADDRESS_FLDS.STR_SUPPL1='STREET2'; //Mat to Comeback
                    ADDRESS_FLDS.COUNTRY=checkIfNull(acc.Country__c, 3);
                    ADDRESS_FLDS.LANGU=Label.English; //Constant
                    ADDRESS_FLDS.REGION=checkIfNull(acc.BillingState, 3);
                    ADDRESS_FLDS.SORT1=Label.Tilde_Sign; //Tilde Sign
                    String referenceVendor = '';
                    if(acc.Trading_Term__c != null){
                        system.debug('Trading Term Not Null');	                   
                        Trading_Terms__c tradingTerm = [SELECT Id, Reference_Vendor__c, PaymentMethod__c, PaymentTermsCode__c FROM Trading_Terms__c WHERE Id=: acc.Trading_Term__c];
                        referenceVendor = tradingTerm.Reference_Vendor__c;
                        IS_LFB1_FIELDS.UZAWE = tradingTerm.PaymentMethod__c;
                        IS_LFB1_FIELDS.ZTERM = tradingTerm.PaymentTermsCode__c;
                        referenceVendor = tradingTerm.Reference_Vendor__c;
                        system.debug('Vendor referenceVendor ' + referenceVendor);
                    }
                    
                    ADDRESS_FLDS.SORT2='';
                    IS_LFA1_FIELDS.ADDRESS_FIELDS=ADDRESS_FLDS;
                    
                    //Australia
                    if(acc.Country__c == Label.AU){
                        IS_LFB1_FIELDS.BUKRS=Label.AU_Company_Code;
                    }
                    //New Zealand
                    else if(acc.Country__c == Label.NZ){
                        IS_LFB1_FIELDS.BUKRS= Label.NZ_Company_Code; 
                    }
                    
                    IS_LFM1_FIELDS.EKORG=Label.X1000; 
                    bob.timeout_x = Integer.valueOf(Label.Timeout);
                    String IV_USER_ID = '';
                    try{
                        User curUser = [SELECT Id, ActiveDirectoryId__c FROM User WHERE Id =: UserInfo.getUserId() LIMIT 1];
                        IV_USER_ID = curUser.ActiveDirectoryId__c;                
                    }catch(Exception e){
                        IV_USER_ID = '';
                    }
                    system.debug('VendorCreationController sendToSAP IV_USER_ID: ' + IV_USER_ID);
                    
                    sapComDocumentSapRfcFunctionsVendor.BAPIRET2_T response = new sapComDocumentSapRfcFunctionsVendor.BAPIRET2_T();
                    response = bob.Z_VEN_CREATION(IS_LFA1_FIELDS, IS_LFB1_FIELDS,IS_LFM1_FIELDS,Label.Default_Logic_Key,referenceVendor,IV_USER_ID);
                    //String IV_REF_VENDOR
                    
                    parseResponse(response, acc, caseRec);
                }catch(Exception e){
                    Web_Service_Log__c logs = new Web_Service_Log__c();
                    //Custom Settings
                    logs.Endpoint__c =  integrationManagement.SAP_Endpoint__c;
                    logs.Error_Message__c= Label.ERROR;
                    logs.Error_Message__c += e;
                    logs.Log_Type__c= Label.Case_Vendor_Create_Error;
                    logs.Service_Name__c = Label.Vendor_Webservice_Error;
                    logs.Status_Code__c = CaseRec.id;
                    insert logs;
                    
                    caseRec.Integration_Error_Message__c = e.getMessage();
                    caseRec.SAP_Sync_Status__c = Label.Sync_Error;
                    caseRec.Status = Label.Approved;
                    update caseRec;
                }
            }
        }        
    }
    

    public static String checkIfNull(String str, Integer maxSize){
        if(str == null){
            str = '';
        }
        else{
            if(str.length() > maxSize ){
                str = str.substring(0, maxSize);
            }
        }
        return str;
    }

    public static void parseResponse(sapComDocumentSapRfcFunctionsVendor.BAPIRET2_T response, Account acc, Case caseRec){
        //Get Integration Management Custom Settings
        Integration_Management__c integrationManagement;        
        try{
            //Get Endpoint URL
            integrationManagement = Integration_Management__c.getValues(Label.Vendor_Creation);        
        }catch(Exception e){
            //log exception to application log utility
            ApplicationLogUtility.logError('VendorCreationController', 'parseResponse', e, e.getMessage(), '', 0);
            ApplicationLogUtility.commitLog();
            integrationManagement = null;
        }
        
        //Check if custom settings not null
        if(integrationManagement !=null){
            if(response !=null){
                if(response.item !=null){
                    system.debug('VendorCreationController parseResponse response: ' + response);
                    system.debug('VendorCreationController parseResponse response: ' + response.item);
                    String message = '';
                    Boolean hasError = false;
                    for (sapComDocumentSapRfcFunctionsVendor.BAPIRET2 item : response.item){
                        system.debug('VendorCreationController parseResponse item: ' + item);
                        system.debug('VendorCreationController parseResponse MESSAGE: ' + item.MESSAGE);
                        system.debug('VendorCreationController parseResponse TYPE_X: ' + item.TYPE_x);
                        if(item.TYPE_x == 'E'){
                            hasError = true;
                        }
                        
                        if(item.MESSAGE!=null){
                            message = item.MESSAGE;                    
                        }
                    }
                    
                    if(!hasError){
                        String vendorNumber = message.replace('Vendor Number created ', '');
                        vendorNumber = vendorNumber.replace('.','');
                        //Update Legacy Vendor Number
                        //Update to Sync Completed
                        //Update Account Vendor Number
                        system.debug('VendorCreationController parseResponse vendorNumber: ' + vendorNumber);
                        acc.VendorNumber__c = vendorNumber;
                        update acc;
                        
                        //Case Record Update
                        caseRec.Integration_Error_Message__c = Label.Vendor_Successful;
                        caseRec.SAP_Sync_Status__c = Label.Sync_Complete;
                        caseRec.Status = 'Sync With SAP Completed';
                        update caseRec;
                        //Lock case
                        Approval.UnlockResult unlockCase = Approval.unlock(caseRec, false);
                        if (unlockCase.isSuccess()) {
                            //Operation was successful, so get the ID of the record that was processed
                            System.debug('Successfully unlocked case with ID: ' + unlockCase.getId());
                        }
                        else {
                            //Operation failed, so get all errors                
                            for(Database.Error err : unlockCase.getErrors()) {
                                System.debug('The following error has occurred.');                    
                                System.debug(err.getStatusCode() + ': ' + err.getMessage());
                                System.debug('Case fields that affected this error: ' + err.getFields());
                            }
                        }
                        
                        //Update Web Service Logs
                        Web_Service_Log__c logs = new Web_Service_Log__c();
                        //Custom Settings
                        logs.Endpoint__c =  integrationManagement.SAP_Endpoint__c;
                        logs.Error_Message__c = message;
                        logs.Log_Type__c= Label.Case_Vendor_Create_Successful;
                        logs.Service_Name__c = Label.Vendor_Webservice_Success;
                        logs.Status_Code__c = CaseRec.id;
                        insert logs;
                        
                        system.debug('VendorCreationController parseResponse Account Vendor Number Updated');
                    }
                    else{
                        //Update Web Service Logs
                        Web_Service_Log__c logs = new Web_Service_Log__c();
                        //Custom Settings
                        logs.Endpoint__c =  integrationManagement.SAP_Endpoint__c;
                        logs.Error_Message__c= Label.ERROR;
                        logs.Error_Message__c += message;
                        logs.Log_Type__c= Label.Case_Vendor_Create_Error;
                        logs.Service_Name__c = Label.Vendor_Webservice_Error;
                        logs.Status_Code__c = CaseRec.id;
                        insert logs;
                        
                        //Update case
                        caseRec.Integration_Error_Message__c = message;
                        caseRec.SAP_Sync_Status__c = Label.Sync_Error;
                        caseRec.Status = Label.Approved;
                        update caseRec;
                    }
                }
                else{
                    //No Response
                    caseRec.Integration_Error_Message__c = Label.No_Response_Received_From_The_Webservice;
                    caseRec.SAP_Sync_Status__c = Label.Sync_Error;
                    caseRec.Status = Label.Approved;
                    update caseRec;
                }
            }
            else{
                //No Response
                caseRec.Integration_Error_Message__c = Label.No_Response_Received_From_The_Webservice;
                caseRec.SAP_Sync_Status__c = Label.Sync_Error;
                caseRec.Status = Label.Approved;
                update caseRec;
            }
        }
    }
}

please help me out thank you :) 
here is my code:
public class AddPriceModalController {
    @AuraEnabled
    public static List<String> getRegionValues() {
        List<String> lstGeography = new List<String>(); //new list for holding all of the picklist options
        
        Schema.DescribeFieldResult fieldResult = PriceDetail__c.Geography__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple)
        {
            lstGeography.add(f.getValue());
        }
        
        return lstGeography;
    }
    
    @AuraEnabled
    public static List<String> getDeliveryMethodValues() {
        List<String> lstSourceOfSupply = new List<String>(); //new list for holding all of the picklist options
        
        Schema.DescribeFieldResult fieldResult = PriceDetail__c.Source_of_Supply__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple)
        {
            lstSourceOfSupply.add(f.getLabel() + '---' + f.getValue());            
        }
        
        return lstSourceOfSupply;
    }
    //Method to Save the Price Detail Change Request
    @AuraEnabled
    public static String savePriceDetails(Id PDID,PriceDetail__c newPriceDetails) {
        system.debug('savePriceDetails');
        system.debug('newPriceDetails'+newPriceDetails);
        Decimal invoiceCost = 0;
        Decimal netCost = 0;
        Decimal netProfit = 0;
        Decimal retailPrice = 0;
        string resultId;
        //Webservice Call to SAP to get the InvoiceCost and NetCost
        /*invoiceCost = PriceDetailsWebService.getInvoiceCost(PDID);
netCost = PriceDetailsWebService.getNetCost(PDID);*/
        
        String PDSOQL = SObjectUtil.getSOQLStringFullFields(PriceDetail__c.getSObjectType())
            +' WHERE ' + ' Id = :PDID LIMIT 1';
        //List<PriceDetail__c> listPD = Database.query(PDSOQL);
        PriceDetail__c PDRec;
        try{
            PDRec = Database.query(PDSOQL);   
        }catch(Exception e){
            ApplicationLogUtility.logError('SubmitActionController', 'getParentId', e, e.getMessage(), '', 0);
            ApplicationLogUtility.commitLog();
            PDRec = null; 
        }   
        if(PDRec!=null){
            PriceDetail__c clonedPD = PDRec.clone(false, true, false, false);
            clonedPD.InvoiceCost__c = invoiceCost;
            clonedPD.NetCost__c = netCost;
            clonedPD.ClonedFrom__c = PDRec.Id;
            clonedPD.Status__c = Label.Draft;
            clonedPD.RecordTypeId = Schema.SObjectType.PriceDetail__c.getRecordTypeInfosByName().get(Label.PriceDetail_Submit).getRecordTypeId();
            Schema.DescribeSObjectResult objResult = PriceDetail__c.sObjectType.getDescribe();
            for(string apiName : objResult.fields.getMap().keySet()){
                String feildName = apiName;
                if(feildName.endsWith('__c')){
                    if((clonedPD.get(apiName) != newPriceDetails.get(apiName)) && (feildName!= 'ClonedFrom__c')){
                        system.debug('feildName***'+feildName);
                        clonedPD.put(apiName, newPriceDetails.get(apiName));
                    }
                }
            }
            system.debug('clonedPD**'+clonedPD);
            if(clonedPD!=null){
                insert clonedPD;    
            }
            
            resultId = Id.valueOf(clonedPD.Id);
            system.debug('resultId'+resultId);
            
        }
        
        return resultId;
    }
    
    //Method to get the exsisting data from the record
    @AuraEnabled
    public static PriceDetail__c getPriceDetails(Id recordId) {
        system.debug('recordId**'+recordId);
        PriceDetail__c pdRecord = (PriceDetail__c) SObjectUtil.getFullSObject(PriceDetail__c.getSObjectType(), recordId);
        return pdRecord;
        
    }
    
    
    
    
}

here is the test class:
@isTest
private class AddPriceModalControllerTest {
    
    @testSetup 
    static void createData() {
        
        TriggerApexSwitch__c apexSwitchNutritionalDetail = TestDataFactory.createApexSwitchTestData(System.Label.NutritionalDetail);
        insert apexSwitchNutritionalDetail;
        
        //Custom Settings - Insert Record for Account
        TriggerApexSwitch__c apexSwitchAccount = TestDataFactory.createApexSwitchTestData(System.Label.Account);
        insert apexSwitchAccount;
        
                TriggerApexSwitch__c apexSwitchUser = TestDataFactory.createApexSwitchTestData(System.Label.User);
        insert apexSwitchUser;
        
        //Custom Settings - Insert Record for SupplierProductArticle    
        TriggerApexSwitch__c apexSwitchSupplierProductArticle     = TestDataFactory.createApexSwitchTestData(System.Label.SupplierProductArticle);
        insert apexSwitchSupplierProductArticle    ;
          
        //Custom Settings - Insert Record for Price Detail    
        TriggerApexSwitch__c apexSwitchPriceDetail     = TestDataFactory.createApexSwitchTestData(System.Label.PriceDetail);
        insert apexSwitchPriceDetail;
          
        //Custom Settings - Insert Record for Case    
        TriggerApexSwitch__c apexSwitchCase = TestDataFactory.createApexSwitchTestData(System.Label.Case);
        insert apexSwitchCase;  
      
        //Custom Settings - Insert Record for GPA    
        TriggerApexSwitch__c apexSwitchGPA = TestDataFactory.createApexSwitchTestData('GlobalProductArticle');
        insert apexSwitchGPA;  
        
        //Custom Settings - Insert Record for Pack Detail    
        TriggerApexSwitch__c apexSwitchPD = TestDataFactory.createApexSwitchTestData('PackDetail');
        insert apexSwitchPD;  
        
        
        //Custom Settings - Insert Record for Retail price    
        TriggerApexSwitch__c apexSwitchRetail = TestDataFactory.createApexSwitchTestData(System.Label.RetailPrice);
        insert apexSwitchRetail;  
        
        //Custom Settings - Insert Record for GTIN    
        TriggerApexSwitch__c apexSwitchGTIN = TestDataFactory.createApexSwitchTestData(System.Label.GlobalTradeItemNumber);
        insert apexSwitchGTIN; 
       
        
        String ArticleEnrichment = Schema.SObjectType.SupplierProductArticle__c.getRecordTypeInfosByName().get('Article Enrichment').getRecordTypeId();
        
        //Create Test data for Account 
        Account accountRec = TestDataFactory.createAccountTestData(1);       
        insert accountRec;                

        //Custom Settings - Insert Record for Contact    
        TriggerApexSwitch__c apexSwitchContact = TestDataFactory.createApexSwitchTestData(System.Label.Contact);
        insert apexSwitchContact;
        
        //Custom Settings - Insert Record for AccountContactRelation    
        TriggerApexSwitch__c apexSwitchAccountContactRelation = TestDataFactory.createApexSwitchTestData(System.Label.AccountContactRelation);
        insert apexSwitchAccountContactRelation;
        
        //Create Test Data for Contact
        Contact contactRec = TestDataFactory.createContactTestData(1, accountRec.Id);
        insert contactRec;
        
        Global_Product_Article__c gpTest = new Global_Product_Article__c();
        gpTest.Article_Hierarchy_Sub_Category_Name__c = 'Test';
        gpTest.Wow_Article_Number__c = NULL;
        insert gpTest;
        
        SupplierProductArticle__c[] spaList = new List<SupplierProductArticle__c>();
        SupplierProductArticle__c spaTest = new SupplierProductArticle__c();
        spaTest.Account__c = accountRec.Id;
        spaTest.Global_Product_Article__c = gpTest.Id;
        spaTest.RecordTypeId = ArticleEnrichment;
        spaTest.Sub_Status__c = 'Awaiting Documents';
        insert spaTest;
        
        Retail_Price__c[] rpList = new List<Retail_Price__c>();
        Retail_Price__c rpTest = new Retail_Price__c();
        rpTest.SupplierProductArticle__c = spaTest.Id;
        rpTest.Number_of_Units__c = 453;
        rpTest.GTIN__c = '8956353';
        rpList.add(rpTest);
        insert rpList;
        
        PackDetail__c pdTest = TestDataFactory.createPackDetails(gpTest.Id);
        pdTest.GTIN__c = '34802';
        pdTest.NumberOfUnits__c = 34;
        pdTest.Orderable_Unit__c = 'Yes';
        insert pdTest;
        
        PriceDetail__c priceRec = new PriceDetail__c();
        priceRec.SupplierProductArticle__c = spaTest.Id;
        priceRec.BonusStockQualifyingQty__c = 89;
        
        insert priceRec;
        
        priceRec.Orderable_GTIN__c = '34802';
        update priceRec;

        //PDRec.clone(false, true, false, false);
        PriceDetail__c PDRec = new PriceDetail__c();
        PDRec.InvoiceCost__c = 888;
        PDRec.NetCost__c = 466;
        PDRec.Status__c = Label.Draft;
        PDRec.SupplierProductArticle__c = spaTest.Id;
        PDRec.RecordTypeId = Schema.SObjectType.PriceDetail__c.getRecordTypeInfosByName().get(Label.PriceDetail_Submit).getRecordTypeId();
        insert PDRec;
        
        PriceDetail__c pD = PDRec.clone(false, true, false, false);
            pD.InvoiceCost__c = 999;
            pD.NetCost__c = 577;
            pD.Status__c = Label.Draft;
            pD.SupplierProductArticle__c = spaTest.Id;
            pD.RecordTypeId = Schema.SObjectType.PriceDetail__c.getRecordTypeInfosByName().get(Label.PriceDetail_Submit).getRecordTypeId();
            insert pD;
    }
    
    @isTest static void getRegionValuesTest(){
        System.assertNotEquals(null, AddPriceModalController.getRegionValues());
    }
    
    @isTest static void getDeliveryMethodValuesTest(){
        System.assertNotEquals(null, AddPriceModalController.getDeliveryMethodValues());
    }
    
    @isTest static void savePriceDetailsTest(){
        //List<PriceDetail__c> pD = [Select Id, InvoiceCost__c, NetCost__c, RecordTypeId, Geography__c  FROM PriceDetail__c];
      String PDSOQL = SObjectUtil.getSOQLStringFullFields(PriceDetail__c.getSObjectType())
            +' LIMIT 1';
        PriceDetail__c pD = Database.query(PDSOQL); 
        AddPriceModalController.savePriceDetails(pD.Id, pD);
    }
    
    @isTest static void getgetPriceDetailsTest(){
        List<PriceDetail__c> pD = [Select Id, InvoiceCost__c, NetCost__c, RecordTypeId  FROM PriceDetail__c];
        System.assertNotEquals(null, AddPriceModalController.getPriceDetails(pD[0].Id));
    }
}

the catch method in my class is not covered by the test class.

here is the separate code of my try-catch method above:
   
    PriceDetail__c PDRec;
        try{
            PDRec = Database.query(PDSOQL);   
        }catch(Exception e){
            ApplicationLogUtility.logError('SubmitActionController', 'getParentId', e, e.getMessage(), '', 0);
            ApplicationLogUtility.commitLog();
            PDRec = null; 

what should i do to cover the catch method by the test class ?
here is my code:
public class AddPriceModalController {
    @AuraEnabled
    public static List<String> getRegionValues() {
        List<String> lstGeography = new List<String>(); //new list for holding all of the picklist options
        
        Schema.DescribeFieldResult fieldResult = PriceDetail__c.Geography__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple)
        {
            lstGeography.add(f.getValue());
        }
        
        return lstGeography;
    }
    
    @AuraEnabled
    public static List<String> getDeliveryMethodValues() {
        List<String> lstSourceOfSupply = new List<String>(); //new list for holding all of the picklist options
        
        Schema.DescribeFieldResult fieldResult = PriceDetail__c.Source_of_Supply__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple)
        {
            lstSourceOfSupply.add(f.getLabel() + '---' + f.getValue());            
        }
        
        return lstSourceOfSupply;
    }
    //Method to Save the Price Detail Change Request
    @AuraEnabled
    public static String savePriceDetails(Id PDID,PriceDetail__c newPriceDetails) {
        system.debug('savePriceDetails');
        system.debug('newPriceDetails'+newPriceDetails);
        Decimal invoiceCost = 0;
        Decimal netCost = 0;
        Decimal netProfit = 0;
        Decimal retailPrice = 0;
        string resultId;
        //Webservice Call to SAP to get the InvoiceCost and NetCost
        /*invoiceCost = PriceDetailsWebService.getInvoiceCost(PDID);
netCost = PriceDetailsWebService.getNetCost(PDID);*/
        
        String PDSOQL = SObjectUtil.getSOQLStringFullFields(PriceDetail__c.getSObjectType())
            +' WHERE ' + ' Id = :PDID LIMIT 1';
        //List<PriceDetail__c> listPD = Database.query(PDSOQL);
        PriceDetail__c PDRec;
        try{
            PDRec = Database.query(PDSOQL);   
        }catch(Exception e){
            ApplicationLogUtility.logError('SubmitActionController', 'getParentId', e, e.getMessage(), '', 0);
            ApplicationLogUtility.commitLog();
            PDRec = null; 
        }   
        if(PDRec!=null){
            PriceDetail__c clonedPD = PDRec.clone(false, true, false, false);
            clonedPD.InvoiceCost__c = invoiceCost;
            clonedPD.NetCost__c = netCost;
            clonedPD.ClonedFrom__c = PDRec.Id;
            clonedPD.Status__c = Label.Draft;
            clonedPD.RecordTypeId = Schema.SObjectType.PriceDetail__c.getRecordTypeInfosByName().get(Label.PriceDetail_Submit).getRecordTypeId();
            Schema.DescribeSObjectResult objResult = PriceDetail__c.sObjectType.getDescribe();
            for(string apiName : objResult.fields.getMap().keySet()){
                String feildName = apiName;
                if(feildName.endsWith('__c')){
                    if((clonedPD.get(apiName) != newPriceDetails.get(apiName)) && (feildName!= 'ClonedFrom__c')){
                        system.debug('feildName***'+feildName);
                        clonedPD.put(apiName, newPriceDetails.get(apiName));
                    }
                }
            }
            system.debug('clonedPD**'+clonedPD);
            if(clonedPD!=null){
                insert clonedPD;    
            }
            
            resultId = Id.valueOf(clonedPD.Id);
            system.debug('resultId'+resultId);
            
        }
        
        return resultId;
    }
    
    //Method to get the exsisting data from the record
    @AuraEnabled
    public static PriceDetail__c getPriceDetails(Id recordId) {
        system.debug('recordId**'+recordId);
        PriceDetail__c pdRecord = (PriceDetail__c) SObjectUtil.getFullSObject(PriceDetail__c.getSObjectType(), recordId);
        return pdRecord;
        
    }
    
    
    
    
}

here is the test class:
@isTest
private class AddPriceModalControllerTest {

    @testSetup 
    static void createData() {
       PriceDetail__c pD = PDRec.clone(false, true, false, false);
            pD.InvoiceCost__c = 999;
            pD.NetCost__c = 577;
            pD.Status__c = Label.Draft;
            pD.RecordTypeId = Schema.SObjectType.PriceDetail__c.getRecordTypeInfosByName().get(Label.PriceDetail_Submit).getRecordTypeId();
            insert pD;
    }
        
    @isTest static void getRegionValuesTest(){
        System.assertNotEquals(null, AddPriceModalController.getRegionValues());
    }
    
    @isTest static void getDeliveryMethodValuesTest(){
        System.assertNotEquals(null, AddPriceModalController.getDeliveryMethodValues());
    }
    
    @isTest static void savePriceDetailsTest(){
        List<PriceDetail__c> pD = [Select Id, InvoiceCost__c, NetCost__c, RecordTypeId  FROM PriceDetail__c];
        System.assertNotEquals(null, AddPriceModalController.savePriceDetails(pD[0].Id, pD[0]));
    }
    
    @isTest static void getgetPriceDetailsTest(){
        List<PriceDetail__c> pD = [Select Id, InvoiceCost__c, NetCost__c, RecordTypeId  FROM PriceDetail__c];
        System.assertNotEquals(null, AddPriceModalController.getPriceDetails(pD[0].Id));
    }
}

im having an error in my test class on line 6, (Variable does not exist: PDRec)

here is the separate code of line 6:
   PriceDetail__c pD = PDRec.clone(false, true, false, false);

what should i do? 
public class AddPriceModalController {
    @AuraEnabled
    public static List<String> getRegionValues() {
        List<String> lstGeography = new List<String>(); //new list for holding all of the picklist options
        
        Schema.DescribeFieldResult fieldResult = PriceDetail__c.Geography__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple)
        {
            lstGeography.add(f.getValue());
        }
        
        return lstGeography;
    }
    
    @AuraEnabled
    public static List<String> getDeliveryMethodValues() {
        List<String> lstSourceOfSupply = new List<String>(); //new list for holding all of the picklist options
        
        Schema.DescribeFieldResult fieldResult = PriceDetail__c.Source_of_Supply__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple)
        {
            lstSourceOfSupply.add(f.getLabel() + '---' + f.getValue());            
        }
        
        return lstSourceOfSupply;
    }
    //Method to Save the Price Detail Change Request
    @AuraEnabled
    public static String savePriceDetails(Id PDID,PriceDetail__c newPriceDetails) {
        system.debug('savePriceDetails');
        system.debug('newPriceDetails'+newPriceDetails);
        Decimal invoiceCost = 0;
        Decimal netCost = 0;
        Decimal netProfit = 0;
        Decimal retailPrice = 0;
        string resultId;
        //Webservice Call to SAP to get the InvoiceCost and NetCost
        /*invoiceCost = PriceDetailsWebService.getInvoiceCost(PDID);
netCost = PriceDetailsWebService.getNetCost(PDID);*/
        
        String PDSOQL = SObjectUtil.getSOQLStringFullFields(PriceDetail__c.getSObjectType())
            +' WHERE ' + ' Id = :PDID LIMIT 1';
        //List<PriceDetail__c> listPD = Database.query(PDSOQL);
        PriceDetail__c PDRec;
        try{
            PDRec = Database.query(PDSOQL);   
        }catch(Exception e){
            ApplicationLogUtility.logError('SubmitActionController', 'getParentId', e, e.getMessage(), '', 0);
            ApplicationLogUtility.commitLog();
            PDRec = null; 
        }   
        if(PDRec!=null){
            PriceDetail__c clonedPD = PDRec.clone(false, true, false, false);
            clonedPD.InvoiceCost__c = invoiceCost;
            clonedPD.NetCost__c = netCost;
            clonedPD.ClonedFrom__c = PDRec.Id;
            clonedPD.Status__c = Label.Draft;
            clonedPD.RecordTypeId = Schema.SObjectType.PriceDetail__c.getRecordTypeInfosByName().get(Label.PriceDetail_Submit).getRecordTypeId();
            Schema.DescribeSObjectResult objResult = PriceDetail__c.sObjectType.getDescribe();
            for(string apiName : objResult.fields.getMap().keySet()){
                String feildName = apiName;
                if(feildName.endsWith('__c')){
                    if((clonedPD.get(apiName) != newPriceDetails.get(apiName)) && (feildName!= 'ClonedFrom__c')){
                        system.debug('feildName***'+feildName);
                        clonedPD.put(apiName, newPriceDetails.get(apiName));
                    }
                }
            }
            system.debug('clonedPD**'+clonedPD);
            if(clonedPD!=null){
                insert clonedPD;    
            }
            
            resultId = Id.valueOf(clonedPD.Id);
            system.debug('resultId'+resultId);
            
        }
        
        return resultId;
    }
    
    //Method to get the exsisting data from the record
    @AuraEnabled
    public static PriceDetail__c getPriceDetails(Id recordId) {
        system.debug('recordId**'+recordId);
        PriceDetail__c pdRecord = (PriceDetail__c) SObjectUtil.getFullSObject(PriceDetail__c.getSObjectType(), recordId);
        return pdRecord;
        
    }
    
    
    
    
}
here is my code:
public class AddPriceModalController {
    @AuraEnabled
    public static List<String> getRegionValues() {
        List<String> lstGeography = new List<String>(); //new list for holding all of the picklist options
        
        Schema.DescribeFieldResult fieldResult = PriceDetail__c.Geography__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple)
        {
            lstGeography.add(f.getValue());
        }
        
        return lstGeography;
    }
    
    @AuraEnabled
    public static List<String> getDeliveryMethodValues() {
        List<String> lstSourceOfSupply = new List<String>(); //new list for holding all of the picklist options
        
        Schema.DescribeFieldResult fieldResult = PriceDetail__c.Source_of_Supply__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple)
        {
            lstSourceOfSupply.add(f.getLabel() + '---' + f.getValue());            
        }
        
        return lstSourceOfSupply;
    }
    //Method to Save the Price Detail Change Request
    @AuraEnabled
    public static String savePriceDetails(Id PDID,PriceDetail__c newPriceDetails) {
        system.debug('savePriceDetails');
        system.debug('newPriceDetails'+newPriceDetails);
        Decimal invoiceCost = 0;
        Decimal netCost = 0;
        Decimal netProfit = 0;
        Decimal retailPrice = 0;
        string resultId;
        //Webservice Call to SAP to get the InvoiceCost and NetCost
        /*invoiceCost = PriceDetailsWebService.getInvoiceCost(PDID);
netCost = PriceDetailsWebService.getNetCost(PDID);*/
        
        String PDSOQL = SObjectUtil.getSOQLStringFullFields(PriceDetail__c.getSObjectType())
            +' WHERE ' + ' Id = :PDID LIMIT 1';
        //List<PriceDetail__c> listPD = Database.query(PDSOQL);
        PriceDetail__c PDRec;
        try{
            PDRec = Database.query(PDSOQL);   
        }catch(Exception e){
            ApplicationLogUtility.logError('SubmitActionController', 'getParentId', e, e.getMessage(), '', 0);
            ApplicationLogUtility.commitLog();
            PDRec = null; 
        }   
        if(PDRec!=null){
            PriceDetail__c clonedPD = PDRec.clone(false, true, false, false);
            clonedPD.InvoiceCost__c = invoiceCost;
            clonedPD.NetCost__c = netCost;
            clonedPD.ClonedFrom__c = PDRec.Id;
            clonedPD.Status__c = Label.Draft;
            clonedPD.RecordTypeId = Schema.SObjectType.PriceDetail__c.getRecordTypeInfosByName().get(Label.PriceDetail_Submit).getRecordTypeId();
            Schema.DescribeSObjectResult objResult = PriceDetail__c.sObjectType.getDescribe();
            for(string apiName : objResult.fields.getMap().keySet()){
                String feildName = apiName;
                if(feildName.endsWith('__c')){
                    if((clonedPD.get(apiName) != newPriceDetails.get(apiName)) && (feildName!= 'ClonedFrom__c')){
                        system.debug('feildName***'+feildName);
                        clonedPD.put(apiName, newPriceDetails.get(apiName));
                    }
                }
            }
            system.debug('clonedPD**'+clonedPD);
            if(clonedPD!=null){
                insert clonedPD;    
            }
            
            resultId = Id.valueOf(clonedPD.Id);
            system.debug('resultId'+resultId);
            
        }
        
        return resultId;
    }
    
    //Method to get the exsisting data from the record
    @AuraEnabled
    public static PriceDetail__c getPriceDetails(Id recordId) {
        system.debug('recordId**'+recordId);
        PriceDetail__c pdRecord = (PriceDetail__c) SObjectUtil.getFullSObject(PriceDetail__c.getSObjectType(), recordId);
        return pdRecord;
        
    }
    
    
    
    
}

here is the test class:
@isTest
private class AddPriceModalControllerTest {
    
    @testSetup 
    static void createData() {
        
        TriggerApexSwitch__c apexSwitchNutritionalDetail = TestDataFactory.createApexSwitchTestData(System.Label.NutritionalDetail);
        insert apexSwitchNutritionalDetail;
        
        //Custom Settings - Insert Record for Account
        TriggerApexSwitch__c apexSwitchAccount = TestDataFactory.createApexSwitchTestData(System.Label.Account);
        insert apexSwitchAccount;
        
                TriggerApexSwitch__c apexSwitchUser = TestDataFactory.createApexSwitchTestData(System.Label.User);
        insert apexSwitchUser;
        
        //Custom Settings - Insert Record for SupplierProductArticle    
        TriggerApexSwitch__c apexSwitchSupplierProductArticle     = TestDataFactory.createApexSwitchTestData(System.Label.SupplierProductArticle);
        insert apexSwitchSupplierProductArticle    ;
          
        //Custom Settings - Insert Record for Price Detail    
        TriggerApexSwitch__c apexSwitchPriceDetail     = TestDataFactory.createApexSwitchTestData(System.Label.PriceDetail);
        insert apexSwitchPriceDetail;
          
        //Custom Settings - Insert Record for Case    
        TriggerApexSwitch__c apexSwitchCase = TestDataFactory.createApexSwitchTestData(System.Label.Case);
        insert apexSwitchCase;  
      
        //Custom Settings - Insert Record for GPA    
        TriggerApexSwitch__c apexSwitchGPA = TestDataFactory.createApexSwitchTestData('GlobalProductArticle');
        insert apexSwitchGPA;  
        
        //Custom Settings - Insert Record for Pack Detail    
        TriggerApexSwitch__c apexSwitchPD = TestDataFactory.createApexSwitchTestData('PackDetail');
        insert apexSwitchPD;  
        
        
        //Custom Settings - Insert Record for Retail price    
        TriggerApexSwitch__c apexSwitchRetail = TestDataFactory.createApexSwitchTestData(System.Label.RetailPrice);
        insert apexSwitchRetail;  
        
        //Custom Settings - Insert Record for GTIN    
        TriggerApexSwitch__c apexSwitchGTIN = TestDataFactory.createApexSwitchTestData(System.Label.GlobalTradeItemNumber);
        insert apexSwitchGTIN; 
       
        
        String ArticleEnrichment = Schema.SObjectType.SupplierProductArticle__c.getRecordTypeInfosByName().get('Article Enrichment').getRecordTypeId();
        
        //Create Test data for Account 
        Account accountRec = TestDataFactory.createAccountTestData(1);       
        insert accountRec;                

        //Custom Settings - Insert Record for Contact    
        TriggerApexSwitch__c apexSwitchContact = TestDataFactory.createApexSwitchTestData(System.Label.Contact);
        insert apexSwitchContact;
        
        //Custom Settings - Insert Record for AccountContactRelation    
        TriggerApexSwitch__c apexSwitchAccountContactRelation = TestDataFactory.createApexSwitchTestData(System.Label.AccountContactRelation);
        insert apexSwitchAccountContactRelation;
        
        //Create Test Data for Contact
        Contact contactRec = TestDataFactory.createContactTestData(1, accountRec.Id);
        insert contactRec;
        
        Global_Product_Article__c gpTest = new Global_Product_Article__c();
        gpTest.Article_Hierarchy_Sub_Category_Name__c = 'Test';
        gpTest.Wow_Article_Number__c = NULL;
        insert gpTest;
        
        SupplierProductArticle__c[] spaList = new List<SupplierProductArticle__c>();
        SupplierProductArticle__c spaTest = new SupplierProductArticle__c();
        spaTest.Account__c = accountRec.Id;
        spaTest.Global_Product_Article__c = gpTest.Id;
        spaTest.RecordTypeId = ArticleEnrichment;
        spaTest.Sub_Status__c = 'Awaiting Documents';
        insert spaTest;
        
        Retail_Price__c[] rpList = new List<Retail_Price__c>();
        Retail_Price__c rpTest = new Retail_Price__c();
        rpTest.SupplierProductArticle__c = spaTest.Id;
        rpTest.Number_of_Units__c = 453;
        rpTest.GTIN__c = '8956353';
        rpList.add(rpTest);
        insert rpList;
        
        PackDetail__c pdTest = TestDataFactory.createPackDetails(gpTest.Id);
        pdTest.GTIN__c = '34802';
        pdTest.NumberOfUnits__c = 34;
        pdTest.Orderable_Unit__c = 'Yes';
        insert pdTest;
        
        PriceDetail__c priceRec = new PriceDetail__c();
        priceRec.SupplierProductArticle__c = spaTest.Id;
        priceRec.BonusStockQualifyingQty__c = 89;
        
        insert priceRec;
        
        priceRec.Orderable_GTIN__c = '34802';
        update priceRec;

        //PDRec.clone(false, true, false, false);
        PriceDetail__c PDRec = new PriceDetail__c();
        PDRec.InvoiceCost__c = 888;
        PDRec.NetCost__c = 466;
        PDRec.Status__c = Label.Draft;
        PDRec.SupplierProductArticle__c = spaTest.Id;
        PDRec.RecordTypeId = Schema.SObjectType.PriceDetail__c.getRecordTypeInfosByName().get(Label.PriceDetail_Submit).getRecordTypeId();
        insert PDRec;
        
        PriceDetail__c pD = PDRec.clone(false, true, false, false);
            pD.InvoiceCost__c = 999;
            pD.NetCost__c = 577;
            pD.Status__c = Label.Draft;
            pD.SupplierProductArticle__c = spaTest.Id;
            pD.RecordTypeId = Schema.SObjectType.PriceDetail__c.getRecordTypeInfosByName().get(Label.PriceDetail_Submit).getRecordTypeId();
            insert pD;
    }
    
    @isTest static void getRegionValuesTest(){
        System.assertNotEquals(null, AddPriceModalController.getRegionValues());
    }
    
    @isTest static void getDeliveryMethodValuesTest(){
        System.assertNotEquals(null, AddPriceModalController.getDeliveryMethodValues());
    }
    
    @isTest static void savePriceDetailsTest(){
        //List<PriceDetail__c> pD = [Select Id, InvoiceCost__c, NetCost__c, RecordTypeId, Geography__c  FROM PriceDetail__c];
      String PDSOQL = SObjectUtil.getSOQLStringFullFields(PriceDetail__c.getSObjectType())
            +' LIMIT 1';
        PriceDetail__c pD = Database.query(PDSOQL); 
        AddPriceModalController.savePriceDetails(pD.Id, pD);
    }
    
    @isTest static void getgetPriceDetailsTest(){
        List<PriceDetail__c> pD = [Select Id, InvoiceCost__c, NetCost__c, RecordTypeId  FROM PriceDetail__c];
        System.assertNotEquals(null, AddPriceModalController.getPriceDetails(pD[0].Id));
    }
}

the catch method in my class is not covered by the test class.

here is the separate code of my try-catch method above:
   
    PriceDetail__c PDRec;
        try{
            PDRec = Database.query(PDSOQL);   
        }catch(Exception e){
            ApplicationLogUtility.logError('SubmitActionController', 'getParentId', e, e.getMessage(), '', 0);
            ApplicationLogUtility.commitLog();
            PDRec = null; 

what should i do to cover the catch method by the test class ?
public class AddPriceModalController {
    @AuraEnabled
    public static List<String> getRegionValues() {
        List<String> lstGeography = new List<String>(); //new list for holding all of the picklist options
        
        Schema.DescribeFieldResult fieldResult = PriceDetail__c.Geography__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple)
        {
            lstGeography.add(f.getValue());
        }
        
        return lstGeography;
    }
    
    @AuraEnabled
    public static List<String> getDeliveryMethodValues() {
        List<String> lstSourceOfSupply = new List<String>(); //new list for holding all of the picklist options
        
        Schema.DescribeFieldResult fieldResult = PriceDetail__c.Source_of_Supply__c.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        
        for( Schema.PicklistEntry f : ple)
        {
            lstSourceOfSupply.add(f.getLabel() + '---' + f.getValue());            
        }
        
        return lstSourceOfSupply;
    }
    //Method to Save the Price Detail Change Request
    @AuraEnabled
    public static String savePriceDetails(Id PDID,PriceDetail__c newPriceDetails) {
        system.debug('savePriceDetails');
        system.debug('newPriceDetails'+newPriceDetails);
        Decimal invoiceCost = 0;
        Decimal netCost = 0;
        Decimal netProfit = 0;
        Decimal retailPrice = 0;
        string resultId;
        //Webservice Call to SAP to get the InvoiceCost and NetCost
        /*invoiceCost = PriceDetailsWebService.getInvoiceCost(PDID);
netCost = PriceDetailsWebService.getNetCost(PDID);*/
        
        String PDSOQL = SObjectUtil.getSOQLStringFullFields(PriceDetail__c.getSObjectType())
            +' WHERE ' + ' Id = :PDID LIMIT 1';
        //List<PriceDetail__c> listPD = Database.query(PDSOQL);
        PriceDetail__c PDRec;
        try{
            PDRec = Database.query(PDSOQL);   
        }catch(Exception e){
            ApplicationLogUtility.logError('SubmitActionController', 'getParentId', e, e.getMessage(), '', 0);
            ApplicationLogUtility.commitLog();
            PDRec = null; 
        }   
        if(PDRec!=null){
            PriceDetail__c clonedPD = PDRec.clone(false, true, false, false);
            clonedPD.InvoiceCost__c = invoiceCost;
            clonedPD.NetCost__c = netCost;
            clonedPD.ClonedFrom__c = PDRec.Id;
            clonedPD.Status__c = Label.Draft;
            clonedPD.RecordTypeId = Schema.SObjectType.PriceDetail__c.getRecordTypeInfosByName().get(Label.PriceDetail_Submit).getRecordTypeId();
            Schema.DescribeSObjectResult objResult = PriceDetail__c.sObjectType.getDescribe();
            for(string apiName : objResult.fields.getMap().keySet()){
                String feildName = apiName;
                if(feildName.endsWith('__c')){
                    if((clonedPD.get(apiName) != newPriceDetails.get(apiName)) && (feildName!= 'ClonedFrom__c')){
                        system.debug('feildName***'+feildName);
                        clonedPD.put(apiName, newPriceDetails.get(apiName));
                    }
                }
            }
            system.debug('clonedPD**'+clonedPD);
            if(clonedPD!=null){
                insert clonedPD;    
            }
            
            resultId = Id.valueOf(clonedPD.Id);
            system.debug('resultId'+resultId);
            
        }
        
        return resultId;
    }
    
    //Method to get the exsisting data from the record
    @AuraEnabled
    public static PriceDetail__c getPriceDetails(Id recordId) {
        system.debug('recordId**'+recordId);
        PriceDetail__c pdRecord = (PriceDetail__c) SObjectUtil.getFullSObject(PriceDetail__c.getSObjectType(), recordId);
        return pdRecord;
        
    }
    
    
    
    
}