Class DefaultTaxCalculator
The default tax calculator.
Inheritance
Implements
Inherited Members
Namespace: EPiServer.Commerce.Order.Calculator
Assembly: EPiServer.Business.Commerce.dll
Version: 13.30.0Syntax
public class DefaultTaxCalculator : ITaxCalculator
Constructors
DefaultTaxCalculator(IContentRepository, ReferenceConverter)
Initializes a new instance of the DefaultTaxCalculator class.
Declaration
public DefaultTaxCalculator(IContentRepository contentRepository, ReferenceConverter referenceConverter)
Parameters
Type | Name | Description |
---|---|---|
EPiServer.IContentRepository | contentRepository | The content Repository. |
ReferenceConverter | referenceConverter | The reference converter. |
DefaultTaxCalculator(IContentRepository, ReferenceConverter, IShippingCalculator, ILineItemCalculator, IReturnLineItemCalculator)
Initializes a new instance of the DefaultTaxCalculator class.
Declaration
[Obsolete("This constructor is no longer used, use constructor with IContentRepository and ReferenceConverter instead. Will remain at least until May 2019.")]
public DefaultTaxCalculator(IContentRepository contentRepository, ReferenceConverter referenceConverter, IShippingCalculator shippingCalculator, ILineItemCalculator lineItemCalculator, IReturnLineItemCalculator returnLineItemCalculator)
Parameters
Type | Name | Description |
---|---|---|
EPiServer.IContentRepository | contentRepository | The content Repository. |
ReferenceConverter | referenceConverter | The reference converter. |
IShippingCalculator | shippingCalculator | The shipping calculator. |
ILineItemCalculator | lineItemCalculator | The line item calculator. |
IReturnLineItemCalculator | returnLineItemCalculator | The return line item calculator. |
Methods
CalculateReturnTaxTotal(IReturnOrderForm, IMarket, Currency)
Gets the tax total for the return order form.
Declaration
[Obsolete("This method is no longer used. Will remain at least until May 2019.")]
protected virtual Money CalculateReturnTaxTotal(IReturnOrderForm returnOrderForm, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IReturnOrderForm | returnOrderForm | The return order form. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculation. |
Returns
Type | Description |
---|---|
Money | The total tax for the return order form. |
CalculateSalesTax(ILineItem, IMarket, IOrderAddress, Money)
Calculates the sales tax of an ILineItem.
Declaration
protected virtual Money CalculateSalesTax(ILineItem lineItem, IMarket market, IOrderAddress shippingAddress, Money basePrice)
Parameters
Type | Name | Description |
---|---|---|
ILineItem | lineItem | The line item. |
IMarket | market | The market to be used in the calculation. |
IOrderAddress | shippingAddress | The shipping address. |
Money | basePrice | The base price. |
Returns
Type | Description |
---|---|
Money | The sales tax. |
Remarks
IMPORTANT - It will take the PricesIncludeTax setting on the order where the line item belongs to into account when calculating the sales tax.
This means that if the value is True
, then sales tax will be calculated based on the assumption that basePrice
already includes tax.
CalculateSalesTax(IEnumerable<ILineItem>, IMarket, IOrderAddress, Currency)
Calculates the sales tax of a collection of ILineItems.
Declaration
protected virtual Money CalculateSalesTax(IEnumerable<ILineItem> lineItems, IMarket market, IOrderAddress shippingAddress, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<ILineItem> | lineItems | The line items |
IMarket | market | The market to be used in the calculation. |
IOrderAddress | shippingAddress | The shipping address. |
Currency | currency | The currency. |
Returns
Type | Description |
---|---|
Money | The sales tax. |
CalculateShippingReturnTaxTotal(IShipment, IMarket, Currency)
Gets the shipping tax total for the return shipment that contains IReturnLineItems.
Declaration
[Obsolete("This method is no longer used. Will remain at least until May 2019.")]
protected virtual Money CalculateShippingReturnTaxTotal(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The return shipment. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculation. |
Returns
Type | Description |
---|---|
Money | The shipping tax for the return shipment. |
CalculateShippingTax(ILineItem, IMarket, IOrderAddress, Money)
Calculates the shipping tax of an ILineItem.
Declaration
protected virtual Money CalculateShippingTax(ILineItem lineItem, IMarket market, IOrderAddress shippingAddress, Money basePrice)
Parameters
Type | Name | Description |
---|---|---|
ILineItem | lineItem | The line item. |
IMarket | market | The market to be used in the calculation. |
IOrderAddress | shippingAddress | The shipping address. |
Money | basePrice | The base price. |
Returns
Type | Description |
---|---|
Money | The shipping tax. |
Remarks
IMPORTANT - It will take the PricesIncludeTax setting on the order where the line item belongs to into account when calculating the shipping tax.
This means that if the value is True
, then shipping tax will be calculated based on the assumption that basePrice
already includes tax.
CalculateShippingTaxTotal(IShipment, IMarket, Currency)
Gets the shipping tax total for the shipment.
Declaration
[Obsolete("This method is no longer used. Will remain at least until May 2019.")]
protected virtual Money CalculateShippingTaxTotal(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculation. |
Returns
Type | Description |
---|---|
Money | The shipping tax for the shipment. |
CalculateTaxTotal(IOrderForm, IMarket, Currency)
Gets the tax total for the order form.
Declaration
[Obsolete("This method is no longer used. Will remain at least until May 2019.")]
protected virtual Money CalculateTaxTotal(IOrderForm orderForm, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IOrderForm | orderForm | The order form. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculation. |
Returns
Type | Description |
---|---|
Money | The total tax for the order form. |
CalculateTaxTotal(IOrderGroup, IMarket, Currency)
Gets the tax total.
Declaration
[Obsolete("This method is no longer used. Will remain at least until May 2019.")]
protected virtual Money CalculateTaxTotal(IOrderGroup orderGroup, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IOrderGroup | orderGroup | The order group. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculation. |
Returns
Type | Description |
---|---|
Money | The total tax for the order. |
Remarks
Gets the result by looping over all order forms and calling GetTaxTotal.
GetExtendedPrice(ILineItem, Currency)
Gets the extended price of the line item.
Declaration
protected virtual Money GetExtendedPrice(ILineItem lineItem, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
ILineItem | lineItem | The line item. |
Currency | currency | The currency. |
Returns
Type | Description |
---|---|
Money | The discounted price of the line item. |
GetReturnTaxTotal(IReturnOrderForm, IMarket, Currency)
Gets the tax total for an IReturnOrderForm.
Declaration
[Obsolete("This method is no longer used, use IReturnOrderFormCalculator.GetReturnTaxTotal instead. Will remain at least until May 2019.")]
public Money GetReturnTaxTotal(IReturnOrderForm returnOrderForm, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IReturnOrderForm | returnOrderForm | The return order form. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculations. |
Returns
Type | Description |
---|---|
Money | The total tax for the return order form. |
GetSalesTax(ILineItem, IMarket, IOrderAddress, Money)
Gets the sales tax of an ILineItem.
Declaration
public Money GetSalesTax(ILineItem lineItem, IMarket market, IOrderAddress shippingAddress, Money basePrice)
Parameters
Type | Name | Description |
---|---|---|
ILineItem | lineItem | The line item. |
IMarket | market | The market to be used in the calculation. |
IOrderAddress | shippingAddress | The shipping address. |
Money | basePrice | The base price. |
Returns
Type | Description |
---|---|
Money | The sales tax. |
Examples
public void GetSalesTax(ILineItem lineItem, IMarket market, IOrderAddress shippingAddress, Money basePrice, ITaxCalculator taxCalculator)
{
var salesTaxAmount = taxCalculator.GetSalesTax(lineItem, market, shippingAddress, basePrice);
Debug.WriteLine("Sales tax amount: ", salesTaxAmount);
}
GetSalesTax(IEnumerable<ILineItem>, IMarket, IOrderAddress, Currency)
Gets the sales tax of a collection of ILineItems.
Declaration
public Money GetSalesTax(IEnumerable<ILineItem> lineItems, IMarket market, IOrderAddress shippingAddress, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<ILineItem> | lineItems | The line item. |
IMarket | market | The market to be used in the calculation. |
IOrderAddress | shippingAddress | The shipping address. |
Currency | currency | The currency. |
Returns
Type | Description |
---|---|
Money | The sales tax. |
Examples
public void GetSalesTax(ILineItem lineItem, IMarket market, IOrderAddress shippingAddress, Money basePrice, ITaxCalculator taxCalculator)
{
var salesTaxAmount = taxCalculator.GetSalesTax(lineItem, market, shippingAddress, basePrice);
Debug.WriteLine("Sales tax amount: ", salesTaxAmount);
}
GetShippingReturnTaxTotal(IShipment, IMarket, Currency)
Gets the tax total for a return shipment that contains IReturnLineItem.
Declaration
[Obsolete("This method is no longer used, use IShippingCalculator.GetShippingReturnTax instead. Will remain at least until May 2019.")]
public Money GetShippingReturnTaxTotal(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The return shipment. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculations. |
Returns
Type | Description |
---|---|
Money | The shipping tax for the return shipment. |
GetShippingTax(ILineItem, IMarket, IOrderAddress, Money)
Gets the shipping tax of an ILineItem.
Declaration
public Money GetShippingTax(ILineItem lineItem, IMarket market, IOrderAddress shippingAddress, Money basePrice)
Parameters
Type | Name | Description |
---|---|---|
ILineItem | lineItem | The line item. |
IMarket | market | The market to be used in the calculation. |
IOrderAddress | shippingAddress | The shipping address. |
Money | basePrice | The base price. |
Returns
Type | Description |
---|---|
Money | The shipping tax. |
Examples
public void GetShippingTax(ILineItem lineItem, IMarket market, IOrderAddress shippingAddress, Money basePrice, ITaxCalculator taxCalculator)
{
var shippingTaxAmount = taxCalculator.GetShippingTax(lineItem, market, shippingAddress, basePrice);
Debug.WriteLine("Shipping tax amount: ", shippingTaxAmount);
}
GetShippingTaxTotal(IShipment, IMarket, Currency)
Gets the shipping tax total for the shipment.
Declaration
[Obsolete("This method is no longer used, use IShippingCalculator.GetShippingTax instead. Will remain at least until May 2019.")]
public Money GetShippingTaxTotal(IShipment shipment, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IShipment | shipment | The shipment. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculation. |
Returns
Type | Description |
---|---|
Money | The shipping tax for the shipment. |
GetTaxCategoryName(ILineItem)
Gets the tax category name from the line item.
Declaration
protected virtual string GetTaxCategoryName(ILineItem lineItem)
Parameters
Type | Name | Description |
---|---|---|
ILineItem | lineItem | The line item. |
Returns
Type | Description |
---|---|
System.String | The tax category name. |
GetTaxCategoryNameById(Int32)
Gets the tax category name by tax category id.
Declaration
[Obsolete("This method is no longer used, use GetTaxCategoryName(ILineItem lineItem) instead. Will remain at least until May 2019.")]
protected virtual string GetTaxCategoryNameById(int taxCategoryId)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | taxCategoryId | The tax category id. |
Returns
Type | Description |
---|---|
System.String | The tax category name. |
GetTaxTotal(IOrderForm, IMarket, Currency)
Gets the tax total for the order form.
Declaration
[Obsolete("This method is no longer used, use IOrderFormCalculator.GetTaxTotal instead. Will remain at least until May 2019.")]
public Money GetTaxTotal(IOrderForm orderForm, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IOrderForm | orderForm | The order form. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculation. |
Returns
Type | Description |
---|---|
Money | The total tax for the order form |
GetTaxTotal(IOrderGroup, IMarket, Currency)
Gets the tax total.
Declaration
[Obsolete("This method is no longer used, use IOrderGroupCalculator.GetTaxTotal instead. Will remain at least until May 2019.")]
public Money GetTaxTotal(IOrderGroup orderGroup, IMarket market, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
IOrderGroup | orderGroup | The order group. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculation. |
Returns
Type | Description |
---|---|
Money | The total tax for the order. |
Remarks
Gets the result by looping over all order forms and calling GetTaxTotal.
GetTaxValues(String, String, IOrderAddress)
Gets the tax values.
Declaration
protected virtual IEnumerable<ITaxValue> GetTaxValues(string taxCategory, string languageCode, IOrderAddress orderAddress)
Parameters
Type | Name | Description |
---|---|---|
System.String | taxCategory | The tax category. |
System.String | languageCode | The language code. |
IOrderAddress | orderAddress | The order address. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ITaxValue> | The tax values. |
ValidateSalesTax(Money)
Validates the sales tax.
Declaration
protected virtual void ValidateSalesTax(Money money)
Parameters
Type | Name | Description |
---|---|---|
Money | money | The calculated value. |
ValidateShippingTax(Money)
Validates the shipping tax.
Declaration
protected virtual void ValidateShippingTax(Money money)
Parameters
Type | Name | Description |
---|---|---|
Money | money | The calculated value. |
ValidateTaxTotalForOrder(Money)
Validates the shipping item total.
Declaration
[Obsolete("This method is no longer used. Will remain at least until May 2019.")]
protected virtual void ValidateTaxTotalForOrder(Money money)
Parameters
Type | Name | Description |
---|---|---|
Money | money | The calculated value. |
ValidateTaxTotalForOrderForm(Money)
Validates the shipping item total.
Declaration
[Obsolete("This method is no longer used. Will remain at least until May 2019.")]
protected virtual void ValidateTaxTotalForOrderForm(Money money)
Parameters
Type | Name | Description |
---|---|---|
Money | money | The calculated value. |