Tax plugin

Abstract

An overview of the sample Sitecore Commerce Tax plugin and the elements it provides.

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.

Note

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 CalculateCartLinesTaxBlock pipeline block

  • The CalculateCartTaxBlock pipeline block

  • The RegisteredPluginBlock block

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.

Note

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.

Note

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

TaxCalculationEnabled

Specifies whether tax calculation is enabled. (Bool. true or false).

true

PriceIncludesTax

Specifies whether the price includes taxes.

false

DefaultCartTaxRate

Specifies the tax rate (in decimal format) used by the CalculateCartTaxBlock block.

0.1

DefaultItemTaxRate

Specifies the tax rate (in decimal format) used by the CalculateCartLinesTaxBlock.

0.1

CalculateTaxBasedOn

Specifies which address the tax calculation is based on. Possible values are ShippingAddress, BillingAddress, or StoreAddress.

"ShippingAddress"

ShippingTaxClass

The name of the class that represents the tax applied for shipping.

"CartItems"

RoundAtSubTotal

Specifies whether rounding occurs at the item level or at the order subtotal level. (Bool. true or false).

false

TaxExemptTag

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 GlobalTaxPolicy policy.

"taxexempt"

TaxExemptTagsEnabled

Specifies whether the TaxExemptTag is used by the calculateCartLinesTaxBlock and CalculateCartTaxBlock.

Note

Although the Tax plugin defines this property, it is not currently used and not included in the GlobalTaxPolicy policy.

true

TaxRatePolicy policy

The Tax plugin defines the TaxRatePolicy policy.

Note

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

CountryCode

A country code (based on ISO 3166-1 alpha-2 standard). Defined as a string value.

No default

StateCode

The code (string format) corresponding to the state for tax purposes. Leave blank for all states.

No default

PostalCode

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

City

The city of taxation (string format).

No default

TaxRate

The tax rate in percentage (decimal format).

No default

TaxName

The name of the tax (string format) for this tax rate. For example VAT, GST, and so on.

No default

Priority

Specifies a priority for the tax rate (integer format) when multiple tax rates exist. Specify a different priority for each tax rate.

No default

IsCompounded

Specifies whether the tax rate applies to prior taxes. (Bool. true or false).

No default

IsShipping

Specifies whether the tax rate applies to shipping. (Bool. true or false).

No default

TaxGroupPolicy

The Tax plugin defines the TaxGroupPolicy policy.

Note

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.

Note

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

TaxClass

Specifies a defined tax class (string format).

"Taxable"