Adjust your Tax Calculation to Use Billing Address in Episerver Commerce
Even thought there are great tax calculation providers with add-ons for Episerver Commerce (like Vertex), which makes tax compliance in e-Commerce a breeze, it happens to be required for developers to leverage the built-in taxation system in Episerver Commerce.
Configuration of tax jurisdictions, through various geographic descriptors, taxation types and corresponding fee’s are always required. Once in a while, we are on top of that in the need of making further changes than that.
Abstraction of Episerver’s Tax System
Episerver’s calculation workflows relies on an interface named ITaxCalculator, located in EPiServer.Commerce.Order, which acts as the abstraction of the entire tax calculation system. It can, like most other public Episerver APIs, be easily interchanged with your own custom implementation – e.g. if you are in the need of adjusting the behavior beyond the configurable jurisdictions.
All you need to do is to implement the required operations as per your business requirements, and then register it via Dependency Injection.
Sample Customization of the Episerver Tax System
Episerver’s built-in tax calculations are of course tailored to meet common compliance requirements, but we are sometimes faced by the need of customizing it. Let me provide an example.
Out-of-the-box, Episerver uses the shipping address of each shipment as the parameter for the tax calculation. That is not always sufficient to achieve tax compliance, and we have a number of times overridden the out-of-the-box behavior to accommodate the requirements for business-to-business transactions in parts of the world – that is relying on the billing address as the parameter for deciding the tax values.
Please note that the retrieval of billing address has been removed from the sample, since that is required to be implemented according to your business logic – especially when we’re calculating taxes for the shipping fee. We’re relying on the concept of MemoryOrders in Episerver Commerce to avoid duplication of the entire tax calculation logic shipped with the Episerver platform. It saves a lot of headaches down the road, since we directly will benefit from any changes made by Episerver during upgrades!