Skip to content

Usage Data Billing

Usage data represent product consumptions (volume or traffic data, service coverage, etc.) that are to be invoiced. To this end, usage data include the following information:

  • the date and time the consumption took place,
  • the quantity for the consumption, like a number of worked hours, or a number of consumed units, etc.,
  • an identifier, which is used to assign the usage data to a subscription item.

In broad strokes, usage data billing (aka metered billing, usage-based billing or pay-per-use) works as follows:

JustOn retrieves raw usage data (for example, via data import or a third-party integration) and usually saves it to custom objects. The transaction builder converts this data to transactions. During the invoice run, JustOn matches the transactions against the defined subscription items, evaluates the provided quantity information and calculates the item's subtotal. This data then makes up the according invoice line item.

transaction_build
Itemizing usage data with the transaction builder

The continuous invoice run creates invoices and invoice line items directly out of objects that hold usage data. It uses the transaction builder functionality to itemize the consumption data, but does not generate "tangible" transaction records.

Info

You can still set up JustOn to actually create transactions and transaction details, see Transaction Builder Setup Options.

Now assume the following example:

You bill mobile phone services, and you distinguish three types of items: calls, text messages and internet data. These items are tracked separately by an external system, and are then imported. Finally, you want to distribute these items to three separate invoice line items on one invoice.

Modeling this business use case and setting up the transaction builder to itemize this usage data comprises the following major tasks:

Note

In addition, you must, of course, set up the usage data retrieval - either a data import or a third-party integration. Note, however, that this setup is not covered with this documentation, as it is too project-specific and cannot be generalized.

For help with setting up the usage data retrieval, see Import Data Into Salesforce in the Salesforce Help or contact the JustOn support team.

Info

For the purpose of this documentation, we assume the minimum required steps to illustrate the setup for usage data billing and the transaction builder, including the continuous invoice run. For a complete overview of the available setup options, see Transaction Builder Setup Options.

Configuring Custom Object

The transaction builder requires a number of ON fields (controlling fields and data fields) on the custom object.

  1. Navigate to the fields list of the custom object.
  2. Create the following new fields.

    API Name Data Type Description
    ON_Type Formula (Text)
    or
    Picklist
    Controlling field, defines the type of the created transaction, either Transaction or Detail.
    When using the continuous invoice run, set Transaction as the value.
    ON_OrderNo Formula (Text)
    or
    Text
    Controlling field, represents the key to match source data to a subscription item.
    If you use a lookup relation or a formula to determine the order no, make sure that your logic produces the same order no value for both the source object and the item.
    If you get individual records for different types of usage data, you need a formula that yields the intended target item.
    If you get different usage data types in one record, you specify a comma-separated list of target items.
    ON_Subscription Lookup (Subscription) Controlling field, links to the related subscription after the object records have been successfully processed.
    ON_Invoice Lookup (Invoice) Controlling field, links to the related invoice after the object records have been successfully billed.
    ON_LastError Text (255) Controlling field, displays the error message if the transaction creation has failed.
    ON_Account Formula (Text) Controlling field, specifies the Salesforce account ID or external ID, required if there is no or more than one account lookup on the object.
    The formula uses the API name of the field that links the object to the account, for example, TEXT(AccountId).
    ON_AddToTransactionTable Checkbox Controlling field, required when using the continuous invoice run. Determines whether to show the transaction on the invoice, deselected by default.
    ON_AddToCsv Checkbox Controlling field, required when using the continuous invoice run. Determines whether to export the transaction as CSV, deselected by default.
    ON_Date Formula (Date)
    or
    Date
    Data field, displays the date on which the transaction is considered for invoicing.
    ON_Quantity Formula (Number)
    or
    Number
    Data field, specifies the quantity or volume information as accumulated for the transaction.

    For help about creating fields, see Managing Object Fields.

Info

Depending on your use case and its requirements, you can add more fields to have them filled and copied to the generated invoices or invoice line items. For details, see Fields on Custom Objects.

Creating Subscription and Items

As the transactions are to be matched with subscription items for the invoice generation, you must prepare a "target" subscription and corresponding items.

  1. Create the subscription as required.

    For details, see Creating Subscriptions.

  2. Add the items to the subscription as required.

    For details, see Adding Items.

Following the example, you create a subscription and three items - "calls", "text messages" and "internet data".

Note

Make sure that each item's value of the OrderNo field matches one of the possible values of the custom object's ON_OrderNo field (see Configuring Custom Object).

Info

Your business may require invoicing a base price, irrespective of the actually incurred usage data costs. In this case, you must enable the minimum fee calculation.

Creating Transaction Filter

To define which objects and records to include in the transaction build process, you create a new custom filter.

  1. In Setup, open Custom Settings.

    In Salesforce Lightning, navigate to Custom Code > Custom Settings.

    In Salesforce Classic, navigate to Develop > Custom Settings.

  2. Click Manage in the row of Filters.

  3. Create the following filter for the transaction build.

    Field Required Description Example Value
    Name Specifies the filter name, will be available as an option picklist value when triggering the operation
    Target Specifies the API name of the (custom) target object that is to be converted to transactions MyObject__c
    Use Case Specifies the filter use case, either Transaction or Continuous.
    When using the continuous invoice run, set Continuous as the value.
    With large data sets, you can ask Salesforce to have the field ON_Date__c indexed, and then use Continuous Daily for the continuous invoice run. For details, see here.
    Continuous
    Condition Specifies a condition (SOQL WHERE clause) to restrict the set of included records.
    For details, see SOQL SELECT Syntax in the Salesforce Help.
    Note that objects on which ON_Subscription and ON_Invoice is already filled will be ignored.

    For help about creating filters, see Filters.

Setting Up Continuous Invoice Run

The continuous invoice run creates invoices and invoice line items directly out of objects that hold usage data. It uses the transaction builder functionality to itemize the consumption data, but does not generate "tangible" transaction records. As the name suggests, it can run multiple times, repeatedly aggregating new usage data to existing invoice line items as long as the invoice is Draft.

For the continuous invoice run to work:

  1. Make sure that the following conditions are met:

  2. Schedule a parameterized invoice run with the corresponding transaction filter (use case Continuous/Continuous Daily) added as a parameter.

    For details, see Parameterized Invoice Run.

Info

For further help with setting up usage data billing in general or the transaction builder in particular, contact the JustOn support team.

Return to JustOn Administration.