action.skip

Best Practice: Selective Multiple-Party Billing

Generally, JustOn Billing & Invoice Management is set up to issue invoices to one recipient, usually via the account associated to the corresponding source record. Certain business use cases, however, may require selectively billing to multiple parties – that is, invoicing the same type of data to only one of the parties based on some conditions.

Assume, for example, a service company that invoices service items either to end customers at a fixed price, or to partners based on the time used. Basically, you combine JustOn's multiple party billing with the arbitrary object billing and usage data billing. But key to this use case is a configuration that determines the "target party" for the invoice.

An implementation of this scenario with Salesforce and JustOn may be:

(1) Both end customers and partners are represented as accounts, which can request services.

(2) For every service case, you create a case with (custom) case items attached, which represent the individual service items to be invoiced.

  • Cases and case items are specifically prepared to be invoiced to either end customers with fixed prices per item, applying arbitrary object billing, or partners for the time used, applying usage data billing.

    This includes specific quantity field configurations to control the "target" for invoicing the case item. Use recipient-specific quantity fields and corresponding formulas that set the quantity 0 in order to exclude records from being invoiced for partners if they are meant for end customers, and vice versa.

  • As the consumption data – the time used for partners – is to be matched with subscription items for the invoice generation, there is a "target" subscription and corresponding item for each partner account.

(3) For end customers, you execute a generic invoice run that produces invoices from the cases and case items with the defined fixed prices.

(4) For partners, you execute a continuous invoice run – JustOn itemizes the tracked time data, matches it against the defined subscription item and evaluates the provided quantity information, calculating the item's subtotal.

uc_gir+cir
Invoicing products to multiple accounts, combining generic and usage billing

Modeling this business use case comprises the configuration tasks as listed below.

To set up the fixed-price billing from cases for end customers:

To set up the time-based billing from cases for partners:

Once set up as outlined, you can execute the invoice run – applying one or the two filters in order to create invoices for the end customers or the partners, or both.

Info

Remember that this article describes one of several possible ways to implement this business use case. The appropriate setup may vary depending on your individual business requirements.

Preparing Case and Case Item for Generic Invoice Run

Both the Case object and the Case Item object require a number of ON fields to hold the information that is necessary for the generic invoice run.

To configure the Case object:

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

    API Name Data Type Example Value
    ON_AccountCust Formula (Text) AccountId (Salesforce account ID)
    ON_InvoiceBuildErrorCust Text(255)
    ON_InvoiceCust Lookup (Invoice)
    ON_InvoiceRunCust Lookup (Invoice Run)
    ON_ServiceDateCust Formula (Date)/Formula (Date/Time) Service_Date
    ON_TemplateCust Formula (Text) Salesforce record ID

To configure the Case Item object:

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

    API Name Data Type Example Value
    ON_QuantityCust Formula (Number) as necessary
    ON_TitleCust Formula (Text) Product_Name__c
    ON_UnitPriceCust Formula (Currency) UnitPrice

    Info

    Using the quantity formula, you set the quantity 0 to exclude records from being invoiced to end customers if certain conditions are true. In this case (with the quantity 0), the record is invoiced to partners.

    Assume, for example, you want service cases to be invoiced to partners if they are subject to a promotion, which is saved in the Product Cluster field. Your formula may look like

    IF(CASE(Product_Cluster_Text__c = 'Promotion', 0, Quantity))
    

    Now if the product cluster is Promotion, the quantity is set 0, and consequently, the case item is not invoiced to end customers but to partners. Otherwise, the determined quantity is applied and consequently, the case item is invoiced to the end customer.

Creating Generic Invoice Run Filter

To define which records to include in the generic invoice run, you create a custom filter.

  1. 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.

  2. Click Manage in the row of Filters.

  3. Create a filter for the transaction build.

    Field Example Value
    Name Item
    Target Case
    Transactional Suffix Cust
    Use Case Generic
    Child Relation CaseItems
    Condition as necessary

    For details, see Creating Invoice Run Filter.

Creating Subscription and Item

As the consumption data – the time used for partners – is to be matched with a subscription item for the invoice generation, you create a "target" subscription and corresponding item for each partner account:

  1. Create the subscription as required.

    For details, see Creating Subscriptions.

  2. Add the item to the subscription as required.

    Following the solution approach, you create an item to match the tracked time.

    The mandatory parameters include:

    Field Example Value
    Title Worked Time
    Billing Type Transactional
    OrderNo TIME

    For details, see Adding Items.

Note

Make sure that the item's value of the OrderNo field matches the value of the usage data object's ON_OrderNo field (see Preparing Case Item for Usage Data Billing).

Preparing Case Item for Usage Data Billing

To itemize consumption data, JustOn's transaction builder requires a number of ON fields (controlling fields and data fields) on the object that holds usage data. Following the example, you configure the Case Item object accordingly.

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

    Controlling fields (with recipient-specific suffix, as explained here)

    API Name Data Type Example Value
    ON_AccountPar Formula (Text) Case.AccountId
    ON_AddToCsvPar Checkbox Default Value: Unchecked
    ON_AddToTransactionTablePar Checkbox Default Value: Unchecked
    ON_InvoicePar Lookup(Invoice)
    ON_LastErrorPar Text(255)
    ON_OrderNoPar Formula (Text) TIME
    ON_SubscriptionPar Lookup (Subscription)
    ON_TypePar Formula (Text) Transaction

    Data fields

    API Name Data Type Example Value
    ON_Date Formula (Date) Case.Service_Date
    ON_Price Formula (Currency) UnitPrice
    ON_Quantity Formula (Number) as necessary

    Info

    Using the quantity formula, you determine whether the quantity for end customers is 0. Following the example, this indicates that the case item is part of a promotion (as outlined above), and is to be paid by the partner. Consequently, you apply the tracked quantity to invoice the item to the partner.

    If the quantity for end customers is not 0, the formula sets the quantity for partners to 0. This excludes the item from being invoiced to partners, and applies the quantity to invoice it to the end customer.

    The corresponding formula may look like

    IF(ON_QuantityCust__c = 0, Quantity, 0)
    

Creating Transaction Filter

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

  1. 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.

  2. Click Manage in the row of Filters.

  3. Create a filter for the transaction build.

    Field Example Value
    Name Time
    Target Case
    Transactional Suffix Par
    Use Case Continuous
    Condition as necessary

    For details, see Creating Transaction Filter.

Setting Up Invoice Run

Once set up as outlined, you can execute the invoice run – applying one or the two filters in order to create invoices for the end customers or the partners, or both.

To set up the invoice run, you schedule a parameterized invoice run with the corresponding invoice run filter and transaction filter added as a parameter.

Setting up a parameterized invoice run involves two steps:

  • Defining parameters for the batch chain
  • Scheduling the batch chain

Configuring Batch Chain Parameters

  1. 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.

  2. Click Manage in the row of Batch Parameters.

  3. Click New.
  4. Specify the details as required.

  5. Click Save.

Scheduling Batch Chain

To schedule the batch chain, 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:

  1. Open the Scheduled Jobs page.

    Use the following URL https://login.salesforce.com/apex/ONB2__JobsSetup, or, if you are already logged in, append apex/ONB2__JobsSetup to your org's domain name.

    You can access the Scheduled Jobs page via the JustOn configuration app ( > JustOn Configuration > Jobs Setup).

  2. From the Apex Job drop-down list, select Batch Chain Job.

  3. In the Job Name field, specify the name of the batch parameters setting created before.
  4. From the Start Time drop-down list, select the preferred execution time.

    Your business may require to schedule multiple invoice runs. In order to prevent concurrent access to records or batch job limitations, they should, however, not run in parallel. Therefore, JustOn recommends to involve a certain time delay between the scheduled invoice runs – for example, one at 00:00, the next at 01:00, and so on. The interval may vary depending on the amount of records to be processed.

  5. Click Schedule.

    This sets up the invoice run to be executed on a regular basis at the specified time with the additional parameters set.

Info

From the Scheduled Jobs page, you can also run the batch chain immediately.

Via Salesforce's Schedule Apex functionality:

  1. 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.

  2. Click Schedule Apex on top of the list.

  3. Specify the details as required.

    Your business may require to schedule multiple invoice runs. In order to prevent concurrent access to records or batch job limitations, they should, however, not run in parallel. Therefore, JustOn recommends to involve a certain time delay between the scheduled invoice runs – for example, one at 00:00, the next at 01:00, and so on. The interval may vary depending on the amount of records to be processed.

  4. Click Save.

    This sets up the invoice run to be executed on a regular basis at the specified time with the additional parameters set.

For more details about job scheduling, see Scheduling a Job in the JustOn documentation and Schedule Apex in the Salesforce Help.