Happy Business Starts Here

Guru

Need Quote Metrics populated

This page says "Quote metrics are calculated automatically when a New Subscription quote or a Renewal quote is created. Quote metrics are recalculated and updated if you update:"

 

We are not seeing this to be the case when we create the quote from apex code and modify the charges on a quote in code.

 

Is there a method I should call on the quote each time I make a change?

 

We currently have custom code that calculates the metrics for us as the ones OOTB when we started were not what we needed. The OOTB metrics now appear to meet our needs and we would like to deprecate some of our custom code to simplify things.  However we are observing that the OOTB metrics on the quote are not populating until someone opens the quote page in a browser. 

This issue is preventing us to update our production code to use ZQuotes 7.

 

Any help will be appreciated.

Maggie Longshore
12 REPLIES 12
Zuora Alumni

Re: Need Quote Metrics populated

Hey Maggie,

 

So I checked with the dev and the metrics are recalced on the basis of a trigger, so whether you use Global Methods or directly alter a field the trigger should pick the change and recalc the metrics.

 

The fact you are not may either indicate a bug or that that particular update is not supported as a metrics "change".  

 

Might be worth a Support ticket.

Guru

Re: Need Quote Metrics populated

@nathanc so I also see the same thing @MaggieL describes.

 

When you modify most attributes on the quote that would impact metrics it toggles the "zqu__Is_Charge_Expired__c" field on the Quote object. The next time someone views the page it will recalculate the metrics, but not until that time.

 

So while I agree that recalculation is "triggered" by a change by global methods, the actual recalc does not occur proper until the preview is viewed in the browser.

Guru

Re: Need Quote Metrics populated

I was told by support a while ago that I could toggle zqu__Is_Charge_Expired__c , but i did not find it to be consistent.  

 

The metrics need to be there regardless of the quote being opened in a browser and should not require custom code.

Maggie Longshore
Highlighted
Guru

Re: Need Quote Metrics populated

@nathanc, I opened a ticket, 92032, and was just told that by design the quote metrics will not update unless you open the quote in a browser. Very disappointing.

Maggie Longshore
Zuora Alumni

Re: Need Quote Metrics populated

Thats correct, we'd need to do more work here to enable that.

 

We have a lot of work to do :-)

Tutor rem
Tutor

Re: Need Quote Metrics populated

Hi all. Any updates about calculating metrics without viewing the page?

I faced with this problem when generated Quote Document via API don`t have total amounts of the Quote.

After visiting the Quote page and generate Document again - all works fine.

Guru

Re: Need Quote Metrics populated

This ticket's solution of calling JR_recalculate() will update the quote I beleive with what you need. This has been a huge problem for us for years since we automate all of the renewal quotes. This method is relatively new and I plan on updating my code to use it.  It did populate all of the metrics data when I tried it in sandbox.

Maggie Longshore
Tutor rem
Tutor

Re: Need Quote Metrics populated

Thanks for your reply, @MaggieL, but no. It doesn`t calculate anything. 

There is some additional info, maybe I`m doing something wrong.

 That`s how I add a product.

 

zqu.ZChargeGroup chargeGroup2 = zqu.zQuoteUtil.getChargeGroup(qte.Id, product2.Id);
for ( zqu.zCharge charge1 : chargeGroup2.zCharges ) {
     charge1.QUANTITY = product2Quantity;
}
zqu.zQuoteUtil.calculateChargesOnQuantityChange(chargeGroup2.zCharges);
chargeGroupsToAdd.add(chargeGroup2);
zqu.ZQuoteUtil.addChargeGroups(chargeGroupsToAdd);

 

Same for product 1. After that, I can see that quantity changed for product 2 but totals are empty.

 

Next one step is 

 

zqu.zQuoteUtil.ZBillingResult previewResult = zqu.QuoteRecalculateController.JR_recalculate(qte.Id);
System.debug(previewResult);

 

Dubug log

 

09:21:35:337 USER_DEBUG [143]|DEBUG|ZBillingResult:[chargeMetrics=null, deltaDiscountMrr=0, deltaDiscountTcb=0, deltaDiscountTcv=0, deltaMrr=0, deltaTcb=0, deltaTcv=0, discountMrr=0, discountTcb=0, discountTcv=0, expectedDeltaDiscountTax=0, expectedDeltaTax=0, expectedDiscountTax=0, expectedTotalTax=0, message=QuoteToBillingValidator.getSubscriptionsByQuoteNumber: The ZOQL query for Subscriptions by Quote Number has failed.:zqu.zApi.zApiException:The callout was unsuccessful after 4 attempts : You have uncommitted work pending. Please commit or rollback before calling out:(zqu)
09:21:31:000 USER_DEBUG , orderMetrics=null, sfdcQuoteId=null, success=false, totalInfo=null, totalMrr=0, totalTcb=0, totalTcv=0, zAccountId=null, zSubscriptionId=null]

 

If I understand correctly, it calls Zuora app and tries to get Subscription data, but a subscription is not created yet (my workflow).

Also, I tried to call '/subscriptions/preview' but it gives me only MRR value so I can`t set totals manually.

 

After calling JR_recalculate() I get the error (see screenshot).

623x551-Selection_25_09_2018_001.jpg

 

So, The problem is that when I create Quote and generate Quote document, total values are empty in PDF until I view the Quote page and regenerate PDF. That`s not acceptable to me. 

 

Maybe I miss something or there are some any ideas how I can get those values in APEX or REST API?

 Also, I tried to use zqu.Quote methods, zqu.zQuoteUtil.

 

Please, help me Man Frustrated

Tutor rem
Tutor

Re: Need Quote Metrics populated

Thanks, @MaggieL for your reply. I posted the comment but it was marked as spam.

 

I tried to do it but no success. This method as I understand calls the Zuora Subscription but it is not created yet.

The code sample and debug info shows me the NULL values. So, still, PDF Quote Document has no totals. 

 

Any suggestions?

 

Please, give me any ideas Man Frustrated

Thanks a lot!