World is now on Opti ID! Learn more

Class DefaultLineItemCalculator

The default line item calculator.

Inheritance
System.Object
DefaultLineItemCalculator
Implements
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Commerce.Order.Calculator
Assembly: EPiServer.Business.Commerce.dll
Version: 13.30.0
Syntax
public class DefaultLineItemCalculator : ILineItemCalculator

Constructors

DefaultLineItemCalculator(ITaxCalculator)

Initialize a new instance of the DefaultLineItemCalculator class.

Declaration
public DefaultLineItemCalculator(ITaxCalculator taxCalculator)
Parameters
Type Name Description
ITaxCalculator taxCalculator

The tax calculator.

Methods

CalculateDiscountedPrice(ILineItem, Currency)

Calculates the discounted price of an ILineItem.

Declaration
protected virtual Money CalculateDiscountedPrice(ILineItem lineItem, Currency currency)
Parameters
Type Name Description
ILineItem lineItem

The line item to calculate the discounted price for.

Currency currency

The currency to be used in the calculations.

Returns
Type Description
Money

The discounted price.

CalculateExtendedPrice(ILineItem, Currency)

Calculates the extended price of an ILineItem.

Declaration
protected virtual Money CalculateExtendedPrice(ILineItem lineItem, Currency currency)
Parameters
Type Name Description
ILineItem lineItem

The line item to calculate the extended price for.

Currency currency

The currency to be used in the calculations.

Returns
Type Description
Money

The rounded extended price.

CalculateSalesTax(ILineItem, IMarket, Currency, IOrderAddress)

Calculates sales tax of an ILineItem.

Declaration
protected virtual Money CalculateSalesTax(ILineItem lineItem, IMarket market, Currency currency, IOrderAddress shippingAddress)
Parameters
Type Name Description
ILineItem lineItem

The line item.

IMarket market

The market to be used in the calculation.

Currency currency

The currency to be used in the calculations.

IOrderAddress shippingAddress

The shipping address to be used in the calculations.

Returns
Type Description
Money

The sales tax for the line item.

CalculateSalesTax(IEnumerable<ILineItem>, IMarket, Currency, IOrderAddress)

Calculates sales tax of a collection of ILineItems.

Declaration
protected virtual Money CalculateSalesTax(IEnumerable<ILineItem> lineItems, IMarket market, Currency currency, IOrderAddress shippingAddress)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<ILineItem> lineItems

The line items.

IMarket market

The market to be used in the calculation.

Currency currency

The currency to be used in the calculations.

IOrderAddress shippingAddress

The shipping address to be used in the calculations.

Returns
Type Description
Money

The sales taxes for a group of line items.

GetDiscountedPrice(ILineItem, Currency)

Gets the discounted price of an ILineItem.

Declaration
public Money GetDiscountedPrice(ILineItem lineItem, Currency currency)
Parameters
Type Name Description
ILineItem lineItem

The line item.

Currency currency

The currency to be used in the calculations.

Returns
Type Description
Money

The line item discounted price.

Examples
        public void GetDiscountedPrice(ILineItem lineItem, Currency currency, ILineItemCalculator lineItemCalculator)
{
var discountedPrice = lineItemCalculator.GetDiscountedPrice(lineItem, currency);
Debug.WriteLine("Discounted price for '{0}': {1}", lineItem.Code, discountedPrice);
}

GetExtendedPrice(ILineItem, Currency)

Gets the extended price of an ILineItem.

Declaration
public Money GetExtendedPrice(ILineItem lineItem, Currency currency)
Parameters
Type Name Description
ILineItem lineItem

The line item to calculate the extended price for.

Currency currency

The currency to be used in the calculations.

Returns
Type Description
Money

The rounded extended price.

Examples
        public void GetExtendedPrice(ILineItem lineItem, Currency currency, ILineItemCalculator lineItemCalculator)
{
var extendedPrice = lineItemCalculator.GetExtendedPrice(lineItem, currency);
Debug.WriteLine("Extended price for '{0}': {1}", lineItem.Code, extendedPrice);
}
Exceptions
Type Condition
System.Exception

Thrown when calculation fails.

GetLineItemPrices(ILineItem, Currency)

Gets the extended and discounted prices of an ILineItem.

Declaration
public LineItemPrices GetLineItemPrices(ILineItem lineItem, Currency currency)
Parameters
Type Name Description
ILineItem lineItem

The line item.

Currency currency

The currency to be used in the calculations.

Returns
Type Description
LineItemPrices

The prices for the line item.

Examples
        public void GetLineItemPrices(ILineItem lineItem, Currency currency, ILineItemCalculator lineItemCalculator)
{
var lineItemdPrices = lineItemCalculator.GetLineItemPrices(lineItem, currency);
Debug.WriteLine("Extended price for '{0}': {1}", lineItem.Code, lineItemdPrices.ExtendedPrice);
Debug.WriteLine("Discounted price for '{0}': {1}", lineItem.Code, lineItemdPrices.DiscountedPrice);
}

GetSalesTax(ILineItem, IMarket, Currency, IOrderAddress)

Gets the sales tax of an ILineItem.

Declaration
public Money GetSalesTax(ILineItem lineItem, IMarket market, Currency currency, IOrderAddress shippingAddress)
Parameters
Type Name Description
ILineItem lineItem

The line item.

IMarket market

The market to be used in the calculation.

Currency currency

The currency to be used in the calculations.

IOrderAddress shippingAddress

The shipping address to be used in the calculations.

Returns
Type Description
Money

The sales tax for the line item.

Examples
        public void GetSalesTax(ILineItem lineItem, IMarket market, Currency currency, IOrderAddress shippingAddress, ILineItemCalculator lineItemCalculator)
{
var salesTax = lineItemCalculator.GetSalesTax(lineItem, market, currency, shippingAddress);
Debug.WriteLine("Sales tax for '{0}': {1}", lineItem.Code, salesTax);
}

GetSalesTax(IEnumerable<ILineItem>, IMarket, Currency, IOrderAddress)

Gets the sales tax of a collection of ILineItems.

Declaration
public Money GetSalesTax(IEnumerable<ILineItem> lineItems, IMarket market, Currency currency, IOrderAddress shippingAddress)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<ILineItem> lineItems

The line items.

IMarket market

The market to be used in the calculation.

Currency currency

The currency to be used in the calculations.

IOrderAddress shippingAddress

The shipping address to be used in the calculations.

Returns
Type Description
Money

The sales tax for the line items.

Examples
        public void GetSalesTax(IEnumerable<ILineItem> lineItems, IMarket market, Currency currency, IOrderAddress shippingAddress, ILineItemCalculator lineItemCalculator)
{
var salesTax = lineItemCalculator.GetSalesTax(lineItems, market, currency, shippingAddress);
}

ValidateDiscountedPrice(Money)

Validates the discounted price.

Declaration
protected virtual void ValidateDiscountedPrice(Money money)
Parameters
Type Name Description
Money money

The calculated value.

ValidateExtendedPrice(Money)

Validates the extended price.

Declaration
protected virtual void ValidateExtendedPrice(Money money)
Parameters
Type Name Description
Money money

The calculated value.

ValidateSalesTax(Money)

Validates the sales tax.

Declaration
protected virtual void ValidateSalesTax(Money money)
Parameters
Type Name Description
Money money

The sales tax.

Implements