Relatude has a flexible tax engine built in, but it can also be extended to support any calculation.
The simple way
If you have a very basic webshop, and you only need one VAT/tax rate, you can use the built-in provider, and the Default Tax Rate property on the shop settings to get the correct calculation.
Using tax classes and tax rates
If you have more advanced needs, the you can create TaxClass nodes, and TaxRate nodes that they are linked to. A product can specify a TaxClass. By default, the matching TaxRate is found using the location of the user. The tax is calculated using the Rate property of the matching TaxRate. If you need more complex matching rules, TaxClass has a method called GetMatchingTaxRate() that can be overridden with your custom business logic. Create a new Content Class called for example MyTaxClass that inherits from TaxClass. Set it to replace TaxRate. In the custom partial C# file for MyTaxClass, you can override GetMatchingTaxRate.
The shop settings has a "Default Tax Class" setting. This is the tax class that will be set as default on any new product that is created. If you need to add some business logic to set the correct TaxClass automatically, you can override the GetDefaultTaxClassId method on ProductBase.
Configuring tax classes and tax rates
To use the TaxClass and TaxRate system, you need to create a few nodes in Relatude first. The first you need to do is to create a TaxClass that you use in the DefaultTaxClass property. Click on the button with the three dots, and click on the NEW sub option. Shown below:
The TaxClass is created. A TaxClass can have one or more TaxRates. The system finds the matching tax rate based on the location of the user. Create at least one TaxRate for the TaxClass.
The TaxRate node has 3 important properties:
- The TaxClass(es) the tax rate is used by.
- The Countries that this TaxRate applies to.
- The actual tax rate that is used in the calculation.
On the product, you only need to change the TaxClass property if the tax class is different from the default specified in the Shop node. If you need business logic to determine the correct tax class, override the GetDefaultTaxClassId() on ProductBase.
Custom tax provider
If you need more flexibility than the approaches above approaches you, you can create a custom provider that implements the IWAFTaxCalculationProvider interface. As long as you implement the interface, how you do it is totally up to you.