Skip to main content

Billing Account Plugin

Zuora

Billing Account Plugin

UndefinedNameError: reference to undefined name 'undefined' (click for details)
Callstack:
    at (CPQ/CPQ_X/CPQ_X_Supported_Plugins/Billing_Account_Plugin), /content/body/div[1]/pre, line 2, column 1

Customize Billing Account Plugin

Use the IBillingAccountPlugin on the BillingAccountPlugin component to customize the Billing Account selection process.

The following customizations are available:

  • For billing account selection
    • Control new and existing billing account options
    • Filter billing accounts
    • Set the default billing account
  • For quote type selection
    • Set the default quote type
    • Control quote type options - new, amend, renew, or cancel
  • For quote type selection
    • Filter subscriptions

The plugin interface is defined as:

global zqu.BillingAccountPlugin.IBillingAccountPlugin

The plugin contains the following interface methods.

Return Type Method Input Parameters
zqu.BillingAccountPlugin.BillingAccountObjects getAvailableBillingAccounts zqu.BillingAccountPlugin.
BillingAccountObjects 
zqu.BillingAccountPlugin.QuoteTypeObjects getAvailableQuoteTypes zqu.BillingAccountPlugin.
QuoteTypeObjects
zqu.BillingAccountPlugin.SubscriptionObjects getAvailableSubscriptions zqu.BillingAccountPlugin.
SubscriptionObjects

Procedure

To activate the Billing Account plugin:

  1. Create a global plugin interface that implements zqu.BillingAccountPlugin.IBillingAccountPlugin
  2. Register and activate the plugin.
    1. Navigate to Zuora Config > Quote Studio Settings > Admin Config.
    2. Switch the Billing Account Plugin toggle to Active, then add the class name of your custom plugin.

clipboard_ecef1f5d61be65f1efea95c0c4279dadb.png

  1. Click Save.

Sample Code for Billing Account Plugin

The following is a code sample for the Billing Account Plugin.


global with sharing class SampleBillingAccountPlugin implements 
    zqu.BillingAccountPlugin.IBillingAccountPlugin {
   global zqu.BillingAccountPlugin.BillingAccountObjects 
   getAvailableBillingAccounts(zqu.BillingAccountPlugin.BillingAccountObjects 
   accountObjs) {
        accountObjs.billingAccountTypes = new List<string>{ 'existing' };
        List<sobject> tempAccounts = new List<Sobject>();
 
        for (Sobject sobj : accountObjs.billingAccounts) {
        if (sobj.get('Zuora__PaymentTerm__c') == 'Due Upon Receipt') {
            tempAccounts.add(sobj);
        }
        
    }
    
    accountObjs.billingAccounts = tempAccounts;
    return accountObjs;
   }
   
   global zqu.BillingAccountPlugin.QuoteTypeObjects 
   getAvailableQuoteTypes(zqu.BillingAccountPlugin.QuoteTypeObjects 
   quoteTypeObjs) {
    quoteTypeObjs.quoteTypes = new List<string>{ 'new', 'amend' };
    return quoteTypeObjs;
   }
   
   global zqu.BillingAccountPlugin.SubscriptionObjects 
   getAvailableSubscriptions(zqu.BillingAccountPlugin.SubscriptionObjects 
   subscriptionObjs) {
       List<sobject> tempSubs = new List<Sobject>();
 
        for (Sobject sobj : subscriptionObjs.subscriptions) {
        if (sobj.get('Zuora__TermSettingType__c') == 'TERMED') {
            tempSubs.add(sobj);
        }
        
    }
    
    subscriptionObjs.subscriptions = tempSubs;
 
    return subscriptionObjs;
   }
   
}

Test Class for Billing Account Plugin

The following is a APEX test class code sample for Billing Account Plugin. You can use the test class to achieve code coverage on the plugin in Salesforce.

@IsTest(SeeAllData=false)
public with sharing class SampleBillingAccountPluginTest{
    @IsTest
    public static void testGetAvailableBillingAccounts() {
        SampleBillingAccountPlugin pluginObj=new
        SampleBillingAccountPlugin();
       
        Zuora__CustomerAccount__c customerAccount=new
        Zuora__CustomerAccount__c();
            customerAccount.Zuora__PaymentTerm__c='Due Upon Receipt';
       
        zqu.BillingAccountPlugin.BillingAccountObjects billingAccounts=new
        zqu.BillingAccountPlugin.BillingAccountObjects();
        billingAccounts.sfdcAccountId='';
        billingAccounts.opportunityId='';
        billingAccounts.defaultBillingAccountId='';
        billingAccounts.billingAccountTypes=new List<string>{'new','existing'};
        billingAccounts.billingAccounts=new List<Sobject>{customerAccount};
       
        zqu.BillingAccountPlugin.BillingAccountObjects
        filteredBillingAccount=pluginObj.getAvailableBillingAccounts(billingAccounts);
       
        System.assertEquals(1,filteredBillingAccount.billingAccounts.size());
        System.assertEquals(1,filteredBillingAccount.billingAccountTypes.size());
    }
    
    @IsTest
    public static void testGetAvailableQuoteTypes() {
        SampleBillingAccountPlugin pluginObj=new SampleBillingAccountPlugin();
       
        zqu.BillingAccountPlugin.QuoteTypeObjects quoteTypes=new
        zqu.BillingAccountPlugin.QuoteTypeObjects();
        quoteTypes.sfdcAccountId='';
        quoteTypes.opportunityId='';
        quoteTypes.billingAccountId='';
        quoteTypes.quoteTypes=new List<string>{'new','existing'};
        zqu.BillingAccountPlugin.QuoteTypeObjects
        quoteTypesResponse=pluginObj.getAvailableQuoteTypes(quoteTypes);
        System.assertEquals(2,quoteTypesResponse.quoteTypes.size());
      
    }
    
    @IsTest
    public static void testGetAvailableSubscriptions() {
        SampleBillingAccountPlugin pluginObj=new
        SampleBillingAccountPlugin();
        Zuora__Subscription__c subscriptionObj=new
        Zuora__Subscription__c();
        subscriptionObj.Zuora__TermSettingType__c='TERMED';
       
        zqu.BillingAccountPlugin.SubscriptionObjects subscriptions=new
        zqu.BillingAccountPlugin.SubscriptionObjects();
        subscriptions.sfdcAccountId='';
        subscriptions.opportunityId='';
        subscriptions.billingAccountId='';
        subscriptions.subscriptions=new List<Sobject>{subscriptionObj};
        pluginObj.getAvailableSubscriptions(subscriptions);
        System.assertEquals(1,subscriptions.subscriptions.size());
      
    }
    
}