function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shruthi MN 19Shruthi MN 19 

Apex Code To add opportunity amount

I have written the below code to add all amount on quota object I am getting below error

User-added image

public with sharing class listopponquota {
     public list<Opportunity> oppList{get;set;}
    public list<quota__c> qutoaList{get;set;}
    public set<ID> oppIds = new set<ID>(); 
    
public void listopponquota()
    {
        String selectedVal ='';
        oppList = new list<Opportunity>();
        qutoaList = new list<quota__c>();
        oppList();
    }
    
    
    
    public pageReference oppList() {
        Id qId = (Id) ApexPages.currentPage().getParameters().get('id');
        system.debug('Id-->'+qId);    
        List<quota__c> quotaList1 = new List<quota__c>();
        List<Opportunity> oppList1 = new List<Opportunity>();
        
        quotaList1 =[select Id, Name,Start_Date__c,End_Date__c,Assign_to_User__c,Actual_Amount__c, OwnerId from quota__c where Id   =: qId Limit 1];
        oppList1 = [Select Id, Name, CloseDate, StageName,OwnerId,Amount From Opportunity where StageName = 'Closed Won'];
        
        system.debug('quotaList1-->'+quotaList1);
        if(quotaList1.size() > 0){
            for(quota__c q : quotaList1){
                
                for(Opportunity opp : oppList1){
                    system.debug('closedDate-->'+opp.CloseDate);
                    if(opp.CloseDate  >=  q.Start_Date__c  && opp.CloseDate <= q.End_Date__c && q.Assign_to_User__c == q.OwnerId){
                        oppList.add(opp);
                        oppIds.add(opp.id);
                    } 
                }                
            }
        }
        for(aggregateresult ag : [SELECT SUM(Amount) sum FROM Opportunity where ID =:oppIds]){
            system.debug('oppList-->'+double.valueof(ag.get('SUM')));
            for(quota__c q : quotaList1){
                if(q.Actual_Amount__c != double.valueof(ag.get('SUM'))){
                    q.Actual_Amount__c = double.valueof(ag.get('SUM'));
                    qutoaList.add(q);
                   
                }
            }
        }
        system.debug('oppList-->'+oppList.size());
        return null;
    }
    
    public void doCallout(){
        system.debug('qutoaList-->'+qutoaList.size());
        if(qutoaList.size()>0){
            Schema.getGlobalDescribe().get('Quota__c').newSObject();
            update qutoaList;
        }
        
    }
}