Skip to main content
Hi,

Here is my code which update the opportunity total when opportunity line item is deleted.

OpportunityLineItem oppLineItem = [ select id, Quantity, ListPrice, UnitPrice, ProductCode, OpportunityId from OpportunityLineItem where Id = :opportunityLineItemMap.keySet() ];

        Opportunity opp = new Opportunity();

        opp.Id = oppLineItem.OpportunityId;

        Decimal amount = 0 ;

        if (oppLineItem.ProductCode == 'FedEx' || oppLineItem.ProductCode == 'FedEx1' || oppLineItem.ProductCode == 'FedEx2' || oppLineItem.ProductCode == 'EZShipping' )

        {

            opp.ShippingTotal__c = 0.0;

        }

        else if(oppLineItem.ProductCode == 'DiscountAmount')

        {

            opp.discountTotal__c = 0.0;

        }

        else

        {

             opp.SubTotal__c = 0.0;

        }

       update opp;

I need to write a test method for the above code. Please help me

 
3 answers
  1. Jan 29, 2015, 11:08 AM
    Hi Shashikant,

    The was written in a method inside a class and the method is called in trigger. Any idea?

    Thanks,

    Vetri