Class DefaultLineItemCalculator
The default line item calculator.
Inheritance
Implements
Inherited Members
Namespace: EPiServer.Commerce.Order.Calculator
Assembly: EPiServer.Business.Commerce.dll
Version: 13.30.0Syntax
public class DefaultLineItemCalculator : ILineItemCalculator
Constructors
DefaultLineItemCalculator(ITaxCalculator)
Initialize a new instance of the Default
Declaration
public DefaultLineItemCalculator(ITaxCalculator taxCalculator)
Parameters
Type | Name | Description |
---|---|---|
ITax |
taxCalculator | The tax calculator. |
Methods
CalculateDiscountedPrice(ILineItem, Currency)
Calculates the discounted price of an ILine
Declaration
protected virtual Money CalculateDiscountedPrice(ILineItem lineItem, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
ILine |
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 ILine
Declaration
protected virtual Money CalculateExtendedPrice(ILineItem lineItem, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
ILine |
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 ILine
Declaration
protected virtual Money CalculateSalesTax(ILineItem lineItem, IMarket market, Currency currency, IOrderAddress shippingAddress)
Parameters
Type | Name | Description |
---|---|---|
ILine |
lineItem | The line item. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculations. |
IOrder |
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 ILine
Declaration
protected virtual Money CalculateSalesTax(IEnumerable<ILineItem> lineItems, IMarket market, Currency currency, IOrderAddress shippingAddress)
Parameters
Type | Name | Description |
---|---|---|
System. |
lineItems | The line items. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculations. |
IOrder |
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 ILine
Declaration
public Money GetDiscountedPrice(ILineItem lineItem, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
ILine |
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 ILine
Declaration
public Money GetExtendedPrice(ILineItem lineItem, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
ILine |
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. |
Thrown when calculation fails. |
GetLineItemPrices(ILineItem, Currency)
Gets the extended and discounted prices of an ILine
Declaration
public LineItemPrices GetLineItemPrices(ILineItem lineItem, Currency currency)
Parameters
Type | Name | Description |
---|---|---|
ILine |
lineItem | The line item. |
Currency | currency | The currency to be used in the calculations. |
Returns
Type | Description |
---|---|
Line |
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 ILine
Declaration
public Money GetSalesTax(ILineItem lineItem, IMarket market, Currency currency, IOrderAddress shippingAddress)
Parameters
Type | Name | Description |
---|---|---|
ILine |
lineItem | The line item. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculations. |
IOrder |
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 ILine
Declaration
public Money GetSalesTax(IEnumerable<ILineItem> lineItems, IMarket market, Currency currency, IOrderAddress shippingAddress)
Parameters
Type | Name | Description |
---|---|---|
System. |
lineItems | The line items. |
IMarket | market | The market to be used in the calculation. |
Currency | currency | The currency to be used in the calculations. |
IOrder |
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. |