You need to sign in to do that
Don't have an account?
Deepu161
Can anybody help me to get 100% code coverage for this trigger
trigger PayoffExpenses on Invoice__c (after update) {
Set<id> invids=new Set<id>();
for(Invoice__c i:trigger.new){
if(i.Status__c=='Paid' && trigger.oldmap.get(i.id).status__c!='Paid')
invids.add(i.Id);
}
List<Expense__c> exp=[Select id,Client_Status__c,Invoice__c from Expense__c where
Invoice__c IN : invids and Status__c!='Paid Off'];
for(Expense__c ep:exp)
ep.Client_Status__c='Paid';
update exp;
}
Set<id> invids=new Set<id>();
for(Invoice__c i:trigger.new){
if(i.Status__c=='Paid' && trigger.oldmap.get(i.id).status__c!='Paid')
invids.add(i.Id);
}
List<Expense__c> exp=[Select id,Client_Status__c,Invoice__c from Expense__c where
Invoice__c IN : invids and Status__c!='Paid Off'];
for(Expense__c ep:exp)
ep.Client_Status__c='Paid';
update exp;
}
Great job on the trigger. Real solid. The test class for this is the following. Let me know if there are any issues or if you need some clarification on this. Made some comments and you might need to tweek it a bit for your case.
Hope this helps!
AM