Foundations Apex API Developer Reference

fferpcore.ElectronicInvoicingService

global with sharing class ElectronicInvoicingService

Common functionality available for sending and receiving invoices electronically. In most circumstances, you should not have to call this directly - other APIs will provide more convenient services for using e-invoicing with particular documents.

Enums

DocumentResponseCode

The document status code will be used in document response.

Value Description
AB It indicates the Message acknowledgement.
AP It indicates that the Document Accepted.
RE It indicates that the Document Rejected.
IP It indicates that the Document is In Process.
UQ It indicates that the Document is Under Query.
CA It indicates that the Document Conditionally Accepted.
PD It indicates that the Document has been Paid.

ClarificationCode

The clarification Code when the document is rejected.

Value Description
REF It Indicates that the received document did not contain references as required by the receiver for correctly routing the document for approval or processing.
LEG It Indicates that the information in the received document is not according to legal requirements.
REC It Indicates that the party to which the document is addressed is not known.
QUA It Indicates that unacceptable or incorrect quality.
DEL It Indicates that delivery proposed or provided is not acceptable.
PRI It Indicates that prices not according to previous expectation.
QTY It Indicates that quantity not according to previous expectation.
ITM It Indicates that items not according to previous expectation.
PAY It Indicates that payment terms not according to previous expectation.
UNR It Indicates that commercial transaction not recognized.
FIN It Indicates that finance terms not according to previous expectation.
OTH It Indicates that reason for status is not defined by code.

DocumentType

The types of document supported by e-invoicing.

Value Description
INVOICE An invoice to be paid by the recipient.
CREDIT_NOTE A credit note reflecting a credit to the recipient.

Source

The source the invoice was received from.

Methods

send

global static fferpcore.ElectronicInvoicingService.SendResponse send(List<fferpcore.ElectronicInvoicingService.Document> documents)

Sends the given documents as electronic invoices. This will make callouts, so no DML can be performed in the same execution context before calling this method. Due to Salesforce limits around making callouts, it is possible that not all the requested documents will be sent. Documents that have not been sent will be returned on the response and will need to be processed in a separate execution context.

Input Parameters

Name Type Description
documents List<fferpcore.ElectronicInvoicingService.Document> The documents that will be sent via e-invoicing.

Return Value

An object containing information about the execution of the request.

notifyDocumentResponse

global static List<fferpcore.ElectronicInvoicingService.DocumentUpdateNotificationResponse> notifyDocumentResponse(List<fferpcore.ElectronicInvoicingService.DocumentResponse> documentResponses)

Sends the document updates to e-invoice provider. This will notify e-invoice provider about the status of documents.

Input Parameters

Name Type Description
documentResponses List<fferpcore.ElectronicInvoicingService.DocumentResponse> The document updates that will be sent to e-invoice provider.

Return Value

A list of objects containing responses received for each document update notification sent to e-invoice provider.

sendAsync

global static fferpcore.ElectronicInvoicingService.SendAsyncResponse sendAsync(List<fferpcore.ElectronicInvoicingService.Document> documents)

Sends the given documents as electronic invoices asynchronously. This uses a Queueable to start the process.

Input Parameters

Name Type Description
documents List<fferpcore.ElectronicInvoicingService.Document> The documents that will be sent via e-invoicing.

Return Value

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

getProviderName

global static String getProviderName()

Returns the name of the connector configured for this service.

Return Value

A string containing the name of the connector used for this service.

validateConnection

global static fferpcore.ElectronicInvoicingService.ValidationResponse validateConnection()

Returns information about the validity of the connector. For example if the connector setup is correct.

Return Value

An object containing information about the validity of the connector, and whether there are any errors associated with it.

testConnection

global static fferpcore.ElectronicInvoicingService.ValidationResponse testConnection(fferpcore.ElectronicInvoicingService.TestConnectionRequest testRequest)

Returns information about the validity of the connector. For example if the connector's URL and API key are correct.

Return Value

An object containing information about the validity of the connector, and whether there are any errors associated with it.

fferpcore.ElectronicInvoicingService.DocumentResponse

global with sharing class DocumentResponse

The document update to send to e-invoice provider.

Properties

Name Type Description
guid String guid for the document
message String The message that is attached to document
statusCode fferpcore.ElectronicInvoicingService.DocumentResponseCode status code for the document
effectiveDate Date The date when the status became effective.
clarificationCode fferpcore.ElectronicInvoicingService.ClarificationCode The clarification Code when the document is rejected.

Methods

DocumentResponse

global DocumentResponse()

Contructs a DocumentResponse with nothing set.

fferpcore.ElectronicInvoicingService.Document

global with sharing class Document

An invoice or credit note.

Properties

Name Type Description
AccountingCostCentre String Text identifying the customer’s accounting cost centre for this document.
AccountingSupplierParty fferpcore.ElectronicInvoicingService.AccountingSupplierParty The person or company who is issuing this document.
AccountingCustomerParty fferpcore.ElectronicInvoicingService.AccountingCustomerParty The person or company who should receive this document.
AllowanceCharges List<fferpcore.ElectronicInvoicingService.AllowanceCharge> Additional charges or allowances that are applicable to the document as a whole.
DocumentTotal Decimal The total value of the document, including the tax. This is specified separately so that rounding differences can be taken into account. If this does not equal the sum of the line net values and the tax amounts, the difference will be included on the e-invoice so that it can be taken into account by the receiver.
Attachments List<fferpcore.ElectronicInvoicingService.Attachment> Additional files to send with the document. Check with your e-invoicing provider for their limits on what can be sent.
CreatePrimaryImage Boolean Set to true to automatically include a PDF copy of the document, if one is not already present in the Attachments.
BillingReference String Reference to a previous document that is being corrected by this one.
ConsumerTaxMode Boolean Set to 'true' to use tax identifier for the sender from the receiver's country, rather than the default. Check with your e-invoicing provider before using this mode.
ContractDocumentReference String Reference to a contract to which this document relates, if one exists.
Delivery fferpcore.ElectronicInvoicingService.Delivery Information about where and when the goods or services being invoiced were delivered.
DeliveryAddress fferpcore.ElectronicInvoicingService.PostalAddress The address to which the supplied goods or services were delivered.
CustomerReference String A reference to allow the customer to identify this document.
DocumentCurrencyCode String Currency in which all monetary amounts in this document are expressed.
DocumentDate Date Date on which the document was created.
DocumentLines List<fferpcore.ElectronicInvoicingService.DocumentLine> Breakdown of the individual charges or credits that make up this document.
DocumentIdentifier String Unique identifier for the document, in the form of a UUID. If the same document is re-sent, the DocumentIdentifier must be the same.
DocumentType fferpcore.ElectronicInvoicingService.DocumentType Whether this is an invoice or a credit note. A negative invoice is equivalent to a positive credit note.
DueDate Date When the document is due to be paid.
InvoiceNumber String Sequential number identifying the document.
InvoicePeriod fferpcore.ElectronicInvoicingService.InvoicePeriod The period of time for which the document is being charged.
IssueDate Date Date when the document was sent to the customer.
LegalEntityId String Identifies the legal entity issuing this document.
Note String Free text to add to the document.
PaymentMeans List<fferpcore.ElectronicInvoicingService.PaymentMeans> Instructions for how to pay this document.
PaymentTerms fferpcore.ElectronicInvoicingService.PaymentTerms Terms governing payment for this document.
PayableRoundingAmount Decimal The difference between the invoice total and the sum of the invoice lines.
AmountIncludingTax Decimal The total invoice amount payable, including tax. This is equal to the sum of the invoice_lines (amount_excluding_tax + tax.amount)
PrepaidAmount Decimal How much has already been paid toward this document, if anything.
ProjectReference String Reference to the project to which this document relates, if one exists.
Routing fferpcore.ElectronicInvoicingService.Routing Where the e-invoice is to be sent.
CustomerOrderReference String The customer's reference for the order to which this document relates, if one exists.
SalesOrderId String The seller's reference for the order to which this document relates, if one exists.
TaxPointDate Date Date used for calculating tax, if different from the document date.
TaxSubtotals List<fferpcore.ElectronicInvoicingService.TaxSubtotal> The subtotals for each different tax applied to this document. If not specified, it will be worked out automatically from the taxes on the document lines and allowances/charges.
UblExtensions List<String> UBL extensions for this document.
Source fferpcore.ElectronicInvoicingService.Source The source the invoice was received from.
ExternalKey String Used for accountants. The id you specified for the organization.
ExternalUserId String Used for the embedded portal retrieval service. The external_user_id you provided when the ShopAccount was created.
TaxSystem String The tax system of the document.
UblString String The ubl file String of the document.

Methods

Document

global Document()

Constructs a document. List properties are initialised to an empty list, all other properties begin as null.

fferpcore.ElectronicInvoicingService.AccountingSupplierParty

global with sharing class AccountingSupplierParty

A person or company capable of sending e-invoices.

Properties

Name Type Description
ContactName String Name of an individual within a company.
ContactFirstName String First Name of an individual within a company.
ContactSecondName String Last Name of an individual within a company.
EmailAddress String The email address by which this party can be contacted.
Telephone String The telephone number by which this party can be contacted.
City String The city.
Country String The country.
County String The county.
Department String The department who sent the invoice.
Identifiers List<fferpcore.ElectronicInvoicingService.Endpoint> The array of identifiers for this sender.
Line1 String The address
Line2 String The address, line 2
PartyName String The party who sent the invoice.
LegalName String The Legal Name of the party who sent the document
BuildingNumber String Building Number of the party who sent the document
SecondaryNumber String Secondary Number of the party who sent the document
Neighborhood String Neighborhood of the party who sent the document
Zip String The zip code.

Methods

AccountingSupplierParty

global AccountingSupplierParty()

Constructs a party with no fields set.

fferpcore.ElectronicInvoicingService.AccountingDetail

global with sharing class AccountingDetail

The accounting details for the invoice line.

Properties

Name Type Description
Code String The the code of the general ledger account.
Name String A textual description of the code.

Methods

AccountingDetail

global AccountingDetail()

Constructs a accountingDetail with no fields set.

fferpcore.ElectronicInvoicingService.AccountingCustomerParty

global with sharing class AccountingCustomerParty

A person or company capable of receiving e-invoices.

Properties

Name Type Description
AccountId String Id of the customer Account assigned by the seller.
CompanyName String Name of the company.
ContactId String Id of an individual contact within a company.
ContactName String Name of an individual within a company.
EmailAddress String The email address by which this party can be contacted.
PublicIdentifiers List<fferpcore.ElectronicInvoicingService.Endpoint> Unique identifiers that can be used by the e-invoicing network to identify the party.
PostalAddress fferpcore.ElectronicInvoicingService.PostalAddress Physical address of the party.
Telephone String The telephone number by which this party can be contacted.
CustomerId String Id of the customer assigned by the seller.

Methods

AccountingCustomerParty

global AccountingCustomerParty()

Constructs a party with an empty list of endpoints. All other properties begin as null.

fferpcore.ElectronicInvoicingService.AllowanceCharge

global with sharing class AllowanceCharge

A discount or surcharge. Should be negative for discounts.

Properties

Name Type Description
NetValue Decimal Amount being charged, net of tax.
Reason String Text describing the reason for the charge or discount.
TaxBreakdown List<fferpcore.ElectronicInvoicingService.Tax> Taxes applicable to this charge or discount.

Methods

AllowanceCharge

global AllowanceCharge()

Constructs an AllowanceCharge with an empty list of TaxBreakdown. All other properties begin as null.

fferpcore.ElectronicInvoicingService.Attachment

global with sharing class Attachment

Files that can be attached to the document.

Properties

Name Type Description
Document String The contents of the attachment, using base64 encoding.
Filename String The name of the file being attached.
MimeType String The format of the attachment. Check with your e-invoicing provider for which types are supported.
PrimaryImage Boolean If true, indicates that this attachment is a visual copy of the document.

Methods

Attachment

global Attachment()

Constructs an Attachment with no fields set.

fferpcore.ElectronicInvoicingService.Delivery

global with sharing class Delivery

Information about what has been or will be delivered for this document.

Properties

Name Type Description
ActualDate Date The date on which the delivery takes or took place.
Location fferpcore.ElectronicInvoicingService.Location Codes for quick identification of a location, for example a Global Location Number.
Quantity Decimal The quantity that has been or will be delivered.
PartyName String The party the goods/services were delivered to.

Methods

Delivery

global Delivery()

Constructs a Delivery with no fields set.

fferpcore.ElectronicInvoicingService.Location

global with sharing class Location

Codes for quick identification of a location, for example a Global Location Number.

Properties

Name Type Description
Id String Identifies the location.
SchemeAgencyId String ID of the agency that issues the Id (e.g. 'ZZZ')
SchemeId String The scheme that the Id conforms to (e.g. 'EAN')
City String Address city.
Country String Address country.
County String Address county.
Line1 String Address line 1.
Line2 String Address line 2.
Zip String Address zip code
BuildingNumber String Address Building Number
SecondaryNumber String Address Secondary Number
Neighborhood String Address Neighborhood
Department String Department name.

Methods

Location

global Location()

Constructs a Location with no fields set.

fferpcore.ElectronicInvoicingService.Endpoint

global with sharing class Endpoint

A unique identifier for an Endpoint on the e-invoicing network, to allow routing of documents to the correct place.

Properties

Name Type Description
Id String Identifier for an Endpoint. This may be in one of many formats, as described by the scheme.
Scheme String Identifies the type of id that describes the company. Valid values can be obtained from your e-invoicing provider.
SuperScheme String The Superscheme of the identifier.
SchemeNumeric String The SchemeNumeric of the identifier.

Methods

Endpoint

global Endpoint(String id, String scheme)

Constructs an Endpoint. All arguments are required.

Input Parameters

Name Type Description
id String Identifier for an Endpoint. This may be in one of many formats, as described by the scheme.
scheme String Scheme that describes how the id is to be interpreted, e.g. as a VAT Id.

Endpoint

global Endpoint(String id, String scheme, String superScheme, String schemeNumeric)

Constructs an Endpoint. All arguments are required.

Input Parameters

Name Type Description
id String Identifier for an Endpoint. This may be in one of many formats, as described by the scheme.
scheme String Scheme that describes how the id is to be interpreted, e.g. as a VAT Id.
superScheme String The Superscheme of the identifier.
schemeNumeric String The SchemeNumeric of the identifier.

Endpoint

global Endpoint()

Constructs a Endpoint with no fields set.

fferpcore.ElectronicInvoicingService.PaymentMeans

global with sharing class PaymentMeans

Instructions for how to pay this document.

Properties

Name Type Description
Account String The bank account number.
BranchCode String SWIFT or BIC code used to identify the bank. Not required if using an IBAN number for the Account.
Code String Identifies the type of payment being used. Different types of payment will require different information. Consult your e-invoicing provider for the available values, and what data is needed in each case.
Holder String Name of the holder of the bank account.
Mandate String Direct debit mandate code, if paying by direct debit.
Network String Name of the card or other payment network, e.g. VISA, PayPal.
PaymentId String ID to be used when paying that you can use to associate the payment with the document.

Methods

PaymentMeans

global PaymentMeans()

Constructs a new PaymentMeans with no fields set.

fferpcore.ElectronicInvoicingService.PaymentTerms

global with sharing class PaymentTerms

The terms under which a document is to be paid.

Properties

Name Type Description
Note String Text describing the payment terms.

Methods

PaymentTerms

global PaymentTerms()

Constructs a new PaymentTerms with no fields set.

fferpcore.ElectronicInvoicingService.PostalAddress

global with sharing class PostalAddress

A physical address that can receive post.

Properties

Name Type Description
AddressLine1 String Street Address / P.O Box / Company Name.
AddressLine2 String Apartment Suite / Unit / Building / Floor.
CityName String Town / City.
County String County / state / province / region.
Country String Name of the country.
CountryIdentificationCode String Code for the country, taken from the ISO 3166-1 alpha-2 standard list.
PostalCode String ZIP / Postal code for the area.

Methods

PostalAddress

global PostalAddress()

Constructs a postal address with no fields set.

fferpcore.ElectronicInvoicingService.Routing

global with sharing class Routing

Information used to deliver the document to the recipient. The EIdentifiers will be used by preference, to send the document across the electronic invoicing network. If the recipient cannot receive e-invoices in this way, the document will be sent to the specified emails.

Properties

Name Type Description
EIdentifiers List<fferpcore.ElectronicInvoicingService.Endpoint>
Emails List<String>

Methods

Routing

global Routing()

Constructs a Routing with empty lists of EIdentifiers and Emails.

fferpcore.ElectronicInvoicingService.TaxSubtotal

global with sharing class TaxSubtotal

Describes the total amount charged for a particular tax across an entire document.

Properties

Name Type Description
TaxCode String Code identifying the tax being applied.
CountryIdentificationCode String Code for the country levying the tax, taken from the ISO 3166-1 alpha-2 standard list.
Percent Decimal Rate used to calculate the tax.
Amount Decimal Amount payable for this tax.
TaxableAmount Decimal The amount that is being taxed.
Tax fferpcore.ElectronicInvoicingService.Tax Constructs a Tax with no fields set.

Methods

TaxSubtotal

global TaxSubtotal()

Constructs a TaxSubtotal with no fields set.

fferpcore.ElectronicInvoicingService.DocumentLine

global with sharing class DocumentLine

An individual line on an invoice or credit note, corresponding to a single charge or credit.

Properties

Name Type Description
AccountingCostCentre String Text identifying the customer’s accounting cost centre for this document line.
AccountingDetail fferpcore.ElectronicInvoicingService.AccountingDetail Accounting detail for the document line.
AdditionalItemProperties List<fferpcore.ElectronicInvoicingService.AdditionalItemProperty> Additional information about this document line that does not belong in any other field.
CustomerItemIdentification String ID used by the customer to identify the product or service.
Delivery fferpcore.ElectronicInvoicingService.Delivery Delivery information for the product on this line.
DeliveryAddress fferpcore.ElectronicInvoicingService.PostalAddress The address to which the supplied goods or services were delivered.
Description String Description providing additional information about the line.
DiscountAmount Decimal Total Amount of any discount applied to this line.
AmountExcludingTax Decimal The amount excluding Tax. This is equal to quantity x price_amount + ∑ allowance_charges.
ItemName String Name of the product or service being charged for.
LineId String Identifier for the line. Must be unique within the document.
NetValue Decimal Amount being charged, net of tax.
OrderLineReferenceLineId String A reference to the order line to which this document line relates.
Period fferpcore.ElectronicInvoicingService.InvoicePeriod Period of time over which the product or service being charged for was supplied.
Quantity Decimal How many units (see UnitCode) are being charged for.
SellersItemIdentification String ID used by the seller to identify the product or service.
StandardItemIdentification String A code identifying the product or service, taken from a standardized code as specified in StandardItemIdentificationSchemeId.
StandardItemIdentificationSchemeAgencyId String ID of the agency that issues the StandardItemIdentification.
StandardItemIdentificationSchemeId String The scheme that the StandardItemIdentification conforms to, e.g. GTIN.
TaxBreakdown List<fferpcore.ElectronicInvoicingService.Tax> Taxes applicable to this line.
UnitCode String Code describing the unit by which quantity is measured, e.g. kg or cm Codes can be taken from UN/ECE Recommendation 20, or an 'X' followed by a code from UN/ECE Recommendation 21.
UnitPrice Decimal The price charged per unit of this product (unit defined in the UnitCode field).
BaseQuantity Decimal The number of items the price is for.
AllowanceCharges List<fferpcore.ElectronicInvoicingService.AllowanceCharge> Additional charges or allowances that are applicable to the document line as a whole.

Methods

DocumentLine

global DocumentLine()

Constructs a document line. List properties are initialised to an empty list, all other properties begin as null.

fferpcore.ElectronicInvoicingService.AdditionalItemProperty

global with sharing class AdditionalItemProperty

An additional property for a document line that isn't already specified elsewhere.

Properties

Name Type Description
name String The name identifying the property.
value String The value of this property.

Methods

AdditionalItemProperty

global AdditionalItemProperty(String name, String value)

Constructs an AdditionalItemProperty

Input Parameters

Name Type Description
name String The name identifying the property.
value String The value of this property.

fferpcore.ElectronicInvoicingService.InvoicePeriod

global with sharing class InvoicePeriod

The period for which a document or line is being charged.

Properties

Name Type Description
EndDate Date The end of the period.
StartDate Date The start of the period.

Methods

InvoicePeriod

global InvoicePeriod()

InvoicePeriod

global InvoicePeriod(Date startDate, Date endDate)

Constructs an invoice period. The start date must be less than or equal to the end date.

Input Parameters

Name Type Description
startDate Date The start of the period.
endDate Date The end of the period.

fferpcore.ElectronicInvoicingService.Tax

global with sharing class Tax

Describes a tax charged on a document line.

Properties

Name Type Description
Amount Decimal Amount payable for this tax.
Percent Decimal Rate used to calculate the tax.
TaxCode String Tax Category code
Type String Rate used to calculate the tax.
LineItemTaxCode String Code identifying the tax being applied.
CountryIdentificationCode String Code for the country levying the tax, taken from the ISO 3166-1 alpha-2 standard list.

Methods

Tax

global Tax()

Constructs a tax with no fields set.

fferpcore.ElectronicInvoicingService.ValidationResponse

global with sharing class ValidationResponse

Describes the validity of the connector.

Properties

Name Type Description
Errors List<String> A list of errors associated with the validation process.
IsValid Boolean A boolean describing if the connector is valid.

Methods

ValidationResponse

global ValidationResponse(List<String> errors)

Constructs a ValidationResponse from the provided list of errors

Input Parameters

Name Type Description
errors List<String> A list of errors to be included in the response. If this parameter is null, then an empty list of errors will be added to the response.

fferpcore.ElectronicInvoicingService.SendResponse

global with sharing class SendResponse

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

Properties

Name Type Description
Results Map<String, fferpcore.ElectronicInvoicingDelivery.DeliveryUpdate> A map of the delivery results by document unique identifier.
UnsentDocuments List<fferpcore.ElectronicInvoicingService.Document> Documents that could not be sent in the current execution context because of limits governing the use of callouts. These documents should be sent in another execution context.

Methods

SendResponse

global SendResponse(Map<String, fferpcore.ElectronicInvoicingDelivery.DeliveryUpdate> results)

Constructs a SendResponse with a map of delivery results.

SendResponse

global SendResponse()

Constructs a SendResponse with nothing set.

fferpcore.ElectronicInvoicingService.SendAsyncResponse

global with sharing class SendAsyncResponse

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

Properties

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

Methods

SendAsyncResponse

global SendAsyncResponse(Id asyncApexJobId)

Constructs a successful SendAsyncResponse.

Input Parameters

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

fferpcore.ElectronicInvoicingService.TestConnectionRequest

global with sharing class TestConnectionRequest

Contains the credentials of the connector.

Properties

Name Type Description
JsonSettings String Json blob containing settings provided for testing the connection.

Methods

TestConnectionRequest

global TestConnectionRequest()

Constructs a TestConnectionRequest with nothing set.

fferpcore.ElectronicInvoicingService.DocumentUpdateNotificationResponse

global with sharing class DocumentUpdateNotificationResponse

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

Properties

Name Type Description
guid String A guid for the document

Methods

DocumentUpdateNotificationResponse

global DocumentUpdateNotificationResponse()

Contructs a DocumentUpdateNotificationResponse with nothing set.

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