How to Implement a Custom Tax Provider in Acumatica
To implement a custom tax provider in Acumatica, you need to create a class that implements the ITaxProvider interface. This interface defines the required methods and properties that a tax provider must implement. Below is an example of a barebones implementation of the ITaxProvider interface, with no actual logic yet:
In the implementation of a custom tax provider, the DefaultSettings property and the Initialize method play crucial roles in configuring and initializing the provider.
The DefaultSettings property defines the configuration fields required by the tax provider. These settings are displayed in the Acumatica UI and allow users to provide necessary information, such as API keys, sandbox modes, or environment-specific options.
The Initialize method is responsible for setting up the tax provider based on the user-configured settings. This method is called by Acumatica during the provider's initialization phase, and its purpose is to validate and apply the settings provided by the user.
Here's a simple Implementation of DefaultSetting property and Initialize method:
Don’t forget to map all the branches to codes, Acumatica requires it to call all Tax Providers:
The Ping method is used to verify the connectivity and availability of the tax provider service. It checks whether the provider is properly configured (e.g., a license is set) and returns a result indicating the service's status, with success or error messages.
To enable calculations using your custom Tax Provider, you need to complete the following actions:
-
Create a vendor as Tax Agency:
-
Create a Tax Zone:
-
Assign it to a customer:
When you set it up, taxes will be calculated for documents where this customer is selected:
The GetTax method is used to retrieve taxes from an external provider you are implementing. It takes a GetTaxRequest parameter, which contains all the necessary information for calculating taxes. In this article, we will implement a simple example using basic math:
Here are the results:
The PostTax method is responsible for synchronizing the given document with the external tax provider by adding or updating tax data.
The VoidTax method handles the deletion or voiding of tax information for a specific document in the external tax provider. It ensures that any previously calculated tax for the document is removed.
The CommitTax method finalizes the tax calculation for a document in the external tax provider, indicating that the tax data for the document is complete and locked.
You can find the complete code for this article at the following link:
https://gist.github.com/vitaliivynnykacupower/da10b73f4a6d072f39a3277a63276435