Knowledge Center

Knowledge Center > Commerce > Zuora for Salesforce Development Resources > Zuora for Salesforce Component Library > Zuora for Salesforce Component Library Samples > Create Multiple Subscriptions and Issue a Single Payment from a Quote

Create Multiple Subscriptions and Issue a Single Payment from a Quote

You can use a single quote to create multiple subscriptions and issue a single payment based on that quote. This feature is supported through global methods only. 

Using Parent and Child Quotes

A quote can have child quotes.

  • A quote that has child quotes is referred to as a parent quote. 
    • A parent quote can have multiple sub-quotes.
    • Products cannot be added to a parent quote. 
  • A child quote is referred to as a sub-quote.
    • One or more products can be added to a sub-quote.
    • The sub-quotes use the ParentQuote__c field to link to the parent quote. 

When a parent quote is sent to Zuora via the sendToZBilling global method, a subscription or a list of amendments will be created for each sub-quote.

Configuring the Parent Quote Attributes

Parent quotes include two attributes to support this feature: 

  • Generate Invoice (zqu__GenerateInvoice__c): Use this attribute to specify whether to generate an invoice for the sub-quotes. 
  • Invoice Processing Option (zqu__InvoiceProcessingOption__c): Use this attribute to specify whether to generate an invoice for a sub-quote at the Account level or the Subscription level.
  • Apply Credit Balance (zqu__ApplyCreditBalance__c): Use this attribute to specify whether to apply any credit balance on the customer's account to invoices for sub-quotes.

Quote Validation Rules

Parent quotes are subject to the following validation rules when being sent to Zuora via the global method:

  • The value of Status__c must be New.
  • The parent quote cannot be a child of another quote, i.e. a parent quote's ParentQuote__c field must be null.
  • The parent quote must have at least two sub-quotes. The sub-quotes can be a mix of subscriptions, amendments, and renewals.
  • When two or more of the sub-quotes are amendment quotes, all of the amendment quotes must refer to different subscriptions. The same subscription cannot be amended by two different sub-quotes.

How the Parent Quote Values Affect the Sub-quotes

Although the two invoice-related attributes are enabled on all quotes, if a quote is a sub-quote, the values specified on its parent quote will take effect.

Generate Invoice value on Parent Quote Invoice Processing Option value on Parent Quote Description
true Account

The sub-quotes will be processed to generate subscriptions or amendments. Zuora 360 will generate a single invoice. 

Zuora 360 will process all of the sub-quotes, even if exceptions are generated for some of the sub-quotes. The exceptions will be sent back to the customer and the invoice will not be generated.

The subscriptions generated will write the Subscription ID back to the sub-quotes. The Invoice ID and Payment ID will be written back to the parent quotes.

One parent quote will create one new billing account if its sub-quotes are of type New Subscription.

true Subscription

The sub-quotes will generate subscriptions or amendments and invoices separately.

The Invoice ID and Payment ID will be written back to the sub-quotes.

One parent quote will create one new billing account if its sub-quotes are type New Subscription.

false (none) Zuora 360 will not generate invoices for either the parent quote or sub-quotes. 

Processing Quotes Sent to Zuora

All requests to send parent quotes to Zuora will be handled asynchronously. This means that the requests will be sent from Salesforce, but the results will not be immediately written back to the Salesforce records. Zuora Quotes writes the results to Salesforce when it completes the processing of the requests.

Sample Code

/* 
    PRE-CONDITIONS:
    - the quote referenced by primaryQuoteId (the parent quote) has its Is_Parent_Quote__c field set to true.
    - at least two "standard" subscription, amendment, or renewal quotes are set to be children of the parent quote
*/

Id primaryQuoteId = 'a0GE0000005HRhD';
Quote__c primaryQuote = [select Id,GenerateInvoice__c,InvoiceProcessingOption__c from Quote__c where Id = :primaryQuoteId];

// construct the wrapper objects to pass to the global method
// NOTE: the wrapper collection for a parent quote should contain only the parent quote in the quoteRequests property
List<zQuoteUtil.ZBillingQuoteCollection> qCollections = new List<zQuoteUtil.ZBillingQuoteCollection>();

zQuoteUtil.ZBillingQuoteCollection qCollection = new zQuoteUtil.ZBillingQuoteCollection();
qCollection.zAccountId = 'new';
qCollection.quoteRequests = new List<zQuoteUtil.ZBillingQuoteRequest>();

zQuoteUtil.ZBillingQuoteRequest qRequest = new zQuoteUtil.ZBillingQuoteRequest();
qRequest.generateInvoice = primaryQuote.GenerateInvoice__c;
qRequest.invoiceProcessingOption = primaryQuote.InvoiceProcessingOption__c;
qRequest.sfdcQuoteId = primaryQuote.Id;

qCollection.quoteRequests.add(qRequest);
qCollections.add(qCollection);

// pass the wrapper objects into the global method
List<zQuoteUtil.ZBillingResult> results = zQuoteUtil.sendToZBilling(qCollections);

// ... operate on the results collection ...
Last modified
16:38, 8 Aug 2016

Tags

This page has no custom tags.

Classifications

(not set)