Happy Business Starts Here

Re: How to determine what the current version of a subscription with future dated amendments

Newly Enrolled

How to determine what the current version of a subscription with future dated amendments

I want to be able to determine what the 'effective' subscription object is at any given point in time.

 

Currently, when I set an amendment, and I query subscriptions, I get a list of multiple versions of the subscription back from the API. However, I don't know which one is current, and which one has pending/future dated amendments that have yet to be applied.

 

E.g. If I future date a cancellation amendment, when I query the subscription, the latest version shows Status = "Cancelled", but actually I want to work on the version of the subscription that doesn't yet have the amendment applied. But I don't know how to figure out which version that is.

 

The only idea I've had so far is to:

 

  1. Query subscriptions
  2. Query all related amendments to those subscriptions
  3. Filter out all subscriptions that have future-dated amendments related to them
  4. Take the newest version of the filtered list as being the 'current' version

But this seems messy. I would have expected some kind of field on Subscription that allows me to determine if it's the current version.

7 REPLIES 7
Zuora Staff

Re: How to determine what the current version of a subscription with future dated amendments

By looking at the Rate Plan Charges of the latest active subscription you are returned all charges from the current subscription as well as all prior subscription versions. These charges will have a different version and/or segment depending on the type of amendment that was processed.

 

By looking at the rate plan charges effective start and end dates you'll be able to determine what charges are current, in the past, or in the future.

 

  • The current price and quantity of a charge:
    EffectiveStartDate <= Today <= EffectiveEndDate
  • The previous details of a charge, such as its price and quantity:
    EffectiveStartDate < Today
  • Pending charges:
    EffectiveStartDate > Today
  • The entire history of a charge:
    Order the RatePlanCharge object by segments, starting with the Segment field with the value, 1.
Newly Enrolled

Re: How to determine what the current version of a subscription with future dated amendments

Thanks Shawn.

 

So just to confirm, I would:

 

  1. Query subscriptions for an account
  2. Query all related rate plans for those subscriptions
  3. Query all related rate plan charges for those rate plans
  4. Filter out the rate plane charges to find those with EffectiveStartDate <= Today <= EffectiveEndDate
  5. Retrieve the rate plans for currently effective rate plan charges found in (4)
  6. Retrieve the subscriptions for rate plans found in (5)

Now in step 6 I should have only currently effective subscriptions, right?

Highlighted
Zuora Staff

Re: How to determine what the current version of a subscription with future dated amendments

That will work, but what I was thinking is:

 

  1. Query subscriptions for an account where the subscription have a status of "Active" or "Cancelled"
  2. Query all related rate plans for those subscriptions
  3. Query all related rate plan charges for those rate plans
  4. Filter out the rate plan charges to find those with EffectiveStartDate <= Today <= EffectiveEndDate

In Zuora we are storing the pervious version of the charges on the latest version of the subscription even if it futured dated. So by looking at the charges you can then determine what is effective from the latest subscription.

Newly Enrolled

Re: How to determine what the current version of a subscription with future dated amendments

Thanks again... I'm a bit confused now though.

 

If I only query subscriptions with status "Active" or "Cancelled" then I will exclude some "Expired" subscriptions which may actually be the "current" / "effective" subscription I am trying to find, prior to any amendments. So then if I find rate plans and charges for those subscriptions, I will be excluding the subscriptions that I am actually trying to find (which aren't actually "Expired" but will be when the amendment takes place).

 

But actually I am stuck even without any amendments... I have a single RatePlanCharge for a single RatePlan for a Subscription (no amendments), and I am getting NULL for EffectiveStartDate and EffectiveEndDate for that rate plan charge. So when I filter EffectiveStartDate <= Today <= EffectiveEndDate I am left with nothing. Note I *am* selecting those fields in my SELECT ... statement.

Zuora Staff

Re: How to determine what the current version of a subscription with future dated amendments

The latest version of the subscription will also have the charges from the expired subscriptions with their associated start and end dates based on the amendment data.

 

You may get a null value for Effective End Date depending on the Subscription Term Type being Evergreen, but the Start date is system generated and is a date format for WSDL 69+ and DateTime for WSDLs 68 and prior and should be populated. I'd recommend opening a ticket with our Support team (support@zuora.com) to look into why you're seeing null values. They can then investigate in your particular tenant. 

 

 

Newly Enrolled

Re: How to determine what the current version of a subscription with future dated amendments

So you're saying the latest version has ALL the charges from the expired subscriptions. However, there seems to be no way in the data structure to get back to those expired subscriptions.

 

E.g. I look up RatePlans using my latest subscription Id. I then look up RatePlanCharges from those RatePlans. Now, the RatePlanId on all the RatePlanCharges points to my RatePlans I looked up. Then the SubscriptionId on all those RatePlans points to my latest subscription id. So, at no point in traversing all these objects did I ever encounter a subscription Id that was not the latest. So then how do I get back to the expired copy of the subscription, which stores the state I want?

 

Thanks

 

 

Re: How to determine what the current version of a subscription with future dated amendments

We ran into the same problem, with future dated amendments, and need to look through all of the amendments and rate plans, to determine what the current and future state of the subscription is.

 

The trick  is when you query the RatePlans, you actually have to perform two queries, to get all of the related RatePlans.

 

Select Id, Name, ProductRatePlanId, AmendmentType, SubscriptionId From RatePlan WHERE AmendmentType!=null AND SubscriptionId = '<subscription_id>'

Select Id, Name, ProductRatePlanId, AmendmentType, SubscriptionId From RatePlan WHERE SubscriptionId = '<subscription_id>'

 

See the notes for 'Querying for Removed RatePlans' at the bottom of http://knowledgecenter.zuora.com/DC_Developers/SOAP_API/E1_SOAP_API_Object_Reference/RatePlan.