Accounting Apex API Developer Reference

c2g.BillingDocumentPostingService

global with sharing class BillingDocumentPostingService

A service providing functionality for posting Billing Documents to create Transactions.

Methods

postNow

global static void postNow(c2g.BillingDocumentPostingService.PostingRequest request)

Posts one or more billing documents immediately, instead of waiting for background posting. Documents posted in this way will be removed from the queue of documents to be posted by the background posting job. Use the PostFDNBillingDocuments (Post FDN Billing Documents) custom permission to grant permissions on this method. This method can only post billing documents from one company at a time. Documents to be posted must:
- Have a status of 'Complete'
- Have a Foundations company that matches an FFA company
- Have a currency that matches an existing accounting currency for the company
- Either have a document date that lies within an open period, or have a period override corresponding to an open period
- Have an account with an accounts receivable control
- Have lines with products that have a sales revenue account
- Not have already been posted The postNow method cannot post billing documents that were completed by a user in another company. We recommend that you assign the "FFA Integrations - FDN Billing Document - Retry Post" permission set to users who will trigger a call to this API. Users must also be logged into the company that matches the billing document being posted.

Input Parameters

Name Type Description
request c2g.BillingDocumentPostingService.PostingRequest A request specifying what to post.

Exceptions Thrown

Value Description
PostingException Thrown if there are any problems meaning that a document cannot be posted. If an exception is thrown then no documents will be posted. Some documents may be updated to indicate what errors were encountered on that document. Documents are still removed from the queue to be posted, after fixing errors they can be posted by using either this service or the 'Retry Post' button.

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.

Set<Id> billingDocumentIds;
c2g.BillingDocumentPostingService.PostingRequest request
    = new c2g.BillingDocumentPostingService.PostingRequest(billingDocumentIds);
try
{
    c2g.BillingDocumentPostingService.postNow(request);
}
catch (Exception e)
{
    System.debug(LoggingLevel.ERROR, e.getMessage());
    //In case of an exception no documents will have been posted, but documents may be updated with
    //an error specific to that document.
    List<fferpcore__BillingDocument__c> documents = [
        SELECT Id, c2g__PostingStatus__c, c2g__PostingError__c
        FROM fferpcore__BillingDocument__c
        WHERE Id IN :billingDocumentIds
    ];
    for (fferpcore__BillingDocument__c document : documents)
    {
        if (document.c2g__PostingStatus__c == 'Error')
        {
            System.debug(
                LoggingLevel.ERROR,
                'Billing document ' + document.Id + ' failed with error ' + document.c2g__PostingError__c
            );
        }
    }
}

c2g.BillingDocumentPostingService.PostingRequest

global with sharing class PostingRequest

A request to post particular billing documents.

Properties

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

Methods

PostingRequest

global PostingRequest(Set<Id> billingDocumentIds)

Construct a new posting request for a particular set of billing document IDs. IDs passed into this constructor will be set on the BillingDocumentIds property.

c2g.BillingDocumentPostingService.PostingException

global with sharing class PostingException extends Exception

A simple Exception extension thrown by the Billing Document Posting Service.

© Copyright 2009–2023 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.