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:
- REST, see REST API Developer Guide
- SOAP, see SOAP API Developer Guide
- Data Loader (Bulk), see Data Loader Guide
- Apex, see Apex Developer Guide
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. 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
You can trigger the balance fix or balance deletion using a process on balances that calls the appropriate Apex class 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 process setup will vary.
-
In Setup, open Process Builder.
In Salesforce Lightning, navigate to Process Automation > Process Builder.
In Salesforce Classic, navigate to Create > Workflow & Approvals > Process Builder.
-
Click New.
- Specify a (descriptive) process name.
- Set the process to start when
A record changes
. -
Configure the process as required.
To trigger the balance fix:
Step Option Description Add Object Object The object whose modifications are to trigger the balance fix, must be Balance
Start the process The type of record change that triggers the process, must be when a record is created or edited
Add Criteria Criteria for Executing Actions The type of criteria, determines whether to check for specific field values or to evaluate records using a formula Set Conditions | Build Formula The use case-specific criteria, either the filter conditions for evaluating field values or the formula Add Action Action Type The type of action to be executed, must be Apex
Apex Class The Apex class to be executed, must be Fix Balances
Set Apex Variables Invocable variables for the Apex class balanceIds
specifies the reference to the ID field of the balances to be fixedTo trigger the balance deletion:
Step Option Description Add Object Object The object whose modifications are to trigger the balance deletion, must be Balance
Start the process The type of record change that triggers the process, must be when a record is created or edited
Add Criteria Criteria for Executing Actions The type of criteria, determines whether to check for specific field values or to evaluate records using a formula Set Conditions | Build Formula The use case-specific criteria, either the filter conditions for evaluating field values or the formula Add Action Action Type The type of action to be executed, must be Apex
Apex Class The Apex class to be executed, must be Delete or unregister Balances
Set Apex Variables Invocable variables for the Apex class Unregister only
Boolean value that controls whether to only unassign balances from invoices (True
) or to unassign and delete them (False
)Balance Id
specifies the reference to the ID field of the balances to be deleted -
Click Save.
-
Click Activate.
For help about creating processes, see Lightning Process Builder in the Salesforce Help.