# SubscriptionRefined Apex Class

Limio for Salesforce (LFS) package includes a custom SubscriptionRefined Apex class, that collects properties across several subscription-related objects (such as Schedule, Product, Offer etc) and centralises them on one level.

These properties can be used to customise what's being surfaced in the Customer's Subscriptions list, see [subscriptions-table-columns](https://docs.limio.com/integrations/using-limio-for-salesforce/subscriptions-table-columns "mention").

They could also be used for determining what actions should be available for a specific subscription, based on its attributes. To customise the list of available actions see [override-subscription-actions](https://docs.limio.com/integrations/setting-up-limio-for-salesforce/subscription-actions-rules/override-subscription-actions "mention").

This document describes the LFS Subscription global properties (SubscriptionRefined) as mapped from the Limio subscription object. Since all of these properties are global, they can be accessed in the org where the managed package is installed.<br>

<figure><img src="https://3950144701-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKxTpA9AeeNYx1ml6UpHj%2Fuploads%2FshqINzJ7jbEjdej6GPz6%2Fimage.png?alt=media&#x26;token=ba752deb-5dea-4c08-ab0d-c1be0bcb5683" alt=""><figcaption></figcaption></figure>

### Fields mapped from the Subscription

| String `subscriptionName` | `name`            |
| ------------------------- | ----------------- |
| String `subscriptionId`   | `id`              |
| Date `startDate`          | `startDate`       |
| Date `endDate`            | `termEndDate`     |
| String `status`           | `status`          |
| String `purchaseCountry`  | `purchaseCountry` |
| Integer `quantity`        | `quantity`        |
| String `owner`            | `owner`           |
| String `customerId`       | `customerId`      |

### Fields mapped from the Subscription Schedules

Every subscription has an associated list of schedules.

*If you navigate to any Schedule record in the Limio App and scroll to the end of the page you’ll find a structure representing a Limio Schedule Object. Most of the fields are reflected on the UI above the structure.*

Each entry corresponds to a billing term. LFS defines a currently active schedule item (schedule\_date <= today) and calculates the following properties using it:

| Date billingPeriodStart | currentSchedule.schedule\_date |
| ----------------------- | ------------------------------ |
| Date billingPeriodEnd   | nextSchedule.schedule\_date    |
| Decimal latestCharge    | currentSchedule.amount         |
| Decimal nextCharge      | nextSchedule.amount            |
| String currency\_x      | currentSchedule.currency       |

### Fields mapped from the Subscription Offers

Every subscription has an associated list of offers on it. During the lifetime of the subscription, an offer can change, and the new one is added to the list.

*If you navigate to any Offer on a Subcription record in the Limio App and scroll to the end of the page you’ll find a structure representing a Limio Offer Object. Most of the fields are reflected on the UI above the structure.*

LFS defines a currently active offer (start <= today, with no defined end\_date or an end\_date in the future) and calculates the following properties using it:

| String offerName                        | transformed activeOffer.offer.path OR activeOffer.offer.parent\_path                                                                                                                                                                                                                                                                                                                                                                                                                              |
| --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| String offerPath                        | activeOffer.offer.path                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| SubscriptionRefined.OfferTerm offerTerm | <p>activeOffer.offer.data.attributes.term\_limio<br><br>This is an object containing two properties: length and type</p>                                                                                                                                                                                                                                                                                                                                                                          |
| List offerAllowedCountries              | activeOffer.offer.data.attributes.allowed\_countries\_limio                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| List offerProducts                      | list of product.path values from activeOffer.products                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| Decimal maxRefundAmount                 | <p>Maximum amount to be refunded which is applied to the Cancel, Switch and Refund journeys in LFS, and defaults to the latest charge amount.<br><br>Note: it is possible to override the maximum refund limit in the LFS flows, see <a href="https://docs.limio.com/integrations/using-limio-for-salesforce/manage-subscriptions-flow/subflow-refund/limit-refund-amount?q=Flow+Customisation:+Limit+the+amount+to+refund+for+a+Cancel+or+Switch+action">this document</a> for more details.</p> |
| Boolean isAutoRenewable                 | <p>if true, it means that an active offer is auto-renewable<br><br>activeOffer.offer.data.attributes.autoRenew\_limio</p>                                                                                                                                                                                                                                                                                                                                                                         |
| Boolean hasDelivery                     | <p>if true, it means that at least one of the products associated with an active offer is deliverable<br><br>product.attributes.has\_delivery\_limio</p>                                                                                                                                                                                                                                                                                                                                          |

### Fields mapped from the Subscription Address

Limio Subscription has an associated list of Limio Address records.

| List addressList | <p>a list of mapped addresses in the following format:<br><br><code>\<br> String FirstName;\<br> String LastName;\<br> String CompanyName;\<br> String label;\<br> String id;\<br> String MailingCountry;\<br> String MailingStreet;\<br> String MailingPostalCode;\<br> String MailingCity;\<br> String MailingState;\<br></code></p> |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

### Fields calculated for a Gift Subscription

When a customer buys a gift subscription, a new gift code is generated and associated with the subscription object. LFS surfaces three gift-related properties on a SubscriptionRefined:

| Boolean isGift           | if true, it means that the subscription is a purchased gift                                                                                                                                    |
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Boolean isGiftRefundable | if true, it means that the gift subscription status is active and it has not been redeemed or refunded yet; controls if the Refund action is shown in the list of allowed subscription actions |
| String gift\_code        | represents the gift code associated with the gift subscription                                                                                                                                 |

### Other

List addressDetails is a deprecated property.\
Boolean hasErrors and String error are for internal use to verify that the subscription was loaded correctly.
