action.skip

Setting Up Balance Import and Fix

← Configuring Reconciliation/Settlements

JustOn Billing & Invoice Management allows for importing balances and creating balance records without using JustOn's business processes. This is necessary, for example, for integrating payment processes of other systems in JustOn.

Usually, creating balances and registering them with invoices requires user interaction, like when assigning payment entries or when manually assigning or unssigning balances. Using the balance import fixing feature, you can insert and register as well as unregister and delete balances via API calls.

Info

Generally, importing balances from a third-party system is a two-step procedure:

Import (draft) balance records
↳ Execute fixing process

This article

  • Specifies the required data fields for balance imports
  • Describes the fixing process
  • Describes the deleting process
  • Outlines the options for invoking the balance fixing process and balance deleting process.

Info

The actual balance import is project-specific and therefore not covered with this documentation. Generally, you can use any Salesforce API to insert records:

Balance Record Data

The following fields are required to insert a balance record:

Field Label API Name Value Description
Account ONB2__Account__c Salesforce account ID A balance must be associated with an existing account in Salesforce.
Amount ONB2__Amount__c Positive or negative amount values Negative amounts represent payments, positive amounts represent refunds or payouts.
Draft ONB2__Draft__c true Imported balances must be draft.
Date ONB2__Date__c date The effective date of the balance.
Invoice ONB2__Invoice__c invoice number The related invoice.
Write-Off Reason ONB2__WriteOffReason__c string The reason why the amount has been written off.
Required for imported balances of the type Write-Off.

Info

Remember that balances to be imported must be set as draft. The import fixing process removes this setting and, if all required data is available, associates the balances with the corresponding invoices.

Imported Balances Fix

Draft balances are ignored by JustOn. They need to be processed by a specific JustOn API in order to be acknowledged in business processes.

The import fixing process

  • Removes the Draft setting for the balance to be considered by JustOn,
  • Can insert and register balances,
  • Ensures that invoice balance amounts and their statuses are consistent.

JustOn provides several options for invoking the balance fixing process.

Synchronous Execution From APEX Code

If the number of balances is small (< 10) and your APEX code is guaranteed to run sequentially (no triggers, no queueables, no batch processes, no external parallelization), you may call the global API directly:

List<Id> balanceIds = new List<Id>(); //provide the IDs of draft balances which need to be fixed

ONB2.FixBalancesApi.fromProcess(balanceIds);

REST Endpoint Call

JustOn allows you to fix balances via REST. Please note that the number of balances that can be fixed in one call is limited.

JustOn accepts an HTTP POST request at the following endpoint:

https://INSTANCE.salesforce.com/services/apexrest/ONB2/FixBalancesApi

The body of the request must be in JSON format and contain a list of balance IDs to be fixed:

{ "balanceIds": [ /* ids */ ] }

Balances Deletion

Balances can also be unlinked from invoices or deleted.

JustOn provides several options for invoking the balance deleting process.

Synchronous Execution From APEX Code

If the number of balances is small (< 10) and your APEX code is guaranteed to run sequentially (no triggers, no queueables, no batch processes, no external parallelization), you may call the global API directly:

ONB2.DelBalancesApi.DelBalanceRequest request1 = new ONB2.DelBalancesApi.DelBalanceRequest();
request1.balanceId = 'a020N000015CE9O'; // provide the Id of the balance to be deleted
request1.unregisterOnly = false;        // delete or unregister (invoice) the balance

List<ONB2.DelBalancesApi.DelBalanceRequest> requests = new List<ONB2.DelBalancesApi.DelBalanceRequest>{
    request1
};

ONB2.DelBalancesApi.fromProcess(requests);

REST Endpoint Call

JustOn allows you to delete balances via REST as well. Please note that the number of balances that can be fixed in one call is limited.

JustOn accepts an HTTP POST request at the following endpoint:

https://INSTANCE.salesforce.com/services/apexrest/ONB2/DelBalancesApi

The body of the request must be in JSON format and contain a list of balance IDs to be fixed:

{
    "balanceIds": [ /* ids */ ],
    "unregisterOnly": false
}

Flow Configuration

You can trigger the balance fix or balance deletion using a flow on balances that calls the appropriate Apex class (Fix Balances or Delete or unregister Balances) provided by JustOn. This is useful, for example, if you create balances from a flow or do not want to call the REST endpoint.

Note

Depending on your use cases, the criteria for executing the flow will vary.

  1. Click to enter Setup, then navigate to Process Automation > Flows.
  2. Click New Flow.
  3. Select Record-Triggered Flow and click Create.
  4. Configure the Start element.

    Option Description
    Object The object whose record modifications are to update a source record, must be Balance
    Trigger The type of record change that triggers the flow, must be A record is created or updated
    Conditions The use case-specific trigger conditions, one or more filter criteria for evaluating certain field values or a formula for evaluating records
    Optimize for Actions and Related Records
  5. Click and add the Action element as required.

    To trigger the balance fix:

    Option Description
    Action The Apex class to call, must be Fix Balances
    Input Values Invocable variables for the Apex class
    balanceIds: specifies the reference to the ID field of the balances to be fixed, like {!$Record.Id}

    To trigger the balance deletion:

    Option Description
    Action The Apex class to call, must be Delete or unregister Balances
    Input Values Invocable variables for the Apex class
    Balance Id: specifies the reference to the ID field of the balances to be deleted, like {!$Record.Id}
    Unregister only: Boolean value that controls whether to only unassign balances from invoices ({!$GlobalConstant.True}) or to unassign and delete them ({!$GlobalConstant.False})

    Specify a label and an API name as required.

  6. Click Save.

    Specify a label and an API name as required.

  7. Click Activate.

    When the defined conditions are met, JustOn will trigger the balance fix or the balance deletion, respectively.

    For help about creating flows, see Flows in the Salesforce Help.