You need to sign in to do that
Don't have an account?
Shruthi MN 88
Write a code
Can you help me with the below code
Note - All Trigger must have a handler.
1. Create Trigger on OpportunityLineItem, on insertion of record GST should be applied.
Create GST (percentage) fields on Product.
Note - All Trigger must have a handler.
1. Create Trigger on OpportunityLineItem, on insertion of record GST should be applied.
Create GST (percentage) fields on Product.
Note - All Trigger must have a handler.
1. Create Trigger on OpportunityLineItem, on insertion of record GST should be applied.
Create GST (percentage) fields on Product.
Can you elaborate more on the ask?
Is there any specific code which you have tried and facing any issues?
public class GSTofproductsHandler {
public static void calculateDiscount(List<OpportunityLineItem> oppItemList){
set<id> prodid = new set<id>();
List<OpportunityLineItem> updopItemlist = new List<OpportunityLineItem>();
for(OpportunityLineItem opItem: oppItemList){
prodid.add(opItem.Product2Id);
}
List<Product2> prodlist = [select id, Discount__c from Product2 where id IN: prodid LIMIT 1];
decimal disc = prodlist[0].Discount__c;
if(prodlist.size() > 0 && disc != null ){
for(OpportunityLineItem opItem:oppItemList ){
OpportunityLineItem item = new OpportunityLineItem();
item.Id = opItem.Id;
item.UnitPrice = opItem.UnitPrice - disc;
updopItemlist.add(item);
}
if(prodlist.GST__c != null && prodlist.GST_Percentage__c != null){
for(Product2 prod : prodlist)
prod.GST__c = disc-prod.GST_Percentage__c ;
else
(if disc == null ){
prod.GST__c = opItem.ListPrice + prod.GST_Percentage__c;
}
}
if(updopItemlist.size() > 0){
update updopItemlist;
}
}
}
}
Show Less
gst.png