ERP Apex API Developer Reference

fferpcore.TaxCalculationService

global with sharing class TaxCalculationService

This class provides the functionality required to connect to an external tax calculation service.

Enums

VoidRequestReason

Value Description
UNSPECIFIED No reason has been provided for the return.
POST_FAILED Tax calculation on the document has failed.
DOCUMENT_DELETED The original document was deleted.
DOCUMENT_VOIDED The original document is now void.
ADJUSTMENT_CANCELLED A previous adjustment to the original document is no longer necessary.

Methods

getSettings

global static fferpcore.TaxCalculationService.Settings getSettings()

Gets the saved tax calculation settings.

Return Value

A Settings DTO that contains the tax calculation settings excluding the password/license key.

saveSettings

global static fferpcore.TaxCalculationService.SaveSettingsResponse saveSettings(fferpcore.TaxCalculationService.Settings settings)

Saves the modified settings. If the password is empty, the existing password/license key is not overwritten.

Input Parameters

Name Type Description
settings fferpcore.TaxCalculationService.Settings The settings DTO to be saved.

isEnabled

global static Boolean isEnabled()

Determines whether external tax calculation is enabled.

Return Value

True if the endpoint service is enabled.

testConnection

global static fferpcore.TaxCalculationService.TestConnectionResponse testConnection(fferpcore.TaxCalculationService.Settings settings)

Calls the external tax calculation service with the saved settings to validate values. This method bypasses the enabled flag.

Return Value

A Response object that contains the state of the connection and errors that occurred.

validateAddress

global static fferpcore.TaxCalculationService.ValidateAddressResponse validateAddress(fferpcore.TaxCalculationService.Address address)

Calls the external tax calculation service with the address to be validated.
This method might result in DML if logging is enabled and prevent further callouts. To defer DML until all callouts have been performed, see the createWorkScope() method.

Return Value

A ValidateAddressResponse object that contains the validated address.

calculateTax

global static fferpcore.TaxCalculationService.TaxResponse calculateTax(fferpcore.TaxCalculationService.TaxDocument document)

Calls the external tax calculation service with the document for which tax is to be calculated.
This method might result in DML if logging is enabled and prevent further callouts. To defer DML until all callouts have been performed, see the createWorkScope() method.

Return Value

A TaxResponse object that contains the tax values for the document.

commitTax

global static fferpcore.TaxCalculationService.TaxResponse commitTax(fferpcore.TaxCalculationService.TaxDocument document)

Calls the external tax calculation service with a document for which tax is to be calculated and committed.
This method might result in DML if logging is enabled and prevent further callouts. To defer DML until all callouts have been performed, see the createWorkScope() method.

Return Value

A TaxResponse object that contains the tax values for the document.

calculateReversal

global static fferpcore.TaxCalculationService.ReversalResponse calculateReversal(fferpcore.TaxCalculationService.CreditDocument document)

Calls the external tax calculation service with a credit document for which tax is to be calculated. The monetary values in the document are expected to be positive. The returned tax values will also be positive.
This method might result in DML if logging is enabled and prevent further callouts. To defer DML until all callouts have been performed, see the createWorkScope() method.

Return Value

A ReversalResponse object that contains the tax values for the credit document.

commitReversal

global static fferpcore.TaxCalculationService.ReversalResponse commitReversal(fferpcore.TaxCalculationService.CreditDocument document)

Calls the external tax calculation service with a credit document for which tax is to be calculated and committed. The monetary values in the document are expected to be positive. The returned tax values will also be positive.
This method might result in DML if logging is enabled and prevent further callouts. To defer DML until all callouts have been performed, see the createWorkScope() method.

Return Value

A ReversalResponse object that contains the tax values for the credit document.

voidTax

global static fferpcore.TaxCalculationService.VoidResponse voidTax(fferpcore.TaxCalculationService.VoidRequest request)

Calls the external tax calculation service with a request to void a previously committed tax document.
This method might result in DML if logging is enabled and prevent further callouts. To defer DML until all callouts have been performed, see the createWorkScope() method.

Return Value

A VoidResponse object.

voidReversal

global static fferpcore.TaxCalculationService.VoidResponse voidReversal(fferpcore.TaxCalculationService.VoidRequest request)

Calls the external tax calculation service with a request to void a previously committed credit document.
This method might result in DML if logging is enabled and prevent further callouts. To defer DML until all callouts have been performed, see the createWorkScope() method.

Return Value

A VoidResponse object.

createWorkScope

global static fferpcore.Disposable createWorkScope()

Creates a scope to facilitate grouping tax operations together. Scopes can be nested.
This causes the logging system to defer its database writes until the end of the outermost work scope. It is necessary when performing multiple callouts to prevent a Salesforce exception.

Return Value

A Disposable object.

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.

public void calculateTax(List<Document> documents)
{
    fferpcore.Disposable workScope = fferpcore.TaxCalculationService.createWorkScope();
    try
    {
        for(Document document : documents)
        {
            // The calculateTax method marshals the Document, calculates tax and unmarshals
            // the result.
            calculateTax(document);
        }
    }
    finally
    {
        // Use of try-finally ensures that the work scope is always disposed,
        // even if calculateTax results in an exception.
        workScope.dispose();
    }
}

fferpcore.TaxCalculationService.Settings

global class Settings

This class wraps the tax calculation settings in a Salesforce org.

Properties

Name Type Description
Enabled Boolean Indicates whether tax is calculated using the external service.
DisableCommit Boolean Indicates whether committing data to the external tax calculation service should be prevented.
Provider String The name of the class that interfaces with the external tax calculation service.
General String A JSON blob that contains the general settings which can be displayed on the user interface.
Secret String A JSON blob that contains the secret settings which cannot be displayed on the user interface. This value is masked when returned from the getSettings() call in the TaxCalculationService.
SecretSpecified Boolean Indicates whether secret data was provided. The value is true if secret data was provided and is false otherwise.

Methods

Settings

global Settings()

Constructs a new Settings object that is disabled by default.

fferpcore.TaxCalculationService.Response

global virtual class Response

Data returned from the external tax provider.

Properties

Name Type Description
Success Boolean True if the request was successful, false otherwise.
Messages List<fferpcore.Message> A list of any associated messages.

fferpcore.TaxCalculationService.SaveSettingsResponse

global class SaveSettingsResponse extends Response

Data concerning an attempt to save settings.

This class extends fferpcore.TaxCalculationService.Response

Properties

Name Type Description
Validated Boolean True if the settings have been validated, false otherwise.

Methods

SaveSettingsResponse

global SaveSettingsResponse()

SaveSettingsResponse

global SaveSettingsResponse(fferpcore.TaxCalculationService.TestConnectionResponse response)

fferpcore.TaxCalculationService.TestConnectionResponse

global class TestConnectionResponse extends Response

Data returned from the external tax provider following a connection test.

This class extends fferpcore.TaxCalculationService.Response

fferpcore.TaxCalculationService.ValidateAddressResponse

global class ValidateAddressResponse extends Response

Data returned from the external tax provider after validating an address.

This class extends fferpcore.TaxCalculationService.Response

Properties

Name Type Description
Address fferpcore.TaxCalculationService.ValidatedAddress The validated address as determined by the external tax provider.

fferpcore.TaxCalculationService.TaxResponse

global virtual class TaxResponse extends Response

Data returned from the external tax provider after calculating tax.

This class extends fferpcore.TaxCalculationService.Response

Properties

Name Type Description
TaxLines List<fferpcore.TaxCalculationService.TaxResponseLine> A list of tax response lines providing tax information respective to each line provided.
Committed Boolean True if the document was committed, false otherwise.

Methods

TaxResponse

global TaxResponse()

fferpcore.TaxCalculationService.TaxResponseLine

global class TaxResponseLine

Data concerning the calculated tax for a provided request line.

Properties

Name Type Description
LineNo String A line identifier matching the provided request line.
Rate Decimal The calculated rate of tax as a fractional value, ranging from 0.0 for no tax to 1.0 for 100%.
Tax Decimal The calculated tax value for the given amount.
Taxable Decimal The amount that is taxable.
Exemption Decimal The amount that is exempt from tax.
Discount Decimal The amount of discount applied if the document level Discount is used.

fferpcore.TaxCalculationService.Address

global virtual class Address

Data concerning an address.

Properties

Name Type Description
Line1 String Street Address / P.O Box / Company Name
Line2 String Apartment Suite / Unit / Building / Floor
Line3 String Third line of the address.
City String Town / City
Region String County / State
PostalCode String Post code for the area.
Country String Country

fferpcore.TaxCalculationService.ValidatedAddress

global class ValidatedAddress extends Address

Data concerning a validated address.

This class extends fferpcore.TaxCalculationService.Address

Properties

Name Type Description
AddressType String Type of address such as residential or company.
County String County of the address.
FipsCode String Unique 10-digit code representing each geographic combination of state, county, and city.
CarrierRoute String Four-character string representing a US postal carrier route.
TaxRegionId String Identifier for the region.
PostNet String 12-digit barcode containing the ZIP Code, ZIP+4 Code, and the delivery point code. Used by the USPS to direct mail.

Methods

ValidatedAddress

global ValidatedAddress()

fferpcore.TaxCalculationService.DocumentIdentity

global virtual class DocumentIdentity

Data that identifies a document.

Properties

Name Type Description
CompanyCode String Code corresponding to a company.
DocumentCode String Identifier for the document.

Methods

DocumentIdentity

global DocumentIdentity()

Default constructor.

DocumentIdentity

global DocumentIdentity(String companyCode, String documentCode)

Construct a document identity with the given company code and document code.

Input Parameters

Name Type Description
companyCode String Code corresponding to a company
documentCode String Identifier for the document.

fferpcore.TaxCalculationService.TaxDocument

global virtual class TaxDocument extends DocumentIdentity

Document data provided to the external tax calculation service to calculate tax.

This class extends fferpcore.TaxCalculationService.DocumentIdentity

Properties

Name Type Description
ClientName String Name of the client requesting calculation.
ClientVersion Version Version of the client requesting calculation.
CustomerCode String Code identifying the customer.
DocumentDate Date Date associated with the document.
CustomerUsageType String Type of usage. Determines the exemption status of the transaction.
Discount Decimal Discount amount to apply to the document.
ExemptionNumber String Number corresponding to the associated exemption certificate.
PurchaseOrderNumber String Associated customer purchase order number.
LocationCode String Value assigned by some State jurisdictions that identifies a particular store location.
TaxDate Date Date for which tax is to be calculated.
CurrencyISOCode String ISO code of the associated currency.
ShipFromAddress fferpcore.TaxCalculationService.Address Address the item is being sent from.
ShipToAddress fferpcore.TaxCalculationService.Address Address the item is being sent to.
Lines List<fferpcore.TaxCalculationService.TaxRequestLine> List of lines detailing the associated items and their quantities.
BusinessIdentifier String The buyer’s VAT ID. If a value is set, VAT rules are used for the transaction.

fferpcore.TaxCalculationService.TaxRequestLine

global class TaxRequestLine

Data concerning a tax line for calculation.

Properties

Name Type Description
LineNo String Identifying number for the line.
ItemCode String Code corresponding to an item.
TaxCode String Product taxability code of the line item.
Description String Description of the item.
Qty Decimal Quantity of the item.
Amount Decimal Total amount for the tax line including all quantities of the item.
Discounted Boolean Indicates whether the document discount is to be applied to this line item.

fferpcore.TaxCalculationService.CreditDocument

global class CreditDocument extends TaxDocument

Credit document data provided to the external tax calculation service to calculate tax.

This class extends fferpcore.TaxCalculationService.TaxDocument

Properties

Name Type Description
ReferenceCode String Document code of the original tax document.

fferpcore.TaxCalculationService.ReversalResponse

global class ReversalResponse extends TaxResponse

Data returned from the external tax provider following the tax calculation of a credit document.

This class extends fferpcore.TaxCalculationService.TaxResponse

Methods

ReversalResponse

global ReversalResponse()

fferpcore.TaxCalculationService.VoidRequest

global class VoidRequest

Data provided to the external tax calculation service to void a document.

Properties

Name Type Description
Document fferpcore.TaxCalculationService.DocumentIdentity The document to return.
Reason fferpcore.TaxCalculationService.VoidRequestReason Reason for the return.

Methods

VoidRequest

global VoidRequest(fferpcore.TaxCalculationService.DocumentIdentity document, fferpcore.TaxCalculationService.VoidRequestReason reason)

Construct a Void Request for the given Document with the given Reason.

Input Parameters

Name Type Description
document fferpcore.TaxCalculationService.DocumentIdentity The document to void.
reason fferpcore.TaxCalculationService.VoidRequestReason The reason for the void.

VoidRequest

global VoidRequest(String companyCode, String documentCode, fferpcore.TaxCalculationService.VoidRequestReason reason)

Construct a Void Request for the given Document with the given Reason.

Input Parameters

Name Type Description
companyCode String The tax provider company code of the document
documentCode String The document code to void.
reason fferpcore.TaxCalculationService.VoidRequestReason The reason for the void.

fferpcore.TaxCalculationService.VoidResponse

global class VoidResponse extends Response

Data returned from the external tax provider following the voiding of a document.

This class extends fferpcore.TaxCalculationService.Response

Methods

VoidResponse

global VoidResponse()

© Copyright 2009–2019 FinancialForce.com, inc. Confidential – all rights reserved. Various trademarks held by their respective owners.