You need to sign in to do that
Don't have an account?

Create custom field Discount Percent on Discount object and use in the below code
Create custom field Discount Percent on Discount object and use in the below code:-
public class DiscountTriggerHelper {
public static void beforeTrigApplyDiscount(List<Discount__c> discounts){
for(Discount__c disc : discounts){
If(disc.Discount_Applied__c == false && disc.Amount__c >= 100){
disc.Amount__c = disc.Amount__c + 10;
disc.Discount_Applied__c = true;
}
}
}
}
public class DiscountTriggerHelper {
public static void beforeTrigApplyDiscount(List<Discount__c> discounts){
for(Discount__c disc : discounts){
If(disc.Discount_Applied__c == false && disc.Amount__c >= 100){
disc.Amount__c = disc.Amount__c + 10;
disc.Discount_Applied__c = true;
}
}
}
}
Please use the below test class to cover both triger and class as 100%.
if this solution helps, Please mark it as best answer.
Thanks,