first commit Riabu

This commit is contained in:
2025-11-26 15:57:11 +05:30
parent dd002222ad
commit a5dea75cc3
51 changed files with 14671 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
trigger OpportunityAfterTrigger on Opportunity(after update, after insert){
map<Id, List<Decimal>> accIdOppAmtMap = new map<Id, List<Decimal>>();
List<Account> accListToUpdate = new List<Account>();
for(Opportunity opp : Trigger.new){
accIdOppAmtMap.put(opp.accountId, new List<Decimal>());
}
if(accIdOppAmtMap.size() > 0){
List<Opportunity> oppList = [Select AccountId, Amount From Opportunity Where AccountId IN : accIdOppAmtMap.keySet() Order By Amount DESC] ;
for(Opportunity opp : oppList){
if(accIdOppAmtMap.ContainsKey(opp.AccountId)){
accIdOppAmtMap.get(opp.AccountId).add(opp.Amount);
}
}
}
for(Id accId : accIdOppAmtMap.KeySet()){
Account acc = new Account(Id = accId);
if(accIdOppAmtMap.get(accId).size() > 1){
acc.AnnualRevenue = accIdOppAmtMap.get(accId).get(1);
} else{
acc.AnnualRevenue = accIdOppAmtMap.get(accId).get(0);
}
accListToUpdate.add(acc);
}
update accListToUpdate;
}