Billing Central Apex API Developer Reference

ffbc.ConsolidationService

global with sharing class ConsolidationService

This class provides functionality to perform consolidation of billing documents, add billing documents to an existing consolidated document, and to undo the consolidation of billing documents. You must enable the Billing Document Consolidation feature in Feature Console before using the service.

Methods

addBillingDocumentsToConsolidate

global static ffbc.ConsolidationService.ConsolidationResponse addBillingDocumentsToConsolidate(ffbc.ConsolidationService.AdditionRequest request)

Adds billing documents with "Draft" document status to a consolidated billing document with "Draft" document status. The original and consolidated billing documents must have the same value for the Document Type, Currency, Company, and Account fields. The original billing documents must have line items.
If DocumentDate and DueDate are supplied, they override the existing values on the consolidated billing document. Checkboxes that contain conflicting values have the default value of the checkbox on the consolidated document. All other fields on the consolidated billing document are unchanged.

Input Parameters

Name Type Description
request ffbc.ConsolidationService.AdditionRequest Contains the information needed to consolidate the additional billing documents.

Return Value

A response containing the results of the AdditionRequest.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

/**
 * Example of using addBillingDocumentsToConsolidate() method of ConsolidationService API
 * Variables marked by asterisks need to be queried from your organisation's data.
 */

//Set of additional billing documents to be consolidated, identified by ID.
Set<Id> setOfBillingDocumentIds = New Set<Id> {*billingDocumentIds*};

ffbc.ConsolidationService.AdditionRequest request = new ffbc.ConsolidationService.AdditionRequest(setOfBillingDocumentIds);
request.ConsolidatedBillingDocumentId = *consolidatedBillingDocumentId*;
//If the DocumentDate is not specified then it will be set to today's date in the header of the consolidated billing document.
request.DocumentDate = *requestDocumentDate*;
//If the DueDate is not specified then it will be calculated automatically as described in the Properties table of the ConsolidationRequest class.
request.DueDate = *requestDueDate*;
ffbc.ConsolidationService.ConsolidationResponse response = ffbc.ConsolidationService.addBillingDocumentsToConsolidate(request);

consolidate

global static ffbc.ConsolidationService.ConsolidationResponse consolidate(ffbc.ConsolidationService.ConsolidationRequest request)

Consolidates the supplied billing documents provided that they are valid and at least two billing documents are in the request. The billing documents are valid if all of the following are true:
- Their Document Type, Currency, Company, and Account fields have the same value.
- Any mandatory custom fields must have the same value.
- Their Document Status is “Draft”.
- They have billing document line items.
If DocumentDate and DueDate are supplied, they override the existing values on the consolidated billing document. Checkboxes that contain conflicting values have the default value of the checkbox on the consolidated document. All other fields on the consolidated billing document are unchanged

Input Parameters

Name Type Description
request ffbc.ConsolidationService.ConsolidationRequest Contains the information needed to consolidate billing documents.

Return Value

A response containing the results of the ConsolidationRequest.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

/**
 * Example of using consolidate() method of ConsolidationService API
 * Variables marked by asterisks need to be queried from your organisation's data.
 */

//Set of billing documents to be consolidated, identified by ID.
Set<Id> setOfBillingDocumentIds = New Set<Id> {*billingDocumentIds*};

ffbc.ConsolidationService.ConsolidationRequest request = new ffbc.ConsolidationService.ConsolidationRequest(setOfBillingDocumentIds);
//If the DocumentDate is not specified then it will be set to today's date in the header of the consolidated billing document.
request.DocumentDate = *requestDocumentDate*;
//If the DueDate is not specified then it will be calculated automatically as described in the Properties table of the ConsolidationRequest class.
request.DueDate = *requestDueDate*;
ffbc.ConsolidationService.ConsolidationResponse response = ffbc.ConsolidationService.consolidate(request);

consolidateAsync

global static ffbc.ConsolidationService.ConsolidationAsyncResponse consolidateAsync(ffbc.ConsolidationService.ConsolidationAsyncRequest request)

Consolidates the supplied billing documents using a background process. Draft billing documents are grouped together using the supplied consolidation grouping method. Billing documents with a status other than “Draft”, documents without line items, and documents that cannot be grouped with another are excluded from consolidation.
If DocumentDate and DueDate are supplied, they override the existing values on the consolidated billing documents. Checkboxes that contain conflicting values have the default value of the checkbox on the consolidated document. All other fields on the consolidated billing document are unchanged.

Input Parameters

Name Type Description
request ffbc.ConsolidationService.ConsolidationAsyncRequest Contains the information needed to consolidate billing documents in a background process.

Return Value

A response containing the results of the ConsolidationAsyncRequest.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

/**
 * Example of using consolidateAsync() method of ConsolidationService API
 * Variables marked by asterisks need to be queried from your organisation's data.
 */

//Set of billing documents to consolidate asynchronously, identified by ID.
Set<Id> setOfBillingDocumentIds = New Set<Id> {*billingDocumentIds*};

ffbc.ConsolidationService.ConsolidationAsyncRequest request = new ffbc.ConsolidationService.ConsolidationAsyncRequest(setOfBillingDocumentIds);
request.GroupingRuleId = *consolidationGroupingMethodId*;

//If the ExecutionDescription is not specified then it will be set to the name of the consolidation grouping method, followed by the current date and time. 
request.ExecutionDescription = *executionDescription*;

//If the DocumentDate is not specified then it will be set to today's date in the header of the consolidated billing document.
request.DocumentDate = *requestDocumentDate*;

//If the DueDate is not specified then it will be calculated automatically as described in the Properties table of the ConsolidationRequest class.
request.DueDate = *requestDueDate*;

ffbc.ConsolidationService.ConsolidationAsyncResponse response = ffbc.ConsolidationService.consolidateAsync(request);

consolidateWithRulesAsync

global static List<ffbc.ConsolidationService.ConsolidationAsyncResponse> consolidateWithRulesAsync(List<ffbc.ConsolidationService.ConsolidationWithRuleAsyncRequest> requests)

Runs the consolidation process using the supplied list of consolidation rules. Parallel background processes are started for each valid consolidation rule in the set.
A consolidation rule is valid if all of the following are true:
- It is not being currently used in another consolidation process.
- Its Consolidation Grouping Method field is populated.
- Its Record Filter field is populated with a filter that retrieves billing documents with the "Draft" status.
The record filter linked to the rule selects billing documents. Once retrieved, the billing documents are grouped together by the related consolidation grouping method and consolidated in the background process.
If DocumentDate is supplied, it overrides the existing values on the consolidated billing documents. Checkboxes that contain conflicting values have the default value of the checkbox on the consolidated document. All other fields on the consolidated billing document are unchanged.

Input Parameters

Name Type Description
requests List<ffbc.ConsolidationService.ConsolidationWithRuleAsyncRequest> List of ConsolidationWithRuleAsyncRequest instances. Each ConsolidationWithRuleAsyncRequest contains the information needed to run the consolidation process using a consolidation rule.

Return Value

A list of responses containing the results of each ConsolidationWithRuleAsyncRequest.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

/**
 * Example of using consolidateWithRulesAsync() method of ConsolidationService API
 * Variables marked by asterisks need to be queried from your organisation's data.
 */

ffbc.ConsolidationService.ConsolidationWithRuleAsyncRequest request1 = new ffbc.ConsolidationService.ConsolidationWithRuleAsyncRequest();
request1.ConsolidationRuleId = *consolidationRule1Id*;

//If the ExecutionDescription is not specified then it will be set to the name of the consolidation rule, followed by the current date and time. 
request1.ExecutionDescription = *executionDescription*;

//If the DocumentDate is not specified then it will be set to today's date in the header of the consolidated billing document.
request1.DocumentDate = *requestDocumentDate*;

ffbc.ConsolidationService.ConsolidationWithRuleAsyncRequest request2 = new ffbc.ConsolidationService.ConsolidationWithRuleAsyncRequest();
request2.ConsolidationRuleId = *consolidationRule2Id*;
request2.ExecutionDescription = *executionDescription*;
request2.DocumentDate = *requestDocumentDate*;

List<ConsolidationService.ConsolidationWithRuleAsyncRequest> requests = new List<ConsolidationService.ConsolidationWithRuleAsyncRequest>{request1, request2};

List<ConsolidationService.ConsolidationAsyncResponse> responses = ffbc.ConsolidationService.consolidateWithRulesAsync(requests);

undoConsolidation

global static ffbc.ConsolidationService.UndoConsolidationResponse undoConsolidation(ffbc.ConsolidationService.UndoConsolidationRequest request)

Undoes consolidation of the supplied billing documents provided that they are valid. The billing documents are valid if all of the following are true:
- They are identified as consolidated (the Consolidated flag is set to true).
- Their Document Status is "Draft".
- They have billing document line items.
- All the billing document lines are linked to an original billing document that has the Document Status "Superseded" or "Draft".

Input Parameters

Name Type Description
request ffbc.ConsolidationService.UndoConsolidationRequest Contains the information needed to undo consolidation of billing documents.

Return Value

A response containing the results of the UndoConsolidationRequest.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

/**
 * Example of using undoConsolidation() method of ConsolidationService API
 * Variables marked by asterisks need to be queried from your organisation's data.
 */

//Set of billing documents to undo consolidation, identified by ID.
Set<Id> setOfBillingDocumentIds = New Set<Id> {*billingDocumentIds*};

ffbc.ConsolidationService.UndoConsolidationRequest request = new ffbc.ConsolidationService.UndoConsolidationRequest(setOfBillingDocumentIds);
ffbc.ConsolidationService.UndoConsolidationResponse response = ffbc.ConsolidationService.undoConsolidation(request);

undoConsolidationAsync

global static ffbc.ConsolidationService.UndoConsolidationAsyncResponse undoConsolidationAsync(ffbc.ConsolidationService.UndoConsolidationRequest request)

Undoes consolidation of the supplied billing documents using a background process, provided the documents are valid. The billing documents are valid if all of the following are true:
- They are identified as consolidated (the Consolidated flag is set to true).
- Their Document Status is "Draft".
- They have billing document line items.
- All the billing document lines are linked to an original billing document that has the Document Status "Superseded" or "Draft".

Input Parameters

Name Type Description
request ffbc.ConsolidationService.UndoConsolidationRequest Contains the information needed to undo consolidation of billing documents in a background process.

Return Value

A response containing the results of the UndoConsolidationRequest.

Sample Code

//Note: This sample code is for demonstration purposes only. It is not intended for
//use in a production environment, is not guaranteed against defects or errors, and
//is in no way optimized or streamlined.

/**
 * Example of using undoConsolidationAsync() method of ConsolidationService API
 * Variables marked by asterisks need to be queried from your organisation's data.
 */

 //Set of billing documents to undo consolidation, identified by ID.
Set<Id> setOfBillingDocumentIds = new Set<Id> {*billingDocumentIds*};

ffbc.ConsolidationService.UndoConsolidationRequest request = new ffbc.ConsolidationService.UndoConsolidationRequest(setOfBillingDocumentIds);
ffbc.ConsolidationService.UndoConsolidationAsyncResponse response = ffbc.ConsolidationService.undoConsolidationAsync(request);

ffbc.ConsolidationService.AdditionRequest

global with sharing class AdditionRequest extends ConsolidationRequest

This class provides the information required to add billing documents to a consolidated billing document. If DocumentDate and DueDate are not supplied, they are resolved as detailed in the Properties table of the inherited class.

This class extends ffbc.ConsolidationService.ConsolidationRequest

Properties

Name Type Description
ConsolidatedBillingDocumentId Id The consolidated billing document, identified by ID.

Methods

AdditionRequest

global AdditionRequest(Set<Id> BillingDocumentIds)

Creates a new AdditionRequest for the given BillingDocumentIds.

Input Parameters

Name Type Description
BillingDocumentIds Set<Id> Set of additional billing documents to be consolidated, identified by ID.

ffbc.ConsolidationService.ConsolidationAsyncRequest

global with sharing class ConsolidationAsyncRequest extends ConsolidationRequest

This class provides the information required to consolidate billing documents using a background process. If DocumentDate and DueDate are not supplied, they are resolved as detailed in the Properties table of the inherited class.

This class extends ffbc.ConsolidationService.ConsolidationRequest

Properties

Name Type Description
GroupingRuleId Id Method used to group billing documents for consolidation, identified by ID.
ExecutionDescription String Optional. Description of the consolidation background process. If null, defaults to the name of the grouping method followed by the current time and date.

Methods

ConsolidationAsyncRequest

global ConsolidationAsyncRequest(Set<Id> BillingDocumentIds)

Creates a new ConsolidationAsyncRequest for the given BillingDocumentIds.

Input Parameters

Name Type Description
BillingDocumentIds Set<Id> The IDs of the billing documents to be consolidated.

ffbc.ConsolidationService.ConsolidationWithRuleAsyncRequest

global with sharing class ConsolidationWithRuleAsyncRequest

This class provides the information required to run the consolidation using a consolidation rule. If DocumentDate and ExecutionDescription are not supplied, they are resolved as detailed in the Properties table below.

Properties

Name Type Description
ConsolidationRuleId Id Consolidation rule used to select and group billing documents for consolidation, identified by ID.
DocumentDate Date Optional. Document date to set in the consolidated billing document. If null, it defaults to today.
ExecutionDescription String Optional. Description of the consolidation background process. If null, defaults to the name of the consolidation rule followed by the current time and date.

Methods

ConsolidationWithRuleAsyncRequest

global ConsolidationWithRuleAsyncRequest()

ffbc.ConsolidationService.ConsolidationAsyncResponse

global with sharing class ConsolidationAsyncResponse extends Response

The response returned by ConsolidationAsyncRequest and ConsolidationWithRuleAsyncRequest. Contains the ID of the background process record and the ID of the background process job running on the billing documents.

This class extends ffbc.Response

Properties

Name Type Description
ConsolidationRunId Id The ID of the background process record.
RunId Id The ID of the background process job running on the billing documents.
ConsolidationRuleId Id The ID of the consolidation rule using which the consolidation is being run. Only populated if the response is returned by ConsolidationWithRuleAsyncRequest.

ffbc.ConsolidationService.ConsolidationRequest

global virtual with sharing class ConsolidationRequest

This class provides the information required to consolidate billing documents. If DocumentDate and DueDate are not supplied, they are resolved as detailed in the Properties table below.

Properties

Name Type Description
BillingDocumentIds Set<Id> Set of billing documents to be consolidated, identified by ID.
DocumentDate Date Optional. Document date to set in the consolidated billing document. If null, it defaults to today.
DueDate Date Optional. Due date to set in the consolidated billing document. If null, it is calculated automatically as follows:
- If you don't enter a due date on an invoice, it is calculated from credit terms. Credit terms held on account take precedence over credit terms held on company. If none exist on either account or company the due date is set to the document date.
- If you don't enter a due date on a credit note, it is set to the document date.

Methods

ConsolidationRequest

global ConsolidationRequest(Set<Id> BillingDocumentIds)

Creates a new ConsolidationRequest for the given BillingDocumentIds.

Input Parameters

Name Type Description
BillingDocumentIds Set<Id> The IDs of the billing documents to be consolidated.

ffbc.ConsolidationService.ConsolidationResponse

global with sharing class ConsolidationResponse extends Response

The response returned by the ConsolidationRequest. Contains the ID of the resulting consolidated billing document (if created) and any errors produced by the process. If an error occurs, the process rolls back. The ID of any billing document related to the error is included in the response.

This class extends ffbc.Response

Properties

Name Type Description
ConsolidationId Id ID of the consolidated billing document that has been created.

ffbc.ConsolidationService.UndoConsolidationRequest

global with sharing class UndoConsolidationRequest

This class provides the information required to undo the consolidation of billing documents.

Properties

Name Type Description
BillingDocumentIds Set<Id> Set of billing documents to be unconsolidated, identified by ID.

Methods

UndoConsolidationRequest

global UndoConsolidationRequest(Set<Id> BillingDocumentIds)

Creates a new UndoConsolidationRequest for the given BillingDocumentIds.

Input Parameters

Name Type Description
BillingDocumentIds Set<Id> The IDs of the billing documents to be unconsolidated.

ffbc.ConsolidationService.UndoConsolidationResponse

global with sharing class UndoConsolidationResponse extends Response

The response returned by the UndoConsolidationRequest. Contains the IDs of the original billing documents that have been reinstated with the “Draft” status, and any errors produced by the process. If an error occurs, the process rolls back. The ID of any billing document related to the error is included in the response.

This class extends ffbc.Response

Properties

Name Type Description
UndoConsolidationIds Set<Id> Set of IDs of the original billing documents that have been reinstated as a result of the undo consolidation process.

ffbc.ConsolidationService.UndoConsolidationAsyncResponse

global with sharing class UndoConsolidationAsyncResponse extends Response

The response returned by the UndoConsolidationRequest. Contains the ID of the background process record and the ID of the background process job running on the billing documents. If an error occurs, the background process is not started. The ID of any billing document related to the error is included in the response.

This class extends ffbc.Response

Properties

Name Type Description
ConsolidationRunId Id The ID of the background process record.
RunId Id The ID of the background process job running on the billing documents.
© Copyright 2009–2024 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.