• Steven Wellman 28
  • NEWBIE
  • 85 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 11
    Replies
I wrote this trigger and it works great. I just don't think it's bulkified very well. Any ideas on how best to combine the 2 soql query's into 1?
 
public class OnboardingsComplete {
    String accId;

    public OnboardingsComplete(String accFromTrigger){
        accId = accFromTrigger;
    }

    public void onboardingsCompleteCheck(){
        List<Onboarding__c> onbList = [SELECT Id FROM Onboarding__c WHERE Account__c = :accId 
                                                                      AND Status__c != 'Onboarded'
                                                                      AND Status__c != 'Partially Onboarded'
                                                                      AND Status__c != 'Canceled'
                                                                      LIMIT 1];
        if(onbList.isEmpty()){
            Account acc = [SELECT Id, Onboarding_Completed__c, Onboarding_Status__c FROM Account WHERE Id = :accId];
            if(acc.Onboarding_Completed__c == null){
                acc.Onboarding_Completed__c = Date.today();
            }
            if(acc.Onboarding_Status__c != 'Onboarding Complete'){
                acc.Onboarding_Status__c = 'Onboarding Complete';
            }
            update acc;
        }
    }
}

 
When a lead is created, I pass the info to 2 different classes to check for dupes. I thought it was bulkified but I can't create more than 20-30 leads at a time. I'll hit a SQOL limit if I do. Is there a different/better way to bulkify this?
public class dupeLeadChecker {
	public static void dupeCheck(List<Lead> leadFromTrigger) {
		
		// Get the Id for the data quality queue
		Group dataQualityGroup = [SELECT Id FROM Group WHERE DeveloperName = 'Data_Quality' LIMIT 1];

		// Create a map to hold the Lead and phone
		Map<String, Lead> leadList = new Map<String, Lead>();
		List<Referral_Log__c> referralInsert = new List<Referral_Log__c>();
		List<Lead> leadsToUpdate = new List<Lead>();

		// Loop through all leads in the class
		for(Lead l : leadFromTrigger){
			leadList.put(l.Phone, l);
		}

		// <----------------- Lead ----------------->
		// Check to see if there's a lead match
		List<Lead> matchedLeads = [SELECT Id, Email, Status, Phone, OwnerId, qbdialer__Dials__c, Digital_Marketing_Opt_in__c, Partner_Rep_Notes__c, Button_Referral__c
									 FROM Lead
								    WHERE Phone = :leadList.keySet() 
								      AND OwnerId != :dataQualityGroup.Id
								      AND Status != 'Converted'];

		// If there's a match, pass the lead to the dupeLeadHandler
		if(!matchedLeads.isEmpty()){
			for(Lead lead : matchedLeads){
	            // Get the new lead in the map
	            Lead leadFromPhone = leadList.get(lead.Phone);

	            // Create a log in the referral history
	            Referral_Log__c leadRef = new Referral_Log__c();

	            // Set the values for the referral record
	            leadRef.Digital_Marketing_Opt_in__c = leadFromPhone.Digital_Marketing_Opt_in__c;
	            leadRef.Partner_Rep_Name__c         = leadFromPhone.Partner_Rep_Name__c;
	            leadRef.Referral_Source__c          = leadFromPhone.LeadSource;
	            leadRef.Referring_Partner__c        = leadFromPhone.Partner__c;
	            leadRef.Partner_Rep_Notes__c        = leadFromPhone.Partner_Rep_Notes__c;
	            leadRef.Button_Referral__c          = leadFromPhone.Button_Referral__c;
	            leadRef.Lead__c                     = lead.Id;
	            
	            referralInsert.add(leadRef);

	            // If new lead is button referral, update button referral on old lead
	            if(leadFromPhone.Button_Referral__c == true){
	            	lead.Button_Referral__c = true;
	            }

	            // If new lead has opted in to digital marketing move update the old lead
	            if(leadFromPhone.Digital_Marketing_Opt_in__c == true){
	            	lead.Digital_Marketing_Opt_in__c = true;
	            }

	            // If lead has opted in, or if lead is button referral and status is drip, change to new
	            if((lead.Digital_Marketing_Opt_in__c == true || lead.Button_Referral__c == true) && lead.Status == 'Drip'){
	            	lead.Status = 'New';
	            }

	            // If new lead is from PACO, update PACO field on old lead
	            if(leadFromPhone.PACO__c == true){
	            	lead.PACO__c = true;
	            }

	            // If rep has notes in new lead, append them onto the old lead
	            if(leadFromPhone.Partner_Rep_Notes__c != null){
	            	if(lead.Partner_Rep_Notes__c == null){
	            		lead.Partner_Rep_Notes__c = leadFromPhone.Partner_Rep_Notes__c;
	            	} else {
	            		lead.Partner_Rep_Notes__c = lead.Partner_Rep_Notes__c + ' | Updated notes: ' + leadFromPhone.Partner_Rep_Notes__c;
	            	}
	            }

	            // Check to see if status = Drip
	            if (lead.Status == 'Drip' && lead.qbdialer__Dials__c > 10){
	                // Cut dials in 1/2 and update status to New
	                lead.qbdialer__Dials__c = 5;
	                lead.Status = 'New'; 
	            }
	            leadsToUpdate.add(lead);

	            // Mark new lead as a dupe
	            leadFromPhone.Dupe__c = true;
	            leadFromPhone.OwnerId = dataQualityGroup.Id;
	        }

	        // Update the old leads
	        update leadsToUpdate;
	        // insert the referral log
	        insert referralInsert;
		}
	}
}

 
I'm trying to learn how to write a trigger that calls a class. When trying to deploy I'm getting this error "Trigger does not exist: Trigger"
Here's my Trigger:
trigger MasterOnboardingTrigger on Onboarding__c (
    before insert, after insert, 
    before update, after update, 
    before delete, after delete) {

    if (Trigger.isBefore) {
        if (Trigger.isInsert) {
        // Call class logic here!
        } 
        if (Trigger.isUpdate) {
        // Call class logic here!
        FulfillmentFirst ful = new FulfillmentFirst(Trigger.new);
        }
        if (Trigger.isDelete) {
        // Call class logic here!
        }
    }

    if (Trigger.IsAfter) {
        if (Trigger.isInsert) {
        // Call class logic here!
        } 
        if (Trigger.isUpdate) {
        // Call class logic here!
        }
        if (Trigger.isDelete) {
        // Call class logic here!
        }
    }
}
And here's my class:
public class FulfillmentFirst {
    // This will hold the onboarding record passed by the trigger
    List<Onboarding__c> onbs; 
    

    public FulfillmentFirst (List<Onboarding__c> triggerOnb) {
        onbs  = triggerOnb;
    }

    public void CreateFirstFulfillment(){
        for(Onboarding__c onb : onbs){
            if(onb.Fulfillment_Created__c = false){
                // Engage
                if(onb.Product__c == 'Engage'){
                    Fulfillment__c enFul = new Fulfillment__c();
                    enFul.Name                   = 'Engage First Fulfillment + ' + onb.Account__r.Name;
                    enFul.Status__c            = 'Not Started';
                    enFul.Account__c       = onb.Account__c;
                    enFul.Due_Date__c    = Date.today().addDays(14);
                    enFul.RecordTypeId  = '0121I000000G1dkQAC';
                    insert enFul;
                    onb.Fulfillment_Created__c = true;
                    update onb;
                }

                // Social Ads
                if(onb.Product__c == 'Social Ads'){
                    Fulfillment__c saFul = new Fulfillment__c();
                    saFul.Name                   = 'Social Ads First Fulfillment + ' + onb.Account__r.Name;
                    saFul.Status__c            = 'Not Started';
                    saFul.Account__c       = onb.Account__c;
                    saFul.Due_Date__c   = Date.today().addDays(14);
                    saFul.RecordTypeId = '0121I000000G1dmQAC';
                    insert saFul;
                    onb.Fulfillment_Created__c = true;
                    update onb;
                }

                // Social Posting
                if(onb.Product__c == 'Social Posting'){
                    Fulfillment__c spFul = new Fulfillment__c();
                    spFul.Name                   = 'Social Posting First Fulfillment + ' + onb.Account__r.Name;
                    spFul.Status__c            = 'Not Started';
                    spFul.Account__c       = onb.Account__c;
                    spFul.Due_Date__c   = Date.today().addDays(14);
                    spFul.RecordTypeId = '0121I000000G1doQAC';
                    insert spFul;
                    onb.Fulfillment_Created__c = true;
                    update onb;
                }
            }
        }
    }
}
Any help would be much appreciated.
The issue here is that I'm looking at 2 values - phone number and message (text). I need to do a lookup to find the contact that belongs to the phone number and update a field on the contact with the message associated with that phone number. I'm not sure how to do that. I created the trigger and it works this way, but I know it's a bad practice. Can you help me bulkify this:
for(TwilioSF__Message__c msg : Trigger.new){
        if(msg.TwilioSF__Status__c == 'received'){
            List<Contact> cons = [SELECT Id FROM Contact WHERE MobilePhone = :msg.TwilioSF__From_Number_Unformatted__c];
            for(Contact con : cons){
                con.NewTextMessage__c = true;
                con.TxtMsg__c = msg.TwilioSF__Body__c;

                update con;
            }
        }
    }
Any help is much appreciated.
I've written this scheduable apex class but I can't figure out how to write a test class. 
global class UpdateCSMTeam implements Schedulable {
    
    global void execute(SchedulableContext ctx) {

    // Create a list of the accounts to update
    List<Account> myList = new List<Account>();

    // Create a list of all the customer accounts
    List<Account> accountList = [SELECT Id, Account_Manager__c FROM Account WHERE Type = 'Customer'];

    for (Account acc : accountList){
    	// one
    	if(acc.Account_Manager__c == '0051I0000027OCuQAM') {
    		acc.Onboarding_Specialist__c = '0051I0000029k0yQAA';
    		acc.Product_Specialist__c = '0051I0000027ODJQA2';

    		myList.add(acc);
    	}
    	// two
    	if(acc.Account_Manager__c == '0051I0000029k3sQAA') {
    		acc.Onboarding_Specialist__c = '0051I0000029k0ZQAQ';
    		acc.Product_Specialist__c = '0051I000002Q8XaQAK';

    		myList.add(acc);
    	}
    	// three
    	if(acc.Account_Manager__c == '0051I000002baVoQAI') {
    		acc.Onboarding_Specialist__c = '0051I000002slVdQAI';
    		acc.Product_Specialist__c = '0051I000002QShlQAG';

    		myList.add(acc);
    	}
    	// four
    	if(acc.Account_Manager__c == '0051I000002s0dpQAA') {
    		acc.Onboarding_Specialist__c = '0051I000002QPrUQAW';
    		acc.Product_Specialist__c = '0051I0000027ODOQA2';

    		myList.add(acc);
    	}
    	// five
    	if(acc.Account_Manager__c == '0051I000002QPrTQAW') {
    		acc.Onboarding_Specialist__c = '0051I000002s0dqQAA';
    		acc.Product_Specialist__c = '0051I000002stE6QAI';

    		myList.add(acc);
    	}
    }

    update myList;

    }
}
Any help appreciated!
Not sure how to bulkify this trigger:
trigger OppPaymentCollected on Account (after update) {

	List<Opportunity> oppsToUpdate = new List<Opportunity>();

	for (Account acc : Trigger.new) {

		// Get trigger.old and trigger.new versions of the record
		Account oldAcc = Trigger.oldMap.get(acc.Id);
		Account newAcc = Trigger.newMap.get(acc.Id);

		// Create variable to store value to see if payment date has changed.
		Boolean newPayment = oldAcc.Most_Recent_Payment__c != newAcc.Most_Recent_Payment__c;

		// Query and find all Oppos that are 'Sold'
		if(newPayment) {
			List<Opportunity> opps = [SELECT Id, Date_Customer_Paid__c FROM Opportunity WHERE StageName = 'Sold' 
																						  AND Date_Customer_Paid__c = null 
																						  AND AccountId = :acc.Id];

			for (Opportunity oppty : opps) {
				oppty.Date_Customer_Paid__c = Date.Today();
				oppsToUpdate.add(oppty);
			}
		}
	}

	update oppsToUpdate;
}
Any help appreciated.
This task isn't creating and I'm not sure why. I know it isn't bulkified. Any help is appreciated.
 
trigger QBRTasks on Task (after update) {

	// Get the record type Id for QBR tasks
	Task qbrTaskRecordTypeId = [SELECT Id 
								  FROM Task 
								 WHERE RecordType.DeveloperName = 'Executive_Business_Review' 
								 LIMIT 1];

	for (Task myTask : Trigger.new) {

		Account acc = [SELECT Id, 
							  Customer_Segment__c, 
							  Task_Counter__c, 
							  Account_Manager__c, 
							  Name, 
							  Type 
						 FROM Account 
						WHERE Id = :myTask.AccountId
						LIMIT 1];

		// Get trigger.old and trigger.new versions of the record
		Task oldTask = Trigger.oldMap.get(myTask.Id);
		Task newTask = Trigger.newMap.get(myTask.Id);

		// Compare statuses on old and new triggers to see if it changed to Completed
		Boolean taskCompleted = (oldTask.Status != 'Completed' && newTask.Status == 'Completed');

		// See if task is completed and a QBR/check-in task
		if (myTask.RecordTypeId == qbrTaskRecordTypeId.Id && taskCompleted && acc.Type == 'Customer') {

			// High Touch - 2nd Check-in task
			if (acc.Customer_Segment__c == 'High Touch' && acc.Task_Counter__c == 1) {
				Task ht2 = new Task();

				ht2.ActivityDate = date.today() + 10;
				ht2.OwnerId      = acc.Account_Manager__c;
				ht2.Priority     = 'Normal';
				ht2.RecordTypeId = qbrTaskRecordTypeId.Id;
				ht2.Status       = 'Not Started';
				ht2.Subject      = '2nd Check-in Call + ' + acc.Name;
				ht2.WhatId       = acc.Id;
				insert ht2;

				acc.Task_Counter__c = 2;
				update acc;
			}

			// Mid Touch - 2nd Check-in task
			if (acc.Customer_Segment__c == 'Mid Touch' && acc.Task_Counter__c == 1) {
				Task mt2 = new Task();

				mt2.ActivityDate = date.today() + 14;
				mt2.OwnerId      = acc.Account_Manager__c;
				mt2.Priority     = 'Normal';
				mt2.RecordTypeId = qbrTaskRecordTypeId.Id;
				mt2.Status       = 'Not Started';
				mt2.Subject      = '2nd Check-in Call + ' + acc.Name;
				mt2.WhatId       = acc.Id;
				insert mt2;

				acc.Task_Counter__c = 2;
				update acc;
			}

			// High Touch - 3rd Check-in task
			if (acc.Customer_Segment__c == 'High Touch' && acc.Task_Counter__c == 2) {
				Task ht3 = new Task();

				ht3.ActivityDate = date.today() + 10;
				ht3.OwnerId      = acc.Account_Manager__c;
				ht3.Priority     = 'Normal';
				ht3.RecordTypeId = qbrTaskRecordTypeId.Id;
				ht3.Status       = 'Not Started';
				ht3.Subject      = '3rd Check-in Call + ' + acc.Name;
				ht3.WhatId       = acc.Id;
				insert ht3;

				acc.Task_Counter__c = 3;
				update acc;
			}

			// Mid Touch = 3+ QBRs
			if (acc.Customer_Segment__c == 'Mid Touch' && acc.Task_Counter__c >= 2) {
				Task mt3 = new Task();

				mt3.ActivityDate = date.today() + 180;
				mt3.OwnerId      = acc.Account_Manager__c;
				mt3.Priority     = 'Normal';
				mt3.RecordTypeId = qbrTaskRecordTypeId.Id;
				mt3.Status       = 'Not Started';
				mt3.Subject      = 'Semi-annual QBR + ' + acc.Name;
				mt3.WhatId       = acc.Id;
				insert mt3;

				acc.Task_Counter__c = acc.Task_Counter__c;
				update acc;
			}


			// High Touch - 4th QBR task
			if (acc.Customer_Segment__c == 'High Touch' && acc.Task_Counter__c == 3) {
				Task ht4 = new Task();

				ht4.ActivityDate = date.today() + 60;
				ht4.OwnerId      = acc.Account_Manager__c;
				ht4.Priority     = 'Normal';
				ht4.RecordTypeId = qbrTaskRecordTypeId.Id;
				ht4.Status       = 'Not Started';
				ht4.Subject      = 'QBR + ' + acc.Name;
				ht4.WhatId       = acc.Id;
				insert ht4;

				acc.Task_Counter__c = 4;
				update acc;
			}

			// High Touch - 5+ QBR Tasks
			if (acc.Customer_Segment__c == 'High Touch' && acc.Task_Counter__c >= 4) {
				Task ht5 = new Task();

				ht5.ActivityDate = date.today() + 90;
				ht5.OwnerId      = acc.Account_Manager__c;
				ht5.Priority     = 'Normal';
				ht5.RecordTypeId = qbrTaskRecordTypeId.Id;
				ht5.Status       = 'Not Started';
				ht5.Subject      = 'QBR + ' + acc.Name;
				ht5.WhatId       = acc.Id;
				insert ht5;

				acc.Task_Counter__c = acc.Task_Counter__c + 1;
				update acc;
			}

		}
	}

}

 
How would you bulkify this trigger? I have a SOQL query in a loop and understand that to be a no no. Appreciate any help.
trigger CreateOnboardings on Zuora__SubscriptionRatePlan__c (before insert) {

	for (Zuora__SubscriptionRatePlan__c mysub : Trigger.new){

		Account myAccount = [SELECT Id, OwnerId, Name, Local_Listings__c, Reviews__c, LMEL__c, Social_Ads__c, Social_Posting__c, SEO__c, Website_Product__c FROM Account WHERE Id = :mysub.Zuora__Account__c LIMIT 1];

		// Local Marketing Essentials Lite
		if (mysub.Name.contains('Local Marketing Essentials Lite')){
		/*	Onboarding__c onb = new Onboarding__c();
			onb.Account__c = ________;
			onb.Name = 'Local Marketing Essentials Lite + ' + ________;
			onb.RecordTypeId = '0121I000000Fk7BQAS';
			onb.Sales_Rep__c = ________;*/
			myAccount.LMEL__c = true;
		}

		// Marketing Essentials Pro
		if (mysub.Name.contains('Marketing Essentials Pro')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'Local Listings + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000Fk7BQAS';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.Local_Listings__c = true;

			insert onb;
		}

		// Local Listings
		if (mysub.Name.contains('Local Listings Pro')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'Local Listings + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000Fk7BQAS';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.Local_Listings__c = true;

			insert onb;
		}

		// Engage
		if (mysub.Name.contains('Engage')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'Engage + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000FkMBQA0';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.Engage__c = true;

			insert onb;
		}

		// Reviews
		if (mysub.Name.contains('Reviews')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'Reviews + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000FkM6QAK';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.Reviews__c = true;

			insert onb;
		}

		// SEO
		if (mysub.Name.contains('SEO')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'SEO + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000FkMVQA0';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.SEO__c = true;

			insert onb;
		}

		// Social Ads
		if (mysub.Name.contains('Social Ads')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'Social Ads + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000FkMLQA0';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.Social_Ads__c = true;

			insert onb;
		}

		// Social Posting
		if (mysub.Name.contains('Social Posting')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'Social Posting + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000FkMQQA0';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.Social_Posting__c = true;

			insert onb;
		}

		// Website
		if (mysub.Name.contains('Website')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'Website + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000FkMGQA0';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.Website_Product__c = true;

			insert onb;
		}
		update myAccount;
	}

}

 
trigger PaymentProcessed on Zuora__ZInvoice__c (before update) {

	for (Zuora__ZInvoice__c inv : Trigger.new) {

		if (inv.Zuora__PaymentAmount__c > 0) {
			List<Account> accs = [SELECT Id,
										 Payment_Processed__c,
										 Payment_Collected__c,
										 Most_Recent_Payment__c
									FROM Account
								   WHERE Id = :inv.Zuora__Account__c];

			for (Account acc : accs) {
				if (acc.Payment_Collected__c == null) {
					acc.Payment_Processed__c = true;
					acc.Payment_Collected__c = Date.today();
					acc.Most_Recent_Payment__c = Date.today();
				} else {
					acc.Most_Recent_Payment__c = Date.today();
				}

			update accs;
			}
		}
	}
}

 
I've built this and I'm not sure why my first system.asserEquals is failing. The records don't seem to be updating. Thanks for any help.
Trigger
trigger CommissionsOnQCD on zqu__QuoteChargeDetail__c (before insert, before update) {
	
    List<zqu__QuoteChargeDetail__c> quoteCharges = [SELECT Id,
                                                    	   Name,
                                                           zqu__MRR__c,
                                                    	   zqu__BillingTotal__c
                                                      FROM zqu__QuoteChargeDetail__c
                                                     WHERE Id IN :Trigger.new];

    List<zqu__QuoteChargeDetail__c> updateQuoteCharges = new List<zqu__QuoteChargeDetail__c>();
    
    for (zqu__QuoteChargeDetail__c charges : quoteCharges) {
        
        // Standard products
        if (!charges.Name.contains('SEO')          && !charges.Name.contains('Social Ads') &&
            !charges.Name.contains('One Time Fee') && !charges.Name.contains('Setup Fee')
                                                           && charges.zqu__MRR__c != null){
                
            // Calculate PAR
            charges.PAR__c = charges.zqu__MRR__c * 12 * 0.2;

            
            // Calculate FL Commission
            if (charges.Name.contains('Annual')) {
                charges.FL_Commission__c = (charges.zqu__MRR__c * 12 * 0.2);
            } else {
                charges.FL_Commission__c = (charges.zqu__MRR__c * 12 * 0.15);
            }
            updateQuoteCharges.add(charges);
        }

        // SEO/Social Ads - non-standard products
		if ((charges.Name.contains('SEO') || charges.Name.contains('Social Ads')) && !charges.Name.contains('One Time Fee') 
            							          && !charges.Name.contains('Setup Fee')  && charges.zqu__MRR__c != null){
                
            // Calculate PAR
            charges.PAR__c = charges.zqu__MRR__c * 12 * 0.2 * 0.4;
            
            // Calculate FL Commission
            if (charges.Name.contains('Annual')) {
                charges.FL_Commission__c = (charges.zqu__MRR__c * 12 * 0.2 * 0.4);
            } else {
                charges.FL_Commission__c = (charges.zqu__MRR__c * 12 * 0.15 * 0.4);
            }
            updateQuoteCharges.add(charges);
        }

        // One Time Fees
        if (charges.Name.contains('One Time Fee') && charges.zqu__BillingTotal__c != null) {
            
            // Calculate PAR
            charges.PAR__c = charges.zqu__BillingTotal__c * 0.15;
            
            // Calculate FL Commission
            charges.FL_Commission__c = charges.zqu__BillingTotal__c * 0.15;
            updateQuoteCharges.add(charges);
        }

        // Setup fees
        if (charges.Name.contains('Setup Fee') && charges.zqu__BillingTotal__c != null) {
            charges.Setup_Fees__c = charges.zqu__BillingTotal__c;
            updateQuoteCharges.add(charges);
        }
    }
    update updateQuoteCharges;
}
Here's the Test Class:
@isTest
private class CommissionsOnQCDTest {

	@isTest static void createAccountContactOpp() {
		// Create Account 
		Account acc = New Account();
		acc.Name = '1234567890987654321';

		insert acc;

		// Create Contact
		Contact myCon = New Contact();
		myCon.FirstName = 'Steve';
		myCon.LastName  = 'Welderbeast';
		myCon.Email     = 'apextest@gmail.com';
		myCon.AccountId = acc.Id;

		insert myCon;

		// Create Opportunity
		Opportunity opp = New Opportunity();
		opp.Name = 'test opp';
		opp.AccountId = acc.Id;
		opp.CloseDate = Date.today();
		opp.StageName = 'Discovery';

		insert opp;

		// Create a quote
		zqu__Quote__c myQuote = New zqu__Quote__c();
		myQuote.zqu__Account__c = acc.Id;
		myQuote.Name = 'One';

		insert myQuote;

		// Create Annual - Standard
		zqu__QuoteChargeDetail__c quoteAnnualStandard = New zqu__QuoteChargeDetail__c();
		quoteAnnualStandard.Name = 'Marketing Essentials - Annual Service Fee';
		quoteAnnualStandard.zqu__MRR__c = 100;
		quoteAnnualStandard.zqu__Quote__c = myQuote.Id;

		insert quoteAnnualStandard;

		zqu__QuoteChargeDetail__c zQuote = [SELECT PAR__c,
												   FL_Commission__c,
												   Setup_Fees__c
											  FROM zqu__QuoteChargeDetail__c
											 WHERE Id = :quoteAnnualStandard.Id];

		system.assertEquals(240,zQuote.PAR__c);
		system.assertEquals(240,zQuote.FL_Commission__c);
		system.assertEquals(null,zQuote.Setup_Fees__c);

		// Create Annual - Non-Standard
		zqu__QuoteChargeDetail__c quoteAnnualNonStandard = New zqu__QuoteChargeDetail__c();
		quoteAnnualNonStandard.Name = 'SEO - Annual Service Fee';
		quoteAnnualNonStandard.zqu__MRR__c = 100;
		quoteAnnualNonStandard.zqu__Quote__c = myQuote.Id;

		insert quoteAnnualNonStandard;

		zqu__QuoteChargeDetail__c zQuote2 = [SELECT PAR__c,
												   FL_Commission__c,
												   Setup_Fees__c
											  FROM zqu__QuoteChargeDetail__c
											 WHERE Id = :quoteAnnualNonStandard.Id];

		system.assertEquals(96,zQuote2.PAR__c);
		system.assertEquals(96,zQuote2.FL_Commission__c);
		system.assertEquals(null,zQuote2.Setup_Fees__c);

		// Create Monthly - Standard
		zqu__QuoteChargeDetail__c quoteMonthlyStandard = New zqu__QuoteChargeDetail__c();
		quoteMonthlyStandard.Name = 'Engage - Monthly Service Fee';
		quoteMonthlyStandard.zqu__MRR__c = 100;
		quoteMonthlyStandard.zqu__Quote__c = myQuote.Id;

		insert quoteMonthlyStandard;

		zqu__QuoteChargeDetail__c zQuote3 = [SELECT PAR__c,
												   FL_Commission__c,
												   Setup_Fees__c
											  FROM zqu__QuoteChargeDetail__c
											 WHERE Id = :quoteMonthlyStandard.Id];

		system.assertEquals(240,zQuote3.PAR__c);
		system.assertEquals(180,zQuote3.FL_Commission__c);
		system.assertEquals(null,zQuote3.Setup_Fees__c);

		// Create Monthly - Non-Standard
		zqu__QuoteChargeDetail__c quoteMonthlyNonStandard = New zqu__QuoteChargeDetail__c();
		quoteMonthlyNonStandard.Name = 'SEO - Monthly Service Fee';
		quoteMonthlyNonStandard.zqu__MRR__c = 100;
		quoteMonthlyNonStandard.zqu__Quote__c = myQuote.Id;

		insert quoteMonthlyNonStandard;

		zqu__QuoteChargeDetail__c zQuote4 = [SELECT PAR__c,
												   FL_Commission__c,
												   Setup_Fees__c
											  FROM zqu__QuoteChargeDetail__c
											 WHERE Id = :quoteMonthlyNonStandard.Id];

		system.assertEquals(96,zQuote4.PAR__c);
		system.assertEquals(72,zQuote4.FL_Commission__c);
		system.assertEquals(null,zQuote4.Setup_Fees__c);

		// Create One Time Fee
		zqu__QuoteChargeDetail__c quoteOneTimeFee = New zqu__QuoteChargeDetail__c();
		quoteOneTimeFee.Name = 'SEO - One Time Fee';
		quoteOneTimeFee.zqu__MRR__c = 0;
		quoteOneTimeFee.zqu__BillingTotal__c = 100;
		quoteOneTimeFee.zqu__Quote__c = myQuote.Id;

		insert quoteOneTimeFee;

		zqu__QuoteChargeDetail__c zQuote5 = [SELECT PAR__c,
												   FL_Commission__c,
												   Setup_Fees__c
											  FROM zqu__QuoteChargeDetail__c
											 WHERE Id = :quoteOneTimeFee.Id];

		system.assertEquals(15,zQuote5.PAR__c);
		system.assertEquals(15,zQuote5.FL_Commission__c);
		system.assertEquals(null,zQuote5.Setup_Fees__c);


		// Create Setup Fee
		zqu__QuoteChargeDetail__c quoteSetupFee = New zqu__QuoteChargeDetail__c();
		quoteSetupFee.Name = 'SEO - Setup Fee';
		quoteSetupFee.zqu__MRR__c = 0;
		quoteSetupFee.zqu__BillingTotal__c = 100;
		quoteSetupFee.zqu__Quote__c = myQuote.Id;

		insert quoteSetupFee;

		zqu__QuoteChargeDetail__c zQuote6 = [SELECT PAR__c,
												   FL_Commission__c,
												   Setup_Fees__c
											  FROM zqu__QuoteChargeDetail__c
											 WHERE Id = :quoteSetupFee.Id];

		system.assertEquals(null,zQuote6.PAR__c);
		system.assertEquals(null,zQuote6.FL_Commission__c);
		system.assertEquals(100,zQuote6.Setup_Fees__c);


	}

}




 
I'm trying to update a field on the account when a child record is deleted but the field isn't updating. Here's the trigger:
trigger RatePlanDeletion on Zuora__SubscriptionRatePlan__c (after delete) {

	// Make a list of the deleted subscription rate plans
	List<Zuora__SubscriptionRatePlan__c> deletedRatePlan = [SELECT Id,
Name,
Zuora__Account__r.Local_Listings__c,
Zuora__Account__r.Engage__c,
Zuora__Account__r.SEO__c,
Zuora__Account__r.Social_Ads__c,
Zuora__Account__r.Social_Posting__c,
Zuora__Account__r.Website_Product__c
Zuora__SubscriptionRatePlan__c
IN :Trigger.old];

	List<Zuora__SubscriptionRatePlan__c> newRatePlan = new List<Zuora__SubscriptionRatePlan__c>();

	for (Zuora__SubscriptionRatePlan__c sub : deletedRatePlan) {

		// Get Trigger.new version of the rate plan
		Zuora__SubscriptionRatePlan__c subInTriggerNew = Trigger.newMap.get(sub.Id);		
		
		// Local Listings
		if ((sub.Name.contains('Marketing Essentials') || sub.Name.contains('Local Listings'))) {
			subInTriggerNew.Zuora__Account__r.Local_Listings__c = false;
		}

		// Engage 
		if (sub.Name.contains('Engage')) {
			subInTriggerNew.Zuora__Account__r.Engage__c = false;
		}

		// Reviews
		if (sub.Name.contains('Review')) {
			subInTriggerNew.Zuora__Account__r.Reviews__c = false;
		}

		// SEO
		if (sub.Name.contains('SEO')) {
			subInTriggerNew.Zuora__Account__r.SEO__c = false;
		}

		// Social Ads
		if (sub.Name.contains('Social Ads')) {
			subInTriggerNew.Zuora__Account__r.Social_Ads__c = false;
		}

		// Social Posting
		if (sub.Name.contains('Social Posting')) {
			subInTriggerNew.Zuora__Account__r.Social_Posting__c = false;
		}

		// Website
		if (sub.Name.contains('Website')) {
			subInTriggerNew.Zuora__Account__r.Website_Product__c = false;
		}
		
		newRatePlan.add(subInTriggerNew);
	}
	update newRatePlan;
}
I appreciate any help I can get.
I'm trying to mark a checkbox as false on the account when a child record is deleted but the field isn't updating. Here's my code:
trigger RatePlanDeletion on Zuora__SubscriptionRatePlan__c (after delete) {
	// Make a list of the deleted subscription rate plans
	List<Zuora__SubscriptionRatePlan__c> deletedRatePlan = [SELECT Id,
               Name,
               Zuora__Account__r.Local_Listings__c,
               Zuora__Account__r.Engage__c,
               Zuora__Account__r.SEO__c,
               Zuora__Account__r.Social_Ads__c,
               Zuora__Account__r.Social_Posting__c,
               Zuora__Account__r.Website_Product__c
               Zuora__SubscriptionRatePlan__c
               WHERE Id IN :Trigger.old];

	for (Zuora__SubscriptionRatePlan__c sub : deletedRatePlan) {

		// Get Trigger.new version of the rate plan
		Zuora__SubscriptionRatePlan__c subInTriggerNew = Trigger.newMap.get(sub.Id);		
		
		// Local Listings
		if ((sub.Name.contains('Marketing Essentials') || sub.Name.contains('Local Listings'))) {
			subInTriggerNew.Zuora__Account__r.Local_Listings__c = false;
		}

		// Engage 
		if (sub.Name.contains('Engage')) {
			subInTriggerNew.Zuora__Account__r.Engage__c = false;
		}

		// Reviews
		if (sub.Name.contains('Review')) {
			subInTriggerNew.Zuora__Account__r.Reviews__c = false;
		}

		// SEO
		if (sub.Name.contains('SEO')) {
			subInTriggerNew.Zuora__Account__r.SEO__c = false;
		}

		// Social Ads
		if (sub.Name.contains('Social Ads')) {
			subInTriggerNew.Zuora__Account__r.Social_Ads__c = false;
		}

		// Social Posting
		if (sub.Name.contains('Social Posting')) {
			subInTriggerNew.Zuora__Account__r.Social_Posting__c = false;
		}

		// Website
		if (sub.Name.contains('Website')) {
			subInTriggerNew.Zuora__Account__r.Website_Product__c = false;
		}
	}
}
Sorry, I'm new to working with deleted records and not sure what I'm missing. Thanks in advance for your help!
I'm trying to write a trigger that looks for matching leads:
trigger DedupLeadLead on Lead (before insert) {

        // Get the data quality queue record ready for future use
        List<Group> dataQualityGroups = [SELECT Id
                                          FROM Group
                                         WHERE DeveloperName = 'Data_Quality'
                                         LIMIT 1];

        for (Lead myLead : Trigger.new) {
            if (myLead.Email != null) {

            // Searching for matching leads
            List<Lead> matchingLeads = [SELECT Id,
                                               FirstName,
                                               LastName,
                                               Company
                                          FROM Lead
                                         WHERE Company = :myLead.Company
                                        ];

            System.debug(matchingLeads.size() + ' lead(s) found.');

            // If matches are found...
            if (!matchingLeads.isEmpty()) {

                // Assign the lead to the data quality queue
                if (!dataQualityGroups.isEmpty()) {
                    myLead.OwnerId = dataQualityGroups.get(0).Id;
                }
                

                // Add the dupe contact ID's into the lead description
                String dupeLeadsMessage = 'Duplicate lead(s) found:\n';
                for (Lead matchingLead : matchingLeads) {
                    dupeLeadsMessage += matchingLead.FirstName + ' '
                                         + matchingLead.LastName + ', '
                                         + matchingLead.Company + ' ('
                                         + matchingLead.Id + ')\n';    
                }
                if (myLead.Description != null) {
                    dupeLeadsMessage += '\n' + myLead.Description;
                }
                
                myLead.Description = dupeLeadsMessage;
            }
        }
    }
}
I'm trying to learn how to write a trigger that calls a class. When trying to deploy I'm getting this error "Trigger does not exist: Trigger"
Here's my Trigger:
trigger MasterOnboardingTrigger on Onboarding__c (
    before insert, after insert, 
    before update, after update, 
    before delete, after delete) {

    if (Trigger.isBefore) {
        if (Trigger.isInsert) {
        // Call class logic here!
        } 
        if (Trigger.isUpdate) {
        // Call class logic here!
        FulfillmentFirst ful = new FulfillmentFirst(Trigger.new);
        }
        if (Trigger.isDelete) {
        // Call class logic here!
        }
    }

    if (Trigger.IsAfter) {
        if (Trigger.isInsert) {
        // Call class logic here!
        } 
        if (Trigger.isUpdate) {
        // Call class logic here!
        }
        if (Trigger.isDelete) {
        // Call class logic here!
        }
    }
}
And here's my class:
public class FulfillmentFirst {
    // This will hold the onboarding record passed by the trigger
    List<Onboarding__c> onbs; 
    

    public FulfillmentFirst (List<Onboarding__c> triggerOnb) {
        onbs  = triggerOnb;
    }

    public void CreateFirstFulfillment(){
        for(Onboarding__c onb : onbs){
            if(onb.Fulfillment_Created__c = false){
                // Engage
                if(onb.Product__c == 'Engage'){
                    Fulfillment__c enFul = new Fulfillment__c();
                    enFul.Name                   = 'Engage First Fulfillment + ' + onb.Account__r.Name;
                    enFul.Status__c            = 'Not Started';
                    enFul.Account__c       = onb.Account__c;
                    enFul.Due_Date__c    = Date.today().addDays(14);
                    enFul.RecordTypeId  = '0121I000000G1dkQAC';
                    insert enFul;
                    onb.Fulfillment_Created__c = true;
                    update onb;
                }

                // Social Ads
                if(onb.Product__c == 'Social Ads'){
                    Fulfillment__c saFul = new Fulfillment__c();
                    saFul.Name                   = 'Social Ads First Fulfillment + ' + onb.Account__r.Name;
                    saFul.Status__c            = 'Not Started';
                    saFul.Account__c       = onb.Account__c;
                    saFul.Due_Date__c   = Date.today().addDays(14);
                    saFul.RecordTypeId = '0121I000000G1dmQAC';
                    insert saFul;
                    onb.Fulfillment_Created__c = true;
                    update onb;
                }

                // Social Posting
                if(onb.Product__c == 'Social Posting'){
                    Fulfillment__c spFul = new Fulfillment__c();
                    spFul.Name                   = 'Social Posting First Fulfillment + ' + onb.Account__r.Name;
                    spFul.Status__c            = 'Not Started';
                    spFul.Account__c       = onb.Account__c;
                    spFul.Due_Date__c   = Date.today().addDays(14);
                    spFul.RecordTypeId = '0121I000000G1doQAC';
                    insert spFul;
                    onb.Fulfillment_Created__c = true;
                    update onb;
                }
            }
        }
    }
}
Any help would be much appreciated.
I've written this scheduable apex class but I can't figure out how to write a test class. 
global class UpdateCSMTeam implements Schedulable {
    
    global void execute(SchedulableContext ctx) {

    // Create a list of the accounts to update
    List<Account> myList = new List<Account>();

    // Create a list of all the customer accounts
    List<Account> accountList = [SELECT Id, Account_Manager__c FROM Account WHERE Type = 'Customer'];

    for (Account acc : accountList){
    	// one
    	if(acc.Account_Manager__c == '0051I0000027OCuQAM') {
    		acc.Onboarding_Specialist__c = '0051I0000029k0yQAA';
    		acc.Product_Specialist__c = '0051I0000027ODJQA2';

    		myList.add(acc);
    	}
    	// two
    	if(acc.Account_Manager__c == '0051I0000029k3sQAA') {
    		acc.Onboarding_Specialist__c = '0051I0000029k0ZQAQ';
    		acc.Product_Specialist__c = '0051I000002Q8XaQAK';

    		myList.add(acc);
    	}
    	// three
    	if(acc.Account_Manager__c == '0051I000002baVoQAI') {
    		acc.Onboarding_Specialist__c = '0051I000002slVdQAI';
    		acc.Product_Specialist__c = '0051I000002QShlQAG';

    		myList.add(acc);
    	}
    	// four
    	if(acc.Account_Manager__c == '0051I000002s0dpQAA') {
    		acc.Onboarding_Specialist__c = '0051I000002QPrUQAW';
    		acc.Product_Specialist__c = '0051I0000027ODOQA2';

    		myList.add(acc);
    	}
    	// five
    	if(acc.Account_Manager__c == '0051I000002QPrTQAW') {
    		acc.Onboarding_Specialist__c = '0051I000002s0dqQAA';
    		acc.Product_Specialist__c = '0051I000002stE6QAI';

    		myList.add(acc);
    	}
    }

    update myList;

    }
}
Any help appreciated!
How would you bulkify this trigger? I have a SOQL query in a loop and understand that to be a no no. Appreciate any help.
trigger CreateOnboardings on Zuora__SubscriptionRatePlan__c (before insert) {

	for (Zuora__SubscriptionRatePlan__c mysub : Trigger.new){

		Account myAccount = [SELECT Id, OwnerId, Name, Local_Listings__c, Reviews__c, LMEL__c, Social_Ads__c, Social_Posting__c, SEO__c, Website_Product__c FROM Account WHERE Id = :mysub.Zuora__Account__c LIMIT 1];

		// Local Marketing Essentials Lite
		if (mysub.Name.contains('Local Marketing Essentials Lite')){
		/*	Onboarding__c onb = new Onboarding__c();
			onb.Account__c = ________;
			onb.Name = 'Local Marketing Essentials Lite + ' + ________;
			onb.RecordTypeId = '0121I000000Fk7BQAS';
			onb.Sales_Rep__c = ________;*/
			myAccount.LMEL__c = true;
		}

		// Marketing Essentials Pro
		if (mysub.Name.contains('Marketing Essentials Pro')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'Local Listings + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000Fk7BQAS';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.Local_Listings__c = true;

			insert onb;
		}

		// Local Listings
		if (mysub.Name.contains('Local Listings Pro')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'Local Listings + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000Fk7BQAS';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.Local_Listings__c = true;

			insert onb;
		}

		// Engage
		if (mysub.Name.contains('Engage')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'Engage + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000FkMBQA0';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.Engage__c = true;

			insert onb;
		}

		// Reviews
		if (mysub.Name.contains('Reviews')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'Reviews + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000FkM6QAK';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.Reviews__c = true;

			insert onb;
		}

		// SEO
		if (mysub.Name.contains('SEO')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'SEO + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000FkMVQA0';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.SEO__c = true;

			insert onb;
		}

		// Social Ads
		if (mysub.Name.contains('Social Ads')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'Social Ads + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000FkMLQA0';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.Social_Ads__c = true;

			insert onb;
		}

		// Social Posting
		if (mysub.Name.contains('Social Posting')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'Social Posting + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000FkMQQA0';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.Social_Posting__c = true;

			insert onb;
		}

		// Website
		if (mysub.Name.contains('Website')){
			Onboarding__c onb = new Onboarding__c();
			onb.Account__c = myAccount.Id;
			onb.Name = 'Website + ' + myAccount.Name;
			onb.RecordTypeId = '0121I000000FkMGQA0';
			onb.Sales_Rep__c = myAccount.OwnerId;
			onb.Status__c = 'Not Started';
			myAccount.Website_Product__c = true;

			insert onb;
		}
		update myAccount;
	}

}

 
trigger PaymentProcessed on Zuora__ZInvoice__c (before update) {

	for (Zuora__ZInvoice__c inv : Trigger.new) {

		if (inv.Zuora__PaymentAmount__c > 0) {
			List<Account> accs = [SELECT Id,
										 Payment_Processed__c,
										 Payment_Collected__c,
										 Most_Recent_Payment__c
									FROM Account
								   WHERE Id = :inv.Zuora__Account__c];

			for (Account acc : accs) {
				if (acc.Payment_Collected__c == null) {
					acc.Payment_Processed__c = true;
					acc.Payment_Collected__c = Date.today();
					acc.Most_Recent_Payment__c = Date.today();
				} else {
					acc.Most_Recent_Payment__c = Date.today();
				}

			update accs;
			}
		}
	}
}

 
I'm trying to update a field on the account when a child record is deleted but the field isn't updating. Here's the trigger:
trigger RatePlanDeletion on Zuora__SubscriptionRatePlan__c (after delete) {

	// Make a list of the deleted subscription rate plans
	List<Zuora__SubscriptionRatePlan__c> deletedRatePlan = [SELECT Id,
Name,
Zuora__Account__r.Local_Listings__c,
Zuora__Account__r.Engage__c,
Zuora__Account__r.SEO__c,
Zuora__Account__r.Social_Ads__c,
Zuora__Account__r.Social_Posting__c,
Zuora__Account__r.Website_Product__c
Zuora__SubscriptionRatePlan__c
IN :Trigger.old];

	List<Zuora__SubscriptionRatePlan__c> newRatePlan = new List<Zuora__SubscriptionRatePlan__c>();

	for (Zuora__SubscriptionRatePlan__c sub : deletedRatePlan) {

		// Get Trigger.new version of the rate plan
		Zuora__SubscriptionRatePlan__c subInTriggerNew = Trigger.newMap.get(sub.Id);		
		
		// Local Listings
		if ((sub.Name.contains('Marketing Essentials') || sub.Name.contains('Local Listings'))) {
			subInTriggerNew.Zuora__Account__r.Local_Listings__c = false;
		}

		// Engage 
		if (sub.Name.contains('Engage')) {
			subInTriggerNew.Zuora__Account__r.Engage__c = false;
		}

		// Reviews
		if (sub.Name.contains('Review')) {
			subInTriggerNew.Zuora__Account__r.Reviews__c = false;
		}

		// SEO
		if (sub.Name.contains('SEO')) {
			subInTriggerNew.Zuora__Account__r.SEO__c = false;
		}

		// Social Ads
		if (sub.Name.contains('Social Ads')) {
			subInTriggerNew.Zuora__Account__r.Social_Ads__c = false;
		}

		// Social Posting
		if (sub.Name.contains('Social Posting')) {
			subInTriggerNew.Zuora__Account__r.Social_Posting__c = false;
		}

		// Website
		if (sub.Name.contains('Website')) {
			subInTriggerNew.Zuora__Account__r.Website_Product__c = false;
		}
		
		newRatePlan.add(subInTriggerNew);
	}
	update newRatePlan;
}
I appreciate any help I can get.
I'm trying to mark a checkbox as false on the account when a child record is deleted but the field isn't updating. Here's my code:
trigger RatePlanDeletion on Zuora__SubscriptionRatePlan__c (after delete) {
	// Make a list of the deleted subscription rate plans
	List<Zuora__SubscriptionRatePlan__c> deletedRatePlan = [SELECT Id,
               Name,
               Zuora__Account__r.Local_Listings__c,
               Zuora__Account__r.Engage__c,
               Zuora__Account__r.SEO__c,
               Zuora__Account__r.Social_Ads__c,
               Zuora__Account__r.Social_Posting__c,
               Zuora__Account__r.Website_Product__c
               Zuora__SubscriptionRatePlan__c
               WHERE Id IN :Trigger.old];

	for (Zuora__SubscriptionRatePlan__c sub : deletedRatePlan) {

		// Get Trigger.new version of the rate plan
		Zuora__SubscriptionRatePlan__c subInTriggerNew = Trigger.newMap.get(sub.Id);		
		
		// Local Listings
		if ((sub.Name.contains('Marketing Essentials') || sub.Name.contains('Local Listings'))) {
			subInTriggerNew.Zuora__Account__r.Local_Listings__c = false;
		}

		// Engage 
		if (sub.Name.contains('Engage')) {
			subInTriggerNew.Zuora__Account__r.Engage__c = false;
		}

		// Reviews
		if (sub.Name.contains('Review')) {
			subInTriggerNew.Zuora__Account__r.Reviews__c = false;
		}

		// SEO
		if (sub.Name.contains('SEO')) {
			subInTriggerNew.Zuora__Account__r.SEO__c = false;
		}

		// Social Ads
		if (sub.Name.contains('Social Ads')) {
			subInTriggerNew.Zuora__Account__r.Social_Ads__c = false;
		}

		// Social Posting
		if (sub.Name.contains('Social Posting')) {
			subInTriggerNew.Zuora__Account__r.Social_Posting__c = false;
		}

		// Website
		if (sub.Name.contains('Website')) {
			subInTriggerNew.Zuora__Account__r.Website_Product__c = false;
		}
	}
}
Sorry, I'm new to working with deleted records and not sure what I'm missing. Thanks in advance for your help!
I'm trying to write a trigger that looks for matching leads:
trigger DedupLeadLead on Lead (before insert) {

        // Get the data quality queue record ready for future use
        List<Group> dataQualityGroups = [SELECT Id
                                          FROM Group
                                         WHERE DeveloperName = 'Data_Quality'
                                         LIMIT 1];

        for (Lead myLead : Trigger.new) {
            if (myLead.Email != null) {

            // Searching for matching leads
            List<Lead> matchingLeads = [SELECT Id,
                                               FirstName,
                                               LastName,
                                               Company
                                          FROM Lead
                                         WHERE Company = :myLead.Company
                                        ];

            System.debug(matchingLeads.size() + ' lead(s) found.');

            // If matches are found...
            if (!matchingLeads.isEmpty()) {

                // Assign the lead to the data quality queue
                if (!dataQualityGroups.isEmpty()) {
                    myLead.OwnerId = dataQualityGroups.get(0).Id;
                }
                

                // Add the dupe contact ID's into the lead description
                String dupeLeadsMessage = 'Duplicate lead(s) found:\n';
                for (Lead matchingLead : matchingLeads) {
                    dupeLeadsMessage += matchingLead.FirstName + ' '
                                         + matchingLead.LastName + ', '
                                         + matchingLead.Company + ' ('
                                         + matchingLead.Id + ')\n';    
                }
                if (myLead.Description != null) {
                    dupeLeadsMessage += '\n' + myLead.Description;
                }
                
                myLead.Description = dupeLeadsMessage;
            }
        }
    }
}
Here's my Trigger:
trigger SoldCustomer on Opportunity (after update) {
    for (Opportunity opp : Trigger.new) {
        if (opp.Account.Type != 'Customer' && opp.StageName == 'Sold' && opp.Account.Type != null) {
            opp.Account.Type = 'Customer';
        }
    }
}

Here's my Test Class:
@isTest
private class SoldCustomerTest {

    @isTest static void CreateOpp() {
        // Create Account
        Account acc = new Account();

        acc.Name = 'Created Account';
        acc.Type = 'Prospect';
        String accId = acc.Id;

        Opportunity opp = new Opportunity();
        opp.StageName = 'Discovery';
        opp.CloseDate = date.parse('12/27/2019');
        opp.Name = 'Sold Customer Test Opp';
        opp.AccountId = accId;
    }

    @isTest static void UpdateOpp() {
        List<Opportunity> records = [
        SELECT Id FROM Opportunity WHERE Name = 'Sold Customer Test Opp'
        ];

        for (Opportunity record : records) {
            record.StageName = 'Sold';
        }

        update records;
    }
}
When I run the test class, it shows no coverage for the trigger. This is my 2nd trigger and I'm really excited about asking my first question. Hopefully, someone can help. Thanks in advance!