SHARE
TWEET

Untitled

a guest Jan 20th, 2020 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class DataFix {
  2.     String registrationNumber {get; set;}
  3.     String minBillDraft {get; set;}
  4.     String minBillCorrection {get; set;}
  5. }
  6.  
  7. StaticResource minBillFixJSON = [SELECT Body FROM StaticResource WHERE Name = 'minBillFixJSON' LIMIT 1];
  8. String minBillFixJSONAsString = minBillFixJSON.Body.toString();
  9. List<DataFix> dataFixesList = (List<DataFix>)JSON.deserialize(minBillFixJSONAsString, List<DataFix>.class);
  10.  
  11. Map<String, List<String>> regNumToMinBillMap = new Map<String, List<String>>();
  12. for (DataFix i : dataFixesList) {
  13.     regNumToMinBillMap.put(i.registrationNumber, new List<String>{i.minBillDraft, i.minBillCorrection});
  14. }
  15.  
  16. List<Quote> qotToUpdateList = [
  17.     SELECT Minimum_Bill_Draft__c, Minimum_Bill_Correction__c, Opportunity.Contract.Registration_Number__c
  18.     FROM Quote
  19.     WHERE Opportunity.Contract.Registration_Number__c IN :regNumToMinBillMap.keySet()
  20. ];
  21.  
  22. for (Quote qot : qotToUpdateList) {
  23.     qot.Minimum_Bill_Draft__c = Decimal.valueOf(regNumToMinBillMap.get(qot.Opportunity.Contract.Registration_Number__c)[0]);
  24.     qot.Minimum_Bill_Correction__c = Decimal.valueOf(regNumToMinBillMap.get(qot.Opportunity.Contract.Registration_Number__c)[1]);    
  25. }
  26. update qotToUpdateList;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top