Skip to content

Balance Import and Fix

JustOn 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

The balance import fixing feature is available as of JustOn 2.49.

This section

  • 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 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 Required Possible Values 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 | false If true, the balance is considered as a draft and ignored in business processes.

All other balance fields are optional.

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 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/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
}

Process Configuration

It is possible to configure a process on balances and trigger the balance fixing and deleting processes. This is useful, for example, if you create balances from a flow or do not want to call the REST endpoint.

  1. In Setup, open Process Builder.

    In Salesforce Lightning, navigate to Process Automation > Process Builder.

    In Salesforce Classic, navigate to Create > Workflow & Approvals > Process Builder.

  2. Create the following process(es) as required.

    Option Value Description
    Object Balance The process must run on the Balance object when a record is created or edited.
    Criteria Select the conditions that meet your business requirements best.
    Immediate Action Apex > Fix balances
    or
    Apex > Delete or unregister Balances
    Set the IDs of the balances to be fixed as the input parameter.
    DelBalancesApi also requires the parameter unregisterOnly.

    For help about creating processes, see Create a Process in the Salesforce Help.