I have an Object called Customer which has related object Purchase, Now every Purchase has Account owner. Under one Customer there can be many purchase from different Account. I need to calculate 3 fields Gross_Commission__c , Debit__c ,Credit__c from purchase under one account owner and create one record of Purchase and attach it back to same Customer. My batch is able to create calcualtions but while attaching it back to record is only creating one record and giving all the calculations under one Account owner. For examle 1 Customer has 15 Purchase in which 10 Purchase has Account 1 as owner and 5 purchase has Account 2 as owner. Now I want to calculate sum of 3 fields from purchase which has same owner and create one single record and attach it back under customer. i.e. there will be 2 new records with calculations of 10 purchase under Account owner 1 and calculation of 5 purchase under account 2 as owner. owner is custom field.
I have an Object called Customer which has related object Purchase. Every Purchase has Account owner. Under one Customer there can be many purchase from different Account. From each purchase I need to create one record of Purchase under one account owner where the Purchase gets attached back to the same Customer. I calculate 3 fields for the purchase and account:
- Gross_Commission__c
- Debit__c
- Credit__c
My batch is able to create calcualtions but while attaching it back to the Purchase record, it is only creating one single record and giving all the calculations under one Account owner.
For example 1 Customer has 15 Purchases in which 10 Purchases has Account 1 as owner and 5 purchase has Account 2 as owner. Now I want to calculate sum of 3 fields from purchase which has same owner and create one single record and attach it back under customer. i.e. there will be 2 new records with calculations of 10 purchases under Account owner 1 and calculation of 5 purchases under account 2 as owner. Also, owner is a custom field.