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
Return Value
A response containing the results of the AdditionRequest.
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /**
* Example of using addBillingDocumentsToConsolidate() method of ConsolidationService API
* Variables marked by asterisks need to be queried from your organisation's data.
*/
Set<Id> setOfBillingDocumentIds = New Set<Id> {*billingDocumentIds*};
ffbc.ConsolidationService.AdditionRequest request = new ffbc.ConsolidationService.AdditionRequest(setOfBillingDocumentIds);
request.ConsolidatedBillingDocumentId = *consolidatedBillingDocumentId*;
request.DocumentDate = *requestDocumentDate*;
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
Return Value
A response containing the results of the ConsolidationRequest.
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /**
* Example of using consolidate() method of ConsolidationService API
* Variables marked by asterisks need to be queried from your organisation's data.
*/
Set<Id> setOfBillingDocumentIds = New Set<Id> {*billingDocumentIds*};
ffbc.ConsolidationService.ConsolidationRequest request = new ffbc.ConsolidationService.ConsolidationRequest(setOfBillingDocumentIds);
request.DocumentDate = *requestDocumentDate*;
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
Return Value
A response containing the results of the ConsolidationAsyncRequest.
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | /**
* Example of using consolidateAsync() method of ConsolidationService API
* Variables marked by asterisks need to be queried from your organisation's data.
*/
Set<Id> setOfBillingDocumentIds = New Set<Id> {*billingDocumentIds*};
ffbc.ConsolidationService.ConsolidationAsyncRequest request = new ffbc.ConsolidationService.ConsolidationAsyncRequest(setOfBillingDocumentIds);
request.GroupingRuleId = *consolidationGroupingMethodId*;
request.ExecutionDescription = *executionDescription*;
request.DocumentDate = *requestDocumentDate*;
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
Return Value
A list of responses containing the results of each ConsolidationWithRuleAsyncRequest.
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | /**
* 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*;
request1.ExecutionDescription = *executionDescription*;
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
Return Value
A response containing the results of the UndoConsolidationRequest.
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /**
* Example of using undoConsolidation() method of ConsolidationService API
* Variables marked by asterisks need to be queried from your organisation's data.
*/
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
Return Value
A response containing the results of the UndoConsolidationRequest.
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /**
* Example of using undoConsolidationAsync() method of ConsolidationService API
* Variables marked by asterisks need to be queried from your organisation's data.
*/
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.
Properties
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
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.
Properties
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
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
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
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.
Properties
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
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
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.
Properties
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
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
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.
Properties
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.
Properties
ConsolidationRunId |
Id |
the id of the background process record. |
RunId |
Id |
the id of the background process job running on the billing documents. |
|