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
Collen Mayer 6Collen Mayer 6 

Help with Controller to Generate Invoices with Multiple Records

All,
I'm working on a visualforce controller to generate multiple invoices with multiple billing items (Client_Billing__c) per invoice.  Each invoice is tied to one and only one client case (AECaseMgmt__Program_Case__c).  I found some very helpful code that I'm modifying for my needs (I'm still an Apex novice) but need a little help with one line of the code:
 
for (Client_Billing__c cb: mapCaseToResults.get(cc.Id))
The sample code I'm modifying did not have a delcaration for "MapCaseToResults" and I'm having trouble understanding the complex syntax.  Could someone help me with the declaration and perhaps an explanation of the syntax?  Currently my code is getting the error: "Method does not exist or incorrect signature: [List].get(Id)." 

Here is my complete controller code:
public class Invoice {
    public ApexPages.StandardController stdCntrlr {get; set;}
    public List<Client_Billing__c> billingList {get;set;}
    public List<AECaseMgmt__Program_Case__c> CaseQueryResults {get;set;}
    public AECaseMgmt__Program_Case__c Clientcase {get;set;}
    public List<Client_Billing__c> mapCaseToResults {get; set;}
    public list <BillingEntry> caseList {get; set;}
    public Invoice(ApexPages.StandardController controller) {
        stdCntrlr = controller;
     	billingList = [Select id, Date__c, Client_Case__c, Amount__c, Amount_Credit_Debit__c,
                       Transaction_Description__c
                       from Client_Billing__c];
      caseQueryResults = [Select id from AECaseMgmt__Program_Case__c];
      
   for(AECaseMgmt__Program_Case__c cc : CaseQueryResults)
    {
        BillingEntry be = new BillingEntry (cc);
        for (Client_Billing__c cb: mapCaseToResults.get(cc.Id))    
        {
            be.billingList.add(cb);
        }
    }
   
   }


	Public class BillingEntry
    {
        public List<Client_Billing__c> billingList {get;set;}
        Public AECaseMgmt__Program_Case__c Clientcase {get;set;}
        
        public BillingEntry (AECaseMgmt__Program_Case__c cc)
        {
            Clientcase = cc;
            billingList = new list<Client_Billing__c>();
        }
	}
}
I'm very open to learning so any help is much appreciated!

Best,
Collen