• Gireesh Arni
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
global  class Batch_SubscriptionCMRRRollup implements Database.Batchable<SObject>{

global Database.QueryLocator start(Database.BatchableContext context) {
    //get all the billing accounts and the related subscriptions
    return Database.getQueryLocator([Select Id,Today_s_MRR__c,(Select Id,Zuora__MRR__c,Zuora__Status__c,Zuora__ServiceActivationDate__c from Zuora__Subscriptions__r) from Zuora__CustomerAccount__c]);
}

global void execute(Database.BatchableContext context, List<Zuora__CustomerAccount__c> listOfBillingAccounts) {

    //Iterate through all the billing accounts
    for(Zuora__CustomerAccount__c iteratingAccount: listOfBillingAccounts){
    
        //Iterate through all the subscriptions
        for(Zuora__Subscription__c iteratingSubscription : iteratingAccount.Zuora__Subscriptions__r){
            
            //add only those active subscriptions
            if((iteratingSubscription.Zuora__Status__c == 'Active' || 
                iteratingSubscription.Zuora__Status__c=='active') &&
                iteratingSubscription.Zuora__ServiceActivationDate__c <=  Date.Today() &&
                iteratingSubscription.Zuora__MRR__c != NULL){
                   iteratingAccount.Today_s_MRR__c += iteratingSubscription.Zuora__MRR__c;
            }
        }
    }
    
    update listOfBillingAccounts;
}

global void finish(Database.BatchableContext context) {}}
Hi,

Recently tried to validate a changeset in production from sfa. Saw "Your code coverage is 74%. You need at least 75% coverage to complete this deployment". So, Is there a way where we can find the classes with lowest code-coverage in the org?  So that code coverage can be improved for those classes ?