Controlling Usage Data Billing Options
When billing usage data, 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. Although without creating "tangible" transaction records, it still uses (transient) transactions to do so – hence the name.
Note
This article summarizes advanced options for the transaction builder. For an introduction and a step-by-step guideline on setting up usage data billing, see Enabling Usage Data Billing.
The following options are available to control the transaction builder's behavior:
Defining fields on custom objects
Displaying itemized usage data records on invoices
When actually building "tangible" transactions, the additional options include:
Fields on Custom Objects
The transaction builder requires a number of ON fields on objects that hold usage data to be itemized. There are two types of required fields:
Controlling fields (hold meta data for assignments or process control)
Data fields (hold actual usage data)
Optionally, your business use cases may require additional price and quantity fields.
Controlling Fields
Controlling fields hold meta data for assignments or process control.
Note
JustOn checks the controlling fields when starting the transaction builder. If a required field is missing, it aborts the transaction building process.
API Name | Required | Data Type | Description |
|---|---|---|---|
ON_Type | ✅ | Formula (Text) | Defines the type of the created transaction, either |
ON_OrderNo | ✅ | Formula (Text) | Represents the key to match source data to a subscription item. |
ON_OrderNo2 | Formula (Text) | Optional, extends the field | |
ON_Subscription | ✅ | Lookup (Subscription) | Links to the related subscription after the object records have been successfully processed. Is empty by default. |
ON_Invoice | ✅ | Lookup (Invoice) | Links to the related invoice after the object records have been successfully billed. Is empty by default. |
ON_LastError | ✅ | Text (255) | Displays the error message if the transaction creation has failed. Is empty by default. |
ON_TargetSubscription | Lookup (Subscription) | Specifies the target subscription if there is more than one active subscription available. | |
ON_Account | ✅ | Formula (Text) | Specifies the Salesforce account ID or external ID, required if there is no or more than one account lookup on the object. |
ON_ParentAccount | Formula (Text) | Links to the related parent account. Subscriptions of the parent account will also be considered when building transactions. | |
ON_AddToTransactionTable | ✅ | Checkbox | Determines whether to show the itemized usage data records on the invoice, deselected by default. |
ON_AddToCsv | ✅ | Checkbox | Determines whether to export the itemized usage data records as CSV, deselected by default. |
ON_Criterion | Formula (Text) | Defines a criterion to aggregate defined transactions to one invoice line item. | |
ON_InvoiceCriterion | Formula (Text) | Defines a criterion to group items on the same invoice. |
Info
Depending on your use case and its requirements, you can add more fields in addition to the fields listed above. Using the ON Field Mechanism, JustOn fills and copies them to the generated invoices or invoice line items.
Data Fields
Data fields hold the actual usage data.
API Name | Required | Data Type | Description |
|---|---|---|---|
ON_Date | ✅ | Formula (Date)/ | Displays the date on which the usage data record is considered for invoicing. |
ON_Quantity | ✅ | Formula (Number) | Specifies the quantity or volume information as accumulated for the usage data record. |
ON_Price | Currency (13,5) | Specifies the net sales price of the usage data record. If set, takes precedence over the price defined on the subscription item. | |
ON_Title | Formula (Text) | Can specify an individual (product) title. If set, takes precedence over the title defined on the subscription item. |
Info
Depending on your use case and its requirements, you can add more fields in addition to the fields listed above. Using the ON Field Mechanism, JustOn fills and copies them to the generated invoices or invoice line items.
Note
Be aware that although JustOn usually does not create "tangible" transaction records, it still uses (transient) transactions to itemize the usage data. That is, any used data fields must be available on the custom object and on the transaction. Data fields on the custom object must have the same API name as the target field on the transaction, prefixed with ON_. Make sure that the data types are compatible.
For an overview of available fields on the transaction, see the Transaction object reference. If there is a field available for the piece of data you require, you must not create a new ON field on the transaction or the invoice line item, only on the custom object.
Price and Quantity Fields
Certain business use cases require individual (account-specific) prices, price tiers or quantity information for consumption data. To this end, you can add multiple price and quantity fields to the source object. An (account-specific) subscription item can then retrieve the intended value from the specified source field. Doing so usually requires to aggregate the relevant values from multiple source records.
Retrieving and aggregating individual source prices
If there are no specific field names defined on the item, the transaction builder uses the (standard) ON_Quantity and ON_Price fields on the source object.
The following subscription item fields are available to specify custom price or quantity source fields for usage data. The configuration differs depending on whether you retrieve the data directly from the usage data records or from transaction records.
Aggregating Additional Fields
Certain business use cases require additional data fields on the source object (see Data Fields), which are then to be aggregated for the (transient) transaction. You can define the aggregation to take place using the field Transaction Aggregation Fields on the subscription item.
Info
Make sure that the fields to be aggregated are available with the same name on the source object, the transaction and the invoice line item.
The field value aggregation is to be defined as a JSON expression using the following pattern:
{"FIELDNAME1":"FUNCTION","FIELDNAME2":"FUNCTION"}
The following aggregation functions are available:
Function | Supported Data Types | Description |
|---|---|---|
SUM | Numeric and string values | Adds up all values, preserves |
MIN | Numeric, Date and DateTime values | Selects the minimum of all values, preserves |
MAX | Numeric, Date and DateTime values | Selects the maximum of all values, preserves |
LAST | Numeric, string and Date values | Selects the last processed value. |
AVG | Numeric | Calculates the average value. |
Open the subscription item for which you want to define the additional data aggregation.
Click Edit.
In the field
Transaction Aggregation Fields, define the fields to be aggregated and the function to use as necessary.Click Save.
→ This enables the additional field aggregation during the transaction generation.
Enabling Transaction Display
When billing usage data, you can configure JustOn Billing & Invoice Management to attach transaction tables to the invoice, either
including a transaction table in the invoice PDF, or
attaching a transaction CSV file to the invoice.
Displaying Transaction Records on Invoices
You can configure JustOn to print a table of itemized usage data records (or, if applicable, transaction records) on an invoice. To this end, provide a corresponding configuration (in JSON notation) in the template field Transaction Records.
Open the template to be edited.
In the
Transaction Recordsfield, specify the transaction table configuration as required.Click Save.
Once set up as required, this triggers JustOn to create the transaction table and print it to the invoice PDF. For details about regenerating the table, see Creating New Transaction Tables.
Note
Make sure that the checkbox fields
ON_AddToTransactionTableon the source object (see Controlling Fields) andDisplayTransactionTableson the invoice
are selected.
Enabling Transaction Table Rebuild
Under certain circumstances, a user may need to rebuild the tables of itemized usage data records for an invoice. JustOn provides the option to do so. However, the button to trigger this operation may not be visible in the UI by default.
To enable the transaction table rebuild:
Navigate to the object management settings of the Invoice object.
Click Search Layouts.
Click Edit in the row of the Invoices List View.
In the Custom Buttons section, move
Rebuild Transaction Tablesto the Selected Buttons column.Click Save to save the modified page layout.
For help about modifying page layouts, see Managing Pages.
Attaching Transaction CSV to Invoices
You can configure JustOn to generate CSV files for itemized usage data records (or, if applicable, transaction records) to be attached to invoices. Use this functionality if the transaction tables as printed directly on invoices become too large or if you need the CSV files for a specific purpose.
To generate transaction CSV files, provide a corresponding configuration (in JSON notation) in the template field Transaction CSV.
Open the template to be edited.
In the
Transaction CSVfield, specify the transaction CSV file configuration as required.Click Save.
→ Once set up as required, this triggers JustOn to create the transaction CSV file and attach it to the invoice when finalizing the invoice. For details about regenerating the table, see Creating New Transaction Tables.
At the size of 2048 kB, JustOn splits the CSV attachment into a new file. So if there are many transaction records, JustOn produces multiple CSV files, putting a numbering to the file name like 2019-01515_Orders_All_1.csv,2019-01515_Orders_All_2.csv, etc.
Note
To have JustOn create and attach the transaction CSV files, make sure, in addition, that
The checkbox field
ON_AddToCsvon the source object (see Controlling Fields) is selectedIn the template field
Email File Types, CSV files are not excluded from being attached to emails.
With the field empty (default), all files, including CSV, are attached except for transaction table HTML (which is printed to the PDF).You execute a batch finalization.
Distributing Transactions Along Criterion
Usually, JustOn aggregates usage data records with the same key (ON_OrderNo, see Controlling Fields) and feeds the aggregated information into one subscription item. Certain business use cases may require, however, only particular usage data records (or, if applicable, transaction records) to be aggregated by a specific criterion. Doing so will split the item along the defined criterion and, consequently, produce multiple invoice line items.
To this end:
Set the field
ON_Criterionon the custom object.This can be a Formula (with the return type Text) or a Text field, which is then used to hold the actual distinguishing criterion.
Select the checkbox
Aggregate Indiv. Priced Transactionson the relevant subscription item(s).
→ Consequently, JustOn aggregates all usage data records with the same criterion to the same transaction and creates a single invoice line item.
Info
You can explicitly disable the aggregation feature for a subscription item by selecting the checkbox Ignore Item Criterion.
Note
Make sure not to confuse the item criterion ON_Criterion and the invoice criterion ON_InvoiceCriterion. They cover different use cases in different contexts. If necessary, the use cases can be combined, though.
When using price tiers, JustOn by default determines the price tier individually for each invoice line item as created on the basis of a specific transaction criterion. Selecting the checkbox Ignore Criterion For Price Tier Quantity, however, forces JustOn to ignore the criterion when determining the price tier.
Distributing Items to Multiple Invoices
Generally, the invoice run creates one invoice per subscription. Certain use cases, however, require usage data or items to be invoiced separately. To support this, JustOn makes use of invoice criteria, which are a means for controlling the distribution of invoice line items to multiple invoices. Only invoice line items with the same criterion are included in one invoice, others are invoiced separately.
To enable the invoice criterion when billing usage data, that is, when processing transactional items, add the field ON_InvoiceCriterion to the custom usage data object.
Navigate to the fields list of the relevant object.
Create the following new field.
Field Label | API Name | Data Type |
|---|---|---|
Invoice Criterion | ON_InvoiceCriterion | Text (255) |
For help about creating fields, see Managing Object Fields.
→ Using this field allows for grouping invoice line items. The scope of the criterion is limited to draft invoices, the current invoice run, and the service period of the current invoice run.
Info
If empty or not set, the invoice criterion is considered an empty criterion, which, consequently, does not distribute the invoice line items to multiple invoices.
Assigning Itemized Data to Specific Subscriptions
JustOn usually assigns the itemized usage data to items of the best matching subscription. Certain business use cases, however, require distributing the usage data to more than one subscription (using ON_ParentAccount, for example). You can explicitly define a subscription as the target for the usage data to prevent unwanted results in this case.
Using the checkbox field ON_ConversionTarget on the subscription, you can control this behavior.
Navigate to the fields list of the Subscription object.
Create the following new field.
API Name | Data Type | Description |
|---|---|---|
ON_ConversionTarget | Checkbox | Determines whether the usage data as converted from custom objects is assigned to the current subscription. |
For help about creating fields, see Managing Object Fields.
Info
If the field ON_ConversionTarget is missing or deselected on all subscriptions, JustOn assigns the usage data to the first matching subscription.
Enabling Usage Data Billing to Multiple Parties
Generally, the transaction builder is set up to bill usage data to one recipient, usually via the account associated to the corresponding subscription. Certain business use cases, however, require billing transactions to multiple parties.
To cover these needs, you apply the configuration explained in Enabling Multiple Party Billing, namely
In addition, enabling usage data billing to multiple recipients involves the following tasks:
Configuring transaction record display for multiple recipients
Optionally, configuring multiple currency billing
Creating Individual Subscriptions
To support multiple billing, you must create recipient-specific subscriptions with individual items.
Create two subscriptions as required – one for the merchant, and one for the buyer.
For details, see Creating Subscriptions.
Add the items to the two subscriptions as required.
Make sure thatThe billing type is set to
TransactionalEach item's value of the
OrderNofield matches one of the possible values of the custom object'sON_OrderNofield (see Configuring Custom Object)
For details, see Adding Items.
Configuring Transaction Record Display
To support multiple billing, you must configure two recipient-specific invoice templates with individually configured Transaction Records fields. To find the correct records, you must use the invoiceFieldName variable in the transaction table configuration.
Create and configure two recipient-specific templates – one for the merchant, and one for the buyer.
For details, see Working With Templates.
For each template, specify the transaction table configurations as required.
For details, see Displaying Transaction Records on Invoices
◾ Merchant-specific transaction table configuration:
[{
"active" : true,
"title" : "Billed Orders",
"name" : "Order",
"fields" : [ "EffectiveDate", "TotalAmount" ],
"invoiceFieldName" : "ON_InvoiceMerch__c"
}]
◾ Buyer-specific transaction table configuration:
[{
"active" : true,
"title" : "Billed Orders",
"name" : "Order",
"fields" : [ "EffectiveDate", "TotalAmount" ],
"invoiceFieldName" : "ON_InvoiceBuy__c"
}]
Building Transactions
When billing usage data, you usually create invoices and invoice line items directly out of objects that hold usage data. The continuous invoice run uses the transaction builder functionality to itemize the consumption data, but does not generate "tangible" transaction records. Specific use cases, however, may require to do so.
There are two ways to invoke the transaction builder to generate "tangible" transaction records:
Selecting a transaction filter when executing an invoice run
Using a transaction build job
Building Transactions Before Invoice Run
When executing an invoice run, users are prompted to select a transaction filter. If they choose to do so, JustOn runs the transaction build process before executing the invoice run.
Create a transaction filter with the use case
Transactionas necessary.For details, see Creating Transaction Filter.
Perform the invoice run.
When prompted, select the relevant transaction filter.
For details, see Executing an Invoice Run.
→ This generates both transaction records and draft invoices.
Info
You can also define a transaction filter as a parameter when setting up a scheduled parameterized invoice run.
Building Transactions Using a Scheduled Job
You can set up a job in order to have transactions built automatically on a regular basis. This involves the following subtasks:
Creating a batch parameters custom setting to include the transaction filter
Scheduling the transaction build job
Creating Transaction Filter
Create a transaction filter with the use case
Transactionas necessary.
Note that the filter name (for example, transaction1) is passed as a parameter to the batch parameters setting.For details, see Creating Transaction Filter.
Creating Batch Parameters Setting
To pass the transaction filter to the transaction build process, you create a specific batch parameters setting. This setting combines the batch chain to be executed (TransactionBuilderChain) with the filter as a specific execution argument.
Click ⚙️ to enter Setup, then open Custom Settings.
In Salesforce Lightning, navigate to Custom Code > Custom Settings.
In Salesforce Classic, navigate to Develop > Custom Settings.
Click Manage in the row of Batch Parameters.
Click New.
Specify the details as required.
Name: The name for the batch parameters setting, must match the name of the transaction build job, for example
buildtransactionsBatch Chain:
TransactionBuilderChainParameter 1: A parameter to be passed to the batch chain (pattern
parameter = value).Assuming the transaction filter name is
transaction1, setCODETransactionFilters = transactions1
Click Save.
Scheduling Transaction Build Job
To schedule the transaction build process, you can use either JustOn's Scheduled Jobs page or Salesforce's Schedule Apex functionality. For details, see Scheduling a Job.
Via JustOn's Scheduled Jobs page:
Open the Scheduled Jobs page.
Use the following URL
https://login.salesforce.com/apex/ONB2__JobsSetup, or, if you are already logged in, appendapex/ONB2__JobsSetupto your org's domain name.
You can access the Scheduled Jobs page via the JustOn configuration app ( ❓ > JustOn Configuration > Jobs Setup).From the
Apex Jobdrop-down list, selectBatch Chain Job.In the
Job Namefield, specify the name of the batch parameters setting, for examplebuildtransactions.From the
Start Timedrop-down list, select the preferred execution time.Optionally, edit the displayed cron expression to adjust the execution time.
Click Schedule.
→ This sets up the transaction build process to be executed at the specified time.
Info
From the Scheduled Jobs page, you can also run the batch chain immediately.
Via Salesforce's Schedule Apex functionality:
Click ⚙️ to enter Setup, then open Apex Classes.
In Salesforce Lightning, navigate to Custom Code > Apex Classes.
In Salesforce Classic, navigate to Develop > Apex Classes.
Click Schedule Apex on top of the list.
Specify the details as required.
Job Name: The name of the batch parameters setting, for example
buildtransactionsApex Class:
ScheduledBatchChainFrequency:
WeeklyorMonthly(with an according weekday or day of month setting)Start
End
Preferred Start Time
Click Save.
This sets up the transaction build process to be executed at the specified time.
For more details about job scheduling, see Scheduling a Job in the JustOn documentation and Schedule Apex in the Salesforce Help.
Transaction and Transaction Details
Usually, each transaction results in an individual invoice line item. Certain business use cases, however, require transactions to be aggregated but still keeping individual records for transaction tables. To this end, JustOn supports transaction details, which are in a master-detail relationship with transactions.
Info
The field ON_Type, which is required on the usage data source object, controls whether to produce a transaction or a transaction detail, setting either Transaction or Detail, respectively.
For aggregating values, JustOn makes use of roll-up summary fields that sum up specific fields over all transactions details that belong to a specific transaction. The field Transaction on the transaction detail shows the parent transaction.
The following transaction fields are relevant for the transaction detail aggregation:
Transaction Field | Type | Child Field | Description |
|---|---|---|---|
Commission Tier Price (A) | Roll-Up Summary (SUM) | Commission Tier Price | The sum of all single transaction commission tier prices. |
Date (A) | Roll-Up Summary (MAX) | Date | The last date of all related transaction details. |
Price (A) | Roll-Up Summary (SUM) | Calculated Price | The sum of all transaction detail prices. |
Price Tier Quantity (A) | Roll-Up Summary (SUM) | Price Tier Quantity | The sum of all single transaction price tier quantities. |
Is Aggregated | Formula (Checkbox) | Determines that the aggregated fields are to be used if there are transaction details available. | |
Is Individually Priced | Formula (Checkbox) | Determines whether this transaction is individually priced. Is | |
Quantity (A) | Formula (Number) | The quantity for all single transactions. It is set to | |
Service Period End (A) | Roll-Up Summary (MAX) | Service Period End | The last service period end date of all related transaction details. |
Service Period Start (A) | Roll-Up Summary (MIN) | Service Period Start | The first service period start date of all related transaction details. |
Single Count | Roll-Up Summary (COUNT) | The number of related transaction details. | |
Single Individual Count | Roll-Up Summary (COUNT, | The number of all individually priced transaction details, required to determine the aggregated transactions with individual pricing. | |
Sum of Quantity | Roll-Up Summary (SUM) | Quantity | The raw sum of all transaction detail quantities, used internally by |
Note
If Is Aggregated is true, the roll-up fields (suffixed (A)) are used during the invoice run. The values of the original fields Date, Price, Price Tier Quantity, Quantity, Service Period Start and Service Period End are ignored in this case.
For a complete list of available transaction and transaction detail fields, see Transaction and Transaction Detail.
Periodically Aggregating Transaction Details
When using transactions and transaction details, JustOn by default adds the transaction details to the newest transaction that has not yet been billed. Certain business use cases, however, require transactions to aggregate the transaction details of a specific period. To this end, you can define an aggregation period on a subscription.
Open the subscription for which you want to set an aggregation period.
Click Edit.
Set the aggregation period as necessary.
The following options are available:
Weekly: Aggregation period Monday - SundayBi-Weekly: Aggregation periods 1st of month - 15th of month and 16th of month - last of monthMonthly: Aggregation period 1st of month - last of month
Click Save.
→ This enables the periodical aggregation of transaction details. JustOn creates a transaction for every period in which transaction details have occurred, adds transaction details until the period end, and creates a new transaction after a new period has started.