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

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.

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.

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 is 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 is any errors associated with it.

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

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.
EmailAddress String The email address by which this party can be contacted.
Telephone String The telephone number by which this party can be contacted.

Methods

AccountingSupplierParty

global AccountingSupplierParty()

Constructs a party 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 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.

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.

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')

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.

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()

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.

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.
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.
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).

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

© Copyright 2009–2021 FinancialForce.com, inc. All rights reserved. Various trademarks held by their respective owners.