• Balasubramani Dhanapal
  • NEWBIE
  • 70 Points
  • Member since 2014
  • Merfantz Technologies Pvt.Ltd

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 22
    Questions
  • 11
    Replies

Hi all, 
         How to call the apex  visulforce page in apex class. 

Thanks in advance 

Regards,
Bala

Hi All,
              How to  create an  pop up alert for  whenever the  Custom field (Booked with customer) is amended. 

API NAME : Booked_with_Customers__c(Picklist)

Please any one help me 

Regards,
Bala
Hi All,
           How to create the New  Report for the below condition  
"same Amount and  same Record Name". Is it possible to create a filter logic?

Please advice me

Regards,
Bala
Hi All,
         If any price book price is amended, including the standard price book,How can I get an emailed alert?

Regards,
Bala 
Hi All,
         If any price book price is amended, including the standard price book,How can I get an emailed alert?

Regards,
Bala
Hi,
        Map anything app  base object  is "Account(Billing)"  is currency symbol is $. This account object values comes under the  
"Annual Revenue " field, this field currency   symbol is £. How to change the $ symbol in to £ symbol in   map anything Application.

Advance in Thanks.
Regards,
Bala

 
Hi ,
             How to change the currency symbol  $ into  £.?  for  mapanything salesforce app. 

Advance in thanks,

Regards
Bala
Hi,
    I have written code for class named as "InvoiceTriggerhandler".this class corresponding test class named as "Invocie Triggerhandlertest".my test class in failing and i got the below  error "


Invoice Trigger Handler:

Public Class InvoiceTriggerHandler{
    
    Public Void OnAfterInsert(Map<id, Invoice__c> newInvoiceMap,Map<id, Invoice__c> oldInvoiceMap){
        
    }
    
    Public Void OnAfterUpdate(Map<id, Invoice__c> newInvoiceMap,Map<id, Invoice__c> oldInvoiceMap){
        if(RecursiveHandler.runITH_POOnce()) PlaceOrder(newInvoiceMap, oldInvoiceMap);
    }
    
    Private Void PlaceOrder(Map<id, Invoice__c> newInvoiceMap, Map<id, Invoice__c> oldInvoiceMap){
        List<id> invIdToPlaceOrders=new List<Id>();
        List<id> quoteIds=new List<Id>();
        for(Invoice__c inv:newInvoiceMap.values()){
            if(inv.Generate_order__c== True  && inv.Generate_order__c!=oldInvoiceMap.get(inv.Id).Generate_order__c){
                invIdToPlaceOrders.add(inv.id);
                quoteIds.add(inv.Quote__c);
            }
        }
        Map<id, Quote> qteMap=new Map<Id, Quote>([SELECT BillingCity,BillingCountry,BillingCountryCode,BillingLatitude,BillingLongitude,BillingName,BillingPostalCode,BillingState,BillingStateCode,BillingStreet,ContactId,Contact.FirstName,Contact.LastName,Description,Discount,Email,ExpirationDate,Fax,GrandTotal,Id,LineItemCount,Name,OpportunityId,Phone,Pricebook2Id,QuoteNumber,ShippingCity,ShippingCountry,ShippingCountryCode,ShippingHandling,ShippingLatitude,ShippingLongitude,ShippingName,ShippingPostalCode,ShippingState,ShippingStateCode,ShippingStreet,Status,Subtotal,Tax,TotalPrice,Dead_Line__c FROM Quote where id IN:quoteIds]);        
        List<Order> listOrderToInsert=new List<Order>();
        Order temp;
        Invoice__c inv;
        Quote qte;
        for(id invId:invIdToPlaceOrders){
            temp=new Order();
            inv=newInvoiceMap.get(invId);
            qte=qteMap.get(inv.Quote__c);
            temp.QuoteId=inv.Quote__c;
            temp.AccountId=inv.AccountID__c;
            temp.OpportunityId=inv.Opportunity__c;
            temp.billTocontactId=qte.ContactID;
            temp.billingStreet=qte.billingStreet;
            temp.billingCity=qte.billingCity;
            temp.billingState=qte.billingState;
            temp.billingCountry=qte.billingCountry;
            temp.BillingPostalCode=qte.BillingPostalCode;
            
            temp.ShippingStreet=qte.ShippingStreet;
            temp.ShippingCity=qte.ShippingCity;
            temp.ShippingState=qte.ShippingState;
            temp.ShippingCountry=qte.ShippingCountry;
            temp.ShippingPostalCode=qte.ShippingPostalCode; 
            temp.EffectiveDate=System.today();
            temp.Status='Initial Progress';
            temp.Invoice__c=invId;
            temp.Pricebook2Id=qte.Pricebook2Id;
            temp.EndDate=qte.Dead_Line__c;
            listOrderToInsert.add(temp);
        }
        if(listOrderToInsert.size()>0)
            insert listOrderToInsert;
    }
    
}
Invoice Triggerhandler Test:
---------------------------------------
@isTest(SeeAllData=true)

Public Class InvoiceTriggerHandlerTest{
    
    @isTest public Static void TestPlaceOrder(){
    
    Account a= new Account(Name='testprimary');
    insert a;
    Contact NewCon= New Contact ( LastName ='Test contact',Accountid =a.id);
    insert NewCon;
    
    Opportunity opp=New Opportunity(Name='Test Opportunity',Accountid=a.id,StageName='Closed Won',CloseDate=System.today());
    insert opp;
    
    
     
    Quote qt=[SELECT id,Name FROM Quote Limit 1];
    
   
    Product2 prod=[SELECT id,Category__c from Product2 where Exclude_Pricing_Matrix__c=false AND Category__c='Item Category: A' LIMIT 1];
    Id pbId=[SELECT id from PriceBook2 where name='Standard Price Book' LIMIT 1].id;
    id PBEId=[SELECT id from PricebookEntry where Product2Id=:prod.Id and Pricebook2Id=:pbId LIMIT 1].Id; 
    
    QuoteLineItem qli=new QuoteLineItem (quoteid=qt.id,PricebookEntryId=PBEId,Follow_Pricing_Matrix__c=TRUE,Capacity__c='64 MB',Description='Testing Description',Quantity=30,UnitPrice=100);
    insert qli;
    
    Order ord=New Order(Name='Test Opportunity',Quoteid=qt.id, Accountid=a.id,Opportunityid=opp.id,BillToContactid=NewCon.id,ShipToContactid=NewCon.id,Manufacturer_Email__c='Test@merfantz.com',Status ='shipping',EffectiveDate=System.today());
    insert ord;
    
    
    List<Order> listOrderToInsert=new List<Order>();
    Order qte = new Order();
    listOrderToInsert.add(ord);
    Test.StartTest();
    insert listOrderToInsert;
    Test.stopTest();
   }
}

Order Trigger Handler:
----------------------------------
Public Class OrderTriggerHandler{
    
    Public Void OnAfterInsert(Map<id, Order> newOrderMap){
        AddProducts(newOrderMap);    
    }
    
    Public Void OnAfterUpdate(Map<id, Order> newOrderMap,Map<id, Order> oldOrderMap){
        
    }
    
    Private Void AddProducts(Map<id, Order> newOrderMap){
        List<id> quoteIds=new List<Id>();
        for(Order ord:newOrderMap.values()){
            quoteIds.add(ord.QuoteId);
        }
        
        Map<id, Quote> qteMap=new Map<Id, Quote>([SELECT id,(SELECT id,Quantity,UnitPrice,Capacity__c, Pricebookentryid from QuoteLineItems) FROM Quote where id IN:quoteIds]);        
        List<OrderItem> listOrLIs=new List<OrderItem>();
        OrderItem OrLI;
        for(Order ord:newOrderMap.values()){  
                 
            for(QuoteLineItem qLI: qteMap.get(ord.Quoteid).QuoteLineItems){
                OrLI=new OrderItem();
                OrLI.PriceBookEntryId=qLI.PriceBookEntryId;
                OrLI.Orderid=ord.Id;
                OrLI.Capacity__c=qLI.Capacity__c;
                OrLI.Quantity=qLI.Quantity;
                OrLI.Unitprice=qLI.UnitPrice;
                listOrLIs.add(OrLI);
            }        
        }
       if(listOrLIs.size()>0) insert listOrLIs;
    }
    
}





Please help me anyone 
Hi ,
I'm having trouble writing the tests class for the following Trigger Handler . I'm new to SF. Can some one please help.
Invocie Trigger Handler:
---------------------------------

Public Class InvoiceTriggerHandler{
    
    Public Void OnAfterInsert(Map<id, Invoice__c> newInvoiceMap,Map<id, Invoice__c> oldInvoiceMap){
        
    }
    
    Public Void OnAfterUpdate(Map<id, Invoice__c> newInvoiceMap,Map<id, Invoice__c> oldInvoiceMap){
        if(RecursiveHandler.runITH_POOnce()) PlaceOrder(newInvoiceMap, oldInvoiceMap);
    }
    
    Private Void PlaceOrder(Map<id, Invoice__c> newInvoiceMap, Map<id, Invoice__c> oldInvoiceMap){
        List<id> invIdToPlaceOrders=new List<Id>();
        List<id> quoteIds=new List<Id>();
        for(Invoice__c inv:newInvoiceMap.values()){
            if(inv.Generate_order__c== True  && inv.Generate_order__c!=oldInvoiceMap.get(inv.Id).Generate_order__c){
                invIdToPlaceOrders.add(inv.id);
                quoteIds.add(inv.Quote__c);
            }
        }
        Map<id, Quote> qteMap=new Map<Id, Quote>([SELECT BillingCity,BillingCountry,BillingCountryCode,BillingLatitude,BillingLongitude,BillingName,BillingPostalCode,BillingState,BillingStateCode,BillingStreet,ContactId,Contact.FirstName,Contact.LastName,Description,Discount,Email,ExpirationDate,Fax,GrandTotal,Id,LineItemCount,Name,OpportunityId,Phone,Pricebook2Id,QuoteNumber,ShippingCity,ShippingCountry,ShippingCountryCode,ShippingHandling,ShippingLatitude,ShippingLongitude,ShippingName,ShippingPostalCode,ShippingState,ShippingStateCode,ShippingStreet,Status,Subtotal,Tax,TotalPrice,Dead_Line__c FROM Quote where id IN:quoteIds]);        
        List<Order> listOrderToInsert=new List<Order>();
        Order temp;
        Invoice__c inv;
        Quote qte;
        for(id invId:invIdToPlaceOrders){
            temp=new Order();
            inv=newInvoiceMap.get(invId);
            qte=qteMap.get(inv.Quote__c);
            temp.QuoteId=inv.Quote__c;
            temp.AccountId=inv.AccountID__c;
            temp.OpportunityId=inv.Opportunity__c;
            temp.billTocontactId=qte.ContactID;
            temp.billingStreet=qte.billingStreet;
            temp.billingCity=qte.billingCity;
            temp.billingState=qte.billingState;
            temp.billingCountry=qte.billingCountry;
            temp.BillingPostalCode=qte.BillingPostalCode;
            
            temp.ShippingStreet=qte.ShippingStreet;
            temp.ShippingCity=qte.ShippingCity;
            temp.ShippingState=qte.ShippingState;
            temp.ShippingCountry=qte.ShippingCountry;
            temp.ShippingPostalCode=qte.ShippingPostalCode; 
            temp.EffectiveDate=System.today();
            temp.Status='Initial Progress';
            temp.Invoice__c=invId;
            temp.Pricebook2Id=qte.Pricebook2Id;
            temp.EndDate=qte.Dead_Line__c;
            listOrderToInsert.add(temp);
        }
        if(listOrderToInsert.size()>0)
            insert listOrderToInsert;
    }
    
}
Thanks in advance.
Hi,


public with sharing class QuoteLineItemsManager{
    
    Public String qteId;
    Public List<QuoteLineItem> QLIs{get; set;} 
    
    public void setqteId (String s) {
        qteId= s;
        QLIs=new List<QuoteLineItem>();
        QLIs=[SELECT id,(Select id, PricebookEntry.Name,Description,Quantity,UnitPrice,TotalPrice, Capacity__c from QuoteLineItems ORDER BY SortOrder) from Quote where Id=:qteId].QuoteLineItems;
        system.debug('qteId==='+qteId);
    }      
    Public String getqteId(){
        return qteId;
    }
    Public QuoteLineItemsManager() {                        
        
    }

}


Thanks.
Hi all,
              I am begineer of salesforce.please help me the below feature development.  
Write batch to update all the opportunities close date as today() ? 

Thanks in advance 
Bala
Hi all,
        I am beginner  in salesforce.I have struggle in validation rules using trigger.Please make it so that we cannot create a Product with the same Product Code (or)  SAGE Code(custom field) as an existing product. This is similar to the way we cannot create two products with the same name.

Thanks in advance
Hi Everyone,
                      I have create one list views in one  visit custom object. I wish this to show projects that are due to start on the following day
(ACTUAL VISIT DATE = TOMORROW), but have an issue when we have a job starting on Monday (will only come into the view on a Sunday).
Please can you advise if there is a way of including a logic statement to the effect that (ACTUAL VISIT DATE = TOMORROW) or (ACTUAL VISIT DATE = NEXT MONDAY IF TODAY IS FRIDAY)

Thanks in advance

Regards,
Bala
Hi all,
         How to enable Related list setting ?. I am not able to enable  edit/ add the product standard object related list.

Thanks in advance
Hi ,
     I am begineer of salesforce.I have create one custom field name as 'cost'.Now i want add the  cost field into Related list in 'Product' standard object.Is it possible to add related list in custom field on standard objects.?

Thanks in advance
Hi all, 
       When i click on any price book, make it so that the Cost field appears as a column between Product Code and List Price. I cannot using wron icon in to  product. why?

Thanks in advance
Hi all, 
           I am beginer of salesforce.Please any one help me  the following code implementation. how to Write Apex class to update all the opportunities close date as today()?

Thanks in advance
Hi all, 
          I am begginer in salesforce.I have added below code in apex class.

"Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Attempt to de-reference a null object: []"
This type   of error.Please help me anyone.
 Apex class:
    AddPSProducts(newOppMap); 

Private void AddPSProducts(Map<Id,Opportunity> newOppMap){
        List<Opportunity> listOppsToAddProduct=new list<Opportunity>();
        List<id> listAccIds=new List<Id>();                
        List<id> listPSIds=new List<Id>();
        for(Opportunity opp:newOppMap.values()){        //Collecting the Accounts ids from the Triggered Opportunities
            if(opp.Project_Sheet__c!= NULL){
                listPSIds.add(opp.Project_Sheet__c);
                listAccIds.add(opp.AccountId);
            }              
        }
        
        //To avoid Unneccessary Executions.
        if(listPSIds.size() == 0) return;
        
        Map<Id,Account> customerMap=new Map<Id,Account>([select id,Delivery_Charged_for__c,Price_Book_ID__c from Account where id IN: listAccIds]);        
        Map<Id,Project_Sheet__c> psMap=new Map<Id,Project_Sheet__c>([SELECT id,Visit__r.Products__c,Site_Contract__c,Arrive__c,Depart__c,Visit__r.Quotation_Reference__c
                                                                     FROM Project_Sheet__c
                                                                     WHERE Id IN: listPSIds]);        
        for(Opportunity newOpp:newOppMap.values()){            
            if(psMap.containskey(newOpp.Project_Sheet__c) ){
                listOppsToAddProduct.add(newOpp);                
            }
        }     
         try{
            if(listOppsToAddProduct.size()>0){
                //Add Project Sheet Sheet Product to Opportunity
                addProduct=new OpportuntiyAutoProducts(psMap);
                System.debug('scMap========??'+scMap);
                listOLIs.addAll(addProduct.AddPSVisitProducts(customerMap,listOppsToAddProduct,prodMap,producsPBEMap,scMap)); 
            }
        }Catch(Exception e){
            String msg=e.getMessage();
            for(Opportunity o:newOppMap.values()){
                o.addError(msg);
          }
        }       
    } 

Advance in Thanks
        
HI All,
         I am Begginer of salesforce,I have  Create one Master field to One object(xxx) to another Object(yyyy).Now I dont want master Detail filed. So,How To Delete that master Field.??

Advance Thanks
How to update some particular Records using Future annotation method .Since I am a beginner can any one give an example with the details. Thanks in advance.
Hi All,
              How to  create an  pop up alert for  whenever the  Custom field (Booked with customer) is amended. 

API NAME : Booked_with_Customers__c(Picklist)

Please any one help me 

Regards,
Bala
Hi all,
              I am begineer of salesforce.please help me the below feature development.  
Write batch to update all the opportunities close date as today() ? 

Thanks in advance 
Bala
Hi all,
        I am beginner  in salesforce.I have struggle in validation rules using trigger.Please make it so that we cannot create a Product with the same Product Code (or)  SAGE Code(custom field) as an existing product. This is similar to the way we cannot create two products with the same name.

Thanks in advance
Hi Everyone,
                      I have create one list views in one  visit custom object. I wish this to show projects that are due to start on the following day
(ACTUAL VISIT DATE = TOMORROW), but have an issue when we have a job starting on Monday (will only come into the view on a Sunday).
Please can you advise if there is a way of including a logic statement to the effect that (ACTUAL VISIT DATE = TOMORROW) or (ACTUAL VISIT DATE = NEXT MONDAY IF TODAY IS FRIDAY)

Thanks in advance

Regards,
Bala
Hi all,
         How to enable Related list setting ?. I am not able to enable  edit/ add the product standard object related list.

Thanks in advance
Hi all, 
       When i click on any price book, make it so that the Cost field appears as a column between Product Code and List Price. I cannot using wron icon in to  product. why?

Thanks in advance
How to update some particular Records using Future annotation method .Since I am a beginner can any one give an example with the details. Thanks in advance.
why we go for future annotations.what is the Relationship between field update and future annotations????
Hi EveryOne,

I have a Extensions on Oppportunity, which sends the Email with two Visualforce Pdf file attachments.
I need to write a test class for it,
As of now, My test coverage is 8%.
Please find my Code below.

Extension Code:
 
//Send email with Multiple attachments, and before sending edit template
public class SendEmail {

    public Account acc;
    public String body { get; set; }    
    Product_EmailTemplates__c template;//Custom settings to read the template, which template to send
    public Opportunity opp { get; set;}
    public String subject { get; set; }
    public String htmlBody {get; set;}
    

    // Create a constructor that populates the Opportunity object
    public SendEmail(ApexPages.StandardController controller) {        
        opp = [Select Id, Name, Email__c, Amount, Contact_Name__c, Account.PersonContactId, Account.id, Product__r.Name, Account.Name, StageName, Tax_Amount__c, Total_after_Tax__c, 
               payment_1_Amount__c, Payment_2_Amount__c, Payment_3_Amount__c, Payment_1_Before_Tax__c, Payment_2_Before_Tax__c, Payment_3_Before_Tax__c, Payment_1_Tax_Amount__c, 
               Payment_2_Tax_Amount__c, Payment_3_Tax_Amount__c, Potential_Number__c,Branch_Name__c, Branch_Name__r.Name, Branch_Name__r.Address_1__c, Branch_Name__r.Address_2__c, Branch_Name__r.City__c, 
               Branch_Name__r.Country__c, Branch_Name__r.Main_Phone_1__c, Branch_Name__r.Main_Phone_2__c, Branch_Name__r.Main_Phone_3__c, Branch_Name__r.Region__c, Branch_Name__r.State__c, 
               Branch_Name__r.Zip_Postal_Code__c, Product__r.Product_Type__c, Admin_Fee__c, Payment_1_plus_Admin_Fee__c
                    from Opportunity where Id = :ApexPages.currentPage().getParameters().get('id')];
              
        EmailTemplate emailTemplate = [SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Id = :getTemplateId(opp.Product__r.Name, opp.Product__r.Product_Type__c)];
    
        htmlBody = emailTemplate.HtmlValue;
        subject = emailTemplate.subject;
    }
    
    //Send the email with two attachments
    public PageReference send() {
        // Define the email
        Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); 
        
        //Send email if Branch not equals to Saudi Arabia and Product type is Standard
        if(opp.Branch_Name__r.Name != 'Saudi Arabia' && opp.Product__r.Product_Type__c == 'Standard'){
            // Reference the attachment page and pass in the Opportunity ID
            PageReference pdf1 =  Page.CCLPdf;//CCLPdf is a Visualforce page
            pdf1.getParameters().put('id',opp.id); 
            pdf1.setRedirect(true);
    
            // Take the PDF content
            Blob b1 = pdf1.getContentAsPDF();
            
            PageReference pdf2 =  Page.ProformaInvoicePdf;//ProformaInvoicePdf is a Visualforce page
            pdf2.getParameters().put('id',opp.id); 
            pdf2.setRedirect(true);
    
            // Take the PDF content
            Blob b2 = pdf2.getContentAsPDF();
    
            // Create the email attachment
            Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
            efa1.setFileName(opp.account.Name+'-CCL.pdf');//set the email attachment name
            efa1.setBody(b1);
            
            Messaging.EmailFileAttachment efa2 = new Messaging.EmailFileAttachment();
            efa2.setFileName(opp.account.Name+'-Invoice.pdf');//set the email attachment name
            efa2.setBody(b2);
            
            // Sets the paramaters of the email
            email.setSubject(subject);//Auto populate the Subject from Template
            email.setHtmlBody(htmlBody);//Auto populate the Body from Template
            //email.setTemplateId('00Xj0000000Yg9k');//getTemplateId(opp.Product__r.Name)
            email.setTargetObjectId(opp.Account.PersonContactId);
            email.setSaveAsActivity(true);
            email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1,efa2});
            StoringAttachments();
        }
        
        //Send email if Branch not equals to Saudi Arabia and Product type is Canada
        if(opp.Branch_Name__r.Name != 'Saudi Arabia' && opp.Product__r.Product_Type__c == 'Canada'){
            // Reference the attachment page and pass in the Opportunity ID
            PageReference pdf3 =  Page.CANCCLPdf;//CANCCLPdf is a Visualforce page
            pdf3.getParameters().put('id',opp.id); 
            pdf3.setRedirect(true);
    
            // Take the PDF content
            Blob b3 = pdf3.getContentAsPDF();
            
            PageReference pdf4 =  Page.ProformaInvoicePdf;//ProformaInvoicePdf is a Visualforce page
            pdf4.getParameters().put('id',opp.id); 
            pdf4.setRedirect(true);
    
            // Take the PDF content
            Blob b4 = pdf4.getContentAsPDF();
    
            // Create the email attachment
            Messaging.EmailFileAttachment efa3 = new Messaging.EmailFileAttachment();
            efa3.setFileName(opp.account.Name+'-CANCCL.pdf');//set the email attachment name
            efa3.setBody(b3);
            
            Messaging.EmailFileAttachment efa4 = new Messaging.EmailFileAttachment();
            efa4.setFileName(opp.account.Name+'-CANInvoice.pdf');//set the email attachment name
            efa4.setBody(b4);
            
            // Sets the paramaters of the email
            email.setSubject(subject);//Auto populate the Subject from Template
            email.setHtmlBody(htmlBody);//Auto populate the Body from Template
            //email.setTemplateId('00Xj0000000Yg9k');//getTemplateId(opp.Product__r.Name)
            email.setTargetObjectId(opp.Account.PersonContactId);
            email.setSaveAsActivity(true);
            email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa3,efa4});
            StoringAttachments();
        }
        
        //Send email if Branch is saudi Arabia and Product type is Standard
        if(opp.Branch_Name__r.Name == 'Saudi Arabia' && opp.Product__r.Product_Type__c == 'Standard'){
            // Reference the attachment page and pass in the Opportunity ID
            PageReference pdf5 =  Page.KSACCLPdf;//KSACCLPdf is a Visualforce page
            pdf5.getParameters().put('id',opp.id); 
            pdf5.setRedirect(true);
    
            // Take the PDF content
            Blob b5 = pdf5.getContentAsPDF();
            
            PageReference pdf6 =  Page.ProformaInvoicePdf;//ProformaInvoicePdf is a Visualforce page
            pdf6.getParameters().put('id',opp.id); 
            pdf6.setRedirect(true);
    
            // Take the PDF content
            Blob b6 = pdf6.getContentAsPDF();
    
            // Create the email attachment
            Messaging.EmailFileAttachment efa5 = new Messaging.EmailFileAttachment();
            efa5.setFileName(opp.account.Name+'-KSACCL.pdf');//set the email attachment name
            efa5.setBody(b5);
            
            Messaging.EmailFileAttachment efa6 = new Messaging.EmailFileAttachment();
            efa6.setFileName(opp.account.Name+'-KSAInvoice.pdf');//set the email attachment name
            efa6.setBody(b6);
            
            // Sets the paramaters of the email
            email.setSubject(subject);//Auto populate the Subject from Template
            email.setHtmlBody(htmlBody);//Auto populate the Body from Template
            //email.setTemplateId('00Xj0000000Yg9k');//getTemplateId(opp.Product__r.Name)
            email.setTargetObjectId(opp.Account.PersonContactId);
            email.setSaveAsActivity(true);
            email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa5,efa6});
            StoringAttachments();
         } 
         
         //Send email if Branch is saudi Arabia and Product type is Canada
         if(opp.Branch_Name__r.Name == 'Saudi Arabia' && opp.Product__r.Product_Type__c == 'Canada'){
            // Reference the attachment page and pass in the Opportunity ID
            PageReference pdf7 =  Page.KSACANCCLPdf;//KSACANCCLPdf is a Visualforce page
            pdf7.getParameters().put('id',opp.id); 
            pdf7.setRedirect(true);
    
            // Take the PDF content
            Blob b7 = pdf7.getContentAsPDF();
            
            PageReference pdf8 =  Page.ProformaInvoicePdf;//ProformaInvoicePdf is a Visualforce page
            pdf8.getParameters().put('id',opp.id); 
            pdf8.setRedirect(true);
    
            // Take the PDF content
            Blob b8 = pdf8.getContentAsPDF();
    
            // Create the email attachment
            Messaging.EmailFileAttachment efa7 = new Messaging.EmailFileAttachment();
            efa7.setFileName(opp.account.Name+'-KSACANCCL.pdf');//set the email attachment name
            efa7.setBody(b7);
            
            Messaging.EmailFileAttachment efa8 = new Messaging.EmailFileAttachment();
            efa8.setFileName(opp.account.Name+'-KSACANInvoice.pdf');//set the email attachment name
            efa8.setBody(b8);
            
            // Sets the paramaters of the email
            email.setSubject(subject);//Auto populate the Subject from Template
            email.setHtmlBody(htmlBody);//Auto populate the Body from Template
            //email.setTemplateId('00Xj0000000Yg9k');//getTemplateId(opp.Product__r.Name)
            email.setTargetObjectId(opp.Account.PersonContactId);
            email.setSaveAsActivity(true);
            email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa7,efa8});
            StoringAttachments();
         } 
    
            // Sends the email
            Messaging.SendEmailResult [] r = 
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email}); 
        
        
        return new PageReference('/'+opp.Id);
    }
    
    //Creating attachments
    public void StoringAttachments() {
        //Send attachments if Branch is India and Product type is Standard
        if((opp.Branch_Name__r.Name == 'India' || opp.Branch_Name__r.Name == 'United Kingdom') && opp.Product__r.Product_Type__c == 'Standard'){
            Attachment myAttach1 = new Attachment();
            myAttach1.ParentId = opp.Account.PersonContactId;
            myAttach1.name = opp.account.Name+'-CCL.pdf';
            PageReference myPdf1 = Page.CCLPdf;
            myAttach1.body = myPdf1.getContentAsPdf();
            insert myAttach1;
            
            Attachment myAttach2 = new Attachment();
            myAttach2.ParentId = opp.Account.PersonContactId;
            myAttach2.name = opp.account.Name+'-Invoice.pdf';
            PageReference myPdf2 = Page.ProformaInvoicePdf;
            myAttach2.body = myPdf2.getContentAsPdf();
            insert myAttach2;
        }
        
        //Send attachments if Branch is India and Product type is Canada
        if((opp.Branch_Name__r.Name == 'India' || opp.Branch_Name__r.Name == 'United Kingdom') && opp.Product__r.Product_Type__c == 'Canada'){
            Attachment myAttach3 = new Attachment();
            myAttach3.ParentId = opp.Account.PersonContactId;
            myAttach3.name = opp.account.Name+'-CANCCL.pdf';
            PageReference myPdf3 = Page.CANCCLPdf;
            myAttach3.body = myPdf3.getContentAsPdf();
            insert myAttach3;
            
            Attachment myAttach4 = new Attachment();
            myAttach4.ParentId = opp.Account.PersonContactId;
            myAttach4.name = opp.account.Name+'-CANInvoice.pdf';
            PageReference myPdf4 = Page.ProformaInvoicePdf;
            myAttach4.body = myPdf4.getContentAsPdf();
            insert myAttach4;
        }
        
        //Send attachments if Branch is saudi Arabia and Product type is Standard
        if(opp.Branch_Name__r.Name == 'Saudi Arabia' && opp.Product__r.Product_Type__c == 'Standard'){
            Attachment myAttach5 = new Attachment();
            myAttach5.ParentId = opp.Account.PersonContactId;
            myAttach5.name = opp.account.Name+'-KSACCL.pdf';
            PageReference myPdf5 = Page.KSACCLPdf;
            myAttach5.body = myPdf5.getContentAsPdf();
            insert myAttach5;
            
            Attachment myAttach6 = new Attachment();
            myAttach6.ParentId = opp.Account.PersonContactId;
            myAttach6.name = opp.account.Name+'-KSAInvoice.pdf';
            PageReference myPdf6 = Page.ProformaInvoicePdf;
            myAttach6.body = myPdf6.getContentAsPdf();
            insert myAttach6;
        }
        
        //Send attachments if Branch is saudi Arabia and Product type is Canada
        if(opp.Branch_Name__r.Name == 'Saudi Arabia' && opp.Product__r.Product_Type__c == 'Canada'){
            Attachment myAttach7 = new Attachment();
            myAttach7.ParentId = opp.Account.PersonContactId;
            myAttach7.name = opp.account.Name+'-KSACANCCL.pdf';
            PageReference myPdf7 = Page.KSACANCCLPdf;
            myAttach7.body = myPdf7.getContentAsPdf();
            insert myAttach7;
            
            Attachment myAttach8 = new Attachment();
            myAttach8.ParentId = opp.Account.PersonContactId;
            myAttach8.name = opp.account.Name+'-KSACANInvoice.pdf';
            PageReference myPdf8 = Page.ProformaInvoicePdf;
            myAttach8.body = myPdf8.getContentAsPdf();
            insert myAttach8;
        }
    } 
    
    //Reads the Template from Custom settings        
    public String getTemplateId(String prodName, String prodType){
       template = [Select Name, Email_Template_Id__c, Product_Type__c from Product_EmailTemplates__c 
                        where Name = : prodName and Product_Type__c = : prodType];
       return template.Email_Template_Id__c;
   }

}

Can anyone please help me to write a Test class for my Extensions?

Thanks In Advance.......
Ranjith