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 billing documents are valid if their Document Type, Currency, Company, and Account fields have the same value. If DocumentDate and DueDate are supplied, they override the existing values on the consolidated billing document. All other header 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> setOfBillingDocuments = New Set<Id> {*billingDocumentIds*}

ffbc.ConsolidationService.AdditionRequest request = new ffbc.ConsolidationService.AdditionRequest(setOfBillingDocuments);
request.ConsolidatedBillingDocumentId = *consolidatedBillingDocumentId*;
//If the DocumentDate is not specified then it will not be changed in the header of the consolidated billing document.
request.DocumentDate = *requestDocumentDate*;
//If the DueDate is not specified then it will not be changed in the header of the consolidated billing document.
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”.

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> setOfBillingDocuments = New Set<Id> {*billingDocumentIds*}

ffbc.ConsolidationService.ConsolidationRequest request = new ffbc.ConsolidationService.ConsolidationRequest(setOfBillingDocuments);
//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 empty in the header of the consolidated billing document.
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. This returns an ID of the background process run on the billing documents.

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> setOfBillingDocuments = New Set<Id> {*billingDocumentIds*}

ffbc.ConsolidationService.ConsolidationAsyncRequest request = new ffbc.ConsolidationService.ConsolidationAsyncRequest(setOfBillingDocuments);
request.GroupingRuleId = {*consolidationGroupingMethodId*}

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

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 each have at least one billing document line.
- 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> setOfBillingDocuments = New Set<Id> {*billingDocumentIds*}

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

ffbc.ConsolidationService.AdditionRequest

global class AdditionRequest extends ConsolidationRequest

This class provides the information required to add billing documents to a consolidated billing document. If DocumentDate and DueDate are supplied, they override the existing values on the consolidated billing document.

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)

Create 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 class ConsolidationAsyncRequest extends ConsolidationRequest

This class provides the information required to consolidate billing documents using a background process.

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 description 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.ConsolidationAsyncResponse

global class ConsolidationAsyncResponse extends Response

The response returned by the ConsolidationAsyncRequest. Contains the ID of the Background Process object and the ID of the background process job running on the billing documents. If an error occurs, 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 object.
RunId Id The ID of the background process job running on the billing documents.

ffbc.ConsolidationService.ConsolidationRequest

global virtual 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.
Mandatory custom fields must have the same value on all the billing documents. The value is then used on the consolidated billing document.
Where other fields have the same value on all the billing documents, the value is used on the consolidated billing document. If all the values for a field are not the same, it is left blank on the consolidated billing document.

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 but all the billing documents have the same due date, that date is used on the consolidated billing document. Otherwise the Document Due Date field on the consolidated billing document is left blank.

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 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 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 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.
© Copyright 2009–2019 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.