Accounting Apex API Developer Reference

c2g.SalesCreditNoteEInvoicingService

global with sharing class SalesCreditNoteEInvoicingService

API methods for sending a sales credit note via the configured electronic invoicing provider. Sending a sales credit note will update the record to set fields used for tracking the progress and make a callout to the configured electronic invoicing provider. Because of platform restrictions around making callouts, there are multiple API methods covering different parts of this process to allow you to split the work across multiple execution contexts as needed.

Methods

sendAsync

global static c2g.SalesCreditNoteEInvoicingService.SendAsyncResponse sendAsync(Set<Id> salesCreditNoteIds)

Performs all operations needed to send electronic invoices from sales credit note. The sales credit note will be updated synchronously to mark them as sending, and a queueable will be started that makes the callout to the electronic invoicing provider asynchronously. Because this method starts a queueable, take care using it from code that may be called from a batch or queueable process where there are tight limits on the number of queueables that can be started.

Input Parameters

Name Type Description
salesCreditNoteIds Set<Id> The IDs of the sales credit notes that are to be sent as electronic invoices.

Return Value

An object containing the ID of the AsyncApexJob started by this method.

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.

You need to provide some sample code

validateSalesCreditNotes

global static c2g.SalesCreditNoteEInvoicingService.ValidationResponse validateSalesCreditNotes(Set<Id> salesCreditNoteIds)

Returns information about the validity of the sales credit notes for sending as electronic invoices. For example if the sales credit notes status is not Complete or the delivery status is already Delivered.

Input Parameters

Name Type Description
salesCreditNoteIds Set<Id> The IDs of the sales credit notes that are to be validated.

Return Value

An object containing information about the validity of the sales credit notes.

c2g.SalesCreditNoteEInvoicingService.EInvoicingResponse

global abstract with sharing class EInvoicingResponse

Abstract base class that all other electronic invoicing response classes extend. Customers are not expected to extend this themselves, but you can refer to other responses using this type to build common error-handling code. Provides a map of errors by record id.

Properties

Name Type Description
Errors Map<Id, List<String>> A map from a credit notes's Id to a list of errors associated with that credit note.

c2g.SalesCreditNoteEInvoicingService.ValidationResponse

global with sharing class ValidationResponse extends EInvoicingResponse

Returns information on the validity of sales credit notes.

This class extends c2g.SalesCreditNoteEInvoicingService.EInvoicingResponse

Properties

Name Type Description
IsValid Boolean A boolean describing the validity of all sales credit notes. This will be false if one or more of the credit notes are invalid.

Methods

ValidationResponse

global ValidationResponse(Map<Id, List<String>> errorMap)

ValidationResponse

global ValidationResponse()

c2g.SalesCreditNoteEInvoicingService.SendAsyncResponse

global with sharing class SendAsyncResponse extends EInvoicingResponse

Response to a request to the `sendAsync` method. This contains information about what has happened when executing `sendAsync`.

This class extends c2g.SalesCreditNoteEInvoicingService.EInvoicingResponse

Properties

Name Type Description
AsyncApexJobId Id Id of the AsyncApexJob that has been created to send the electronic invoice. This can be used to track the progress of the job.

Methods

SendAsyncResponse

global SendAsyncResponse(Id asyncApexJobId)

Constructs a SendAsyncResponse.

Input Parameters

Name Type Description
asyncApexJobId Id Id of the AsyncApexJob that has been created to send the electronic invoice.

SendAsyncResponse

global SendAsyncResponse(Map<Id, List<String>> errorsById)

Constructs a SendAsyncResponse.

Input Parameters

Name Type Description
errorsById Map<Id, List<String>> Map of errors by invoice Id.
© Copyright 2009–2023 Certinia Inc. All rights reserved. Various trademarks held by their respective owners.