Tax plugin
The Sitecore.Commerce.Plugin.Tax plugin is a sample tax calculator that implements pipeline blocks and policies to apply tax adjustments both at the cart level and at the line item level.
The Sitecore.Commerce.Plugin.Tax plugin is provided as a sample only and not intended for production. You can use the sample tax plugin as a starting point to develop a custom tax plugin that meets specific tax calculation requirements.
Pipeline blocks
The Sitecore.Commerce.Plugin.Tax plugin defines the following pipeline blocks used to calculate how taxes apply to an order:
-
The
CalculateCartLinesTaxBlockpipeline block -
The
CalculateCartTaxBlockpipeline block -
The
RegisteredPluginBlockblock
The CalculateCartLinesTaxBlock block
In the ICalculateCartLinesPipeline pipeline, the CalculateCartLinesTaxBlock block is a sample pipeline block that calculates the tax totals applicable at the cart line level. It adds the CartLineLevelAwardedAdjustment to all cart lines that contain taxable sellable items. The tax rate used to calculate this adjustment is configurable in the GlobalTaxPolicy policy.
The CalculateCartLinesTaxBlock block is intended as a sample only. In a typical Commerce deployment, you replace this block with a call out to the appropriate third-party tax provider for your deployment.
The CalculateCartTaxBlock block
In the ICalculateCartPipeline pipeline, the CalculateCartTaxBlock block is a sample pipeline block that calculates cart level tax adjustments that represent the total taxable tax amount applicable to the entire order. The tax rate used to calculate this adjustment is configurable in the GlobalTaxPolicy policy.
When a cart contains a SplitFulfillmentComponent component, the CalculateCartTaxBlock block takes no action, and tax adjustments are calculated at the item level only.
The RegisteredPluginBlock block
In the IRunningPluginsPipeline pipeline, the RegisteredPluginBlock block is used to register the tax plugin with the Commerce Engine.
Policies
The sample Sitecore.Commerce.Plugin.Tax plugin defines tax policies that allow you to configure how the CalculateCartLinesTaxBlock and the CalculateCartTaxBlock blocks apply tax adjustments.
GlobalTaxPolicy policy
You can configure the GlobalTaxPolicy policies in the following default Commerce environment configuration files:
-
PlugIn.Habitat.CommerceAuthoring-1.0.0.json -
PlugIn.Habitat.CommerceMinions-1.0.0.json -
PlugIn.Habitat.CommerceShops-1.0.0.json -
PlugIn.AdventureWorks.CommerceAuthoring-1.0.0.json -
PlugIn.AdventureWorks.CommerceMinions-1.0.0.json -
PlugIn.AdventureWorks.CommerceShops-1.0.0.json
The following table describes the properties of the GlobalTaxPolicy policy:
|
Property |
Description |
Default value |
|---|---|---|
|
|
Specifies whether tax calculation is enabled. (Bool. true or false). |
|
|
|
Specifies whether the price includes taxes. |
|
|
|
Specifies the tax rate (in decimal format) used by the |
|
|
|
Specifies the tax rate (in decimal format) used by the |
|
|
|
Specifies which address the tax calculation is based on. Possible values are |
|
|
|
The name of the class that represents the tax applied for shipping. |
|
|
|
Specifies whether rounding occurs at the item level or at the order subtotal level. (Bool. true or false). |
|
|
|
Specifies the name of a tag used to identify cart items that are exempt from tax. Tax calculation is skipped for those items. Note Although the Tax plugin defines this property, it is not currently used and not included in the |
|
|
|
Specifies whether the Note Although the Tax plugin defines this property, it is not currently used and not included in the |
|
TaxRatePolicy policy
The Tax plugin defines the TaxRatePolicy policy.
This policy is not used by default. It is not included in the sample environment configuration files.
The following table describes the properties of the TaxRatePolicy policy:
|
Property |
Description |
Default value |
|---|---|---|
|
|
A country code (based on ISO 3166-1 alpha-2 standard). Defined as a string value. |
No default |
|
|
The code (string format) corresponding to the state for tax purposes. Leave blank for all states. |
No default |
|
|
Postal codes (string format) for the tax rate. Separate multiple codes with a semicolon. For all codes, do not assign a value (leave blank). |
No default |
|
|
The city of taxation (string format). |
No default |
|
|
The tax rate in percentage (decimal format). |
No default |
|
|
The name of the tax (string format) for this tax rate. For example VAT, GST, and so on. |
No default |
|
|
Specifies a priority for the tax rate (integer format) when multiple tax rates exist. Specify a different priority for each tax rate. |
No default |
|
|
Specifies whether the tax rate applies to prior taxes. (Bool. true or false). |
No default |
|
|
Specifies whether the tax rate applies to shipping. (Bool. true or false). |
No default |
TaxGroupPolicy
The Tax plugin defines the TaxGroupPolicy policy.
This policy is not used by default. It is not included in the sample environment configuration files.
ItemTaxPolicy policy
The Tax plugin defines the ItemTaxPolicy policy.
This policy is not used by default. It is not included in the sample environment configuration files.
The following table describes the property of the ItemTaxPolicy policy:
|
Property |
Description |
Default value |
|---|---|---|
|
|
Specifies a defined tax class (string format). |
|