QuoteRecalculateController Class
This article describes the methods in the QuoteRecalculateController class. Use the methods to programmatically invoke the subscription preview call to Zuora.
QuoteRecalculateController Class Global Methods
The following methods are supported in the QuoteRecalculateController class.
| Return Type | Method | Description |
|---|---|---|
| zqu.zQuoteUtil.ZBillingResult | JR_recalculate |
This method makes the subscription preview call to Zuora and returns the result. This call also updates the quote and charge level metrics with the results. If the setting Enable Charge Segment Metrics is enabled in Zuora Config > Quote Studio Settings > Admin Config, charge segment records are generated. |
| zqu.zQuoteUtil.ZBillingResult | recalculateNoUpdate | This method makes the subscription preview call same as JR_recalculate, but this method does not update the quote and charge level metrics in Salesforce. |
| zqu.zQuoteUtil.ZBillingResult | JR_recalculateInvoiceItemSummaries |
This method, available starting with Quotes Version 10.48, makes a subscription preview call to Zuora, updates the Invoice Item Summaries with the returned data, and then returns the result.
The call to this global method must be executed in a separate transaction from quote creation or other DML operations, because Salesforce does not allow DML operations and callouts in the same transaction. This can be achieved using asynchronous Apex, such as a future method or a Queueable class. |
Sample Code
The following is a sample call for the JR_recalculate global method:
zqu.zQuoteUtil.ZBillingResult previewResult = zqu.QuoteRecalculateController.JR_recalculate('<quoteId>');
if (previewResult.success) {
System.debug('The metrics were successfully updated on all Quote Charge Details, Quote Charge Summaries, and Quote Rate Plan Charges.');
}
The following is a sample call for the recalculateNoUpdate global method:
zqu.zQuoteUtil.ZBillingResult previewResult = zqu.QuoteRecalculateController.recalculateNoUpdate('<quoteId>');
if (previewResult.success) {
System.debug('The preview to Zuora was successful. However, the metrics were not refreshed for Quote Charge Details, Quote Charge Summaries, or Quote Rate Plan Charges.');
}
The following is a sample call for the JR_recalculateInvoiceItemSummaries global method:
@future(callout=true)
public static void callNewGlobalMethodAsync(String quoteId) {
try{
QuoteRecalculateController.JR_recalculateInvoiceItemSummaries(quoteId);
system.debug('Invoice Item Summary records successfully created.');
} catch(Exception e){
system.debug('Invoice Item Summary records creation failed with message: '+e.getMessage());
}
}
