Table of Contents

Class PriceCalculator

Namespace
Dynamicweb.Ecommerce.Prices
Assembly
Dynamicweb.Ecommerce.dll

Common hub for price calculations.

public abstract class PriceCalculator
Inheritance
PriceCalculator
Inherited Members

Remarks

Register an implementation in the dependency container to take over how the platform calculates VAT, exchanges currencies and rounds money.

Methods

CalculateQualifiedPrice(double, Currency, Country, Currency)

Calculates a qualified price for the specified price value, converted from the default currency to the specified currency.

protected abstract PriceInfo CalculateQualifiedPrice(double price, Currency currency, Country country, Currency defaultCurrency)

Parameters

price double

The price value in the default currency.

currency Currency

The target currency.

country Country

The country used for VAT calculation.

defaultCurrency Currency

The default currency.

Returns

PriceInfo

The PriceInfo in the provided currency, using the resolved VAT based on the provided country.

ConvertToPIP(Currency?, double)

Converts the specified amount to a value in the smallest monetary unit for the specified Currency.

public abstract long ConvertToPIP(Currency? currency, double amount)

Parameters

currency Currency

The currency that determines the smallest monetary unit. When it has no culture, two decimals are assumed.

amount double

The amount to convert.

Returns

long

The converted amount in the smallest monetary unit.

ConvertToPIP(int, double)

Converts the specified amount to a value in the smallest monetary unit, given a number of decimals.

protected abstract long ConvertToPIP(int decimalDigits, double amount)

Parameters

decimalDigits int

The number of decimals the amount is expressed with.

amount double

The amount to convert.

Returns

long

The converted amount in the smallest monetary unit.

Exchange(double, Currency, Currency)

Converts the specified price from one currency to another.

protected abstract double Exchange(double price, Currency sourceCurrency, Currency destinationCurrency)

Parameters

price double

The price to convert.

sourceCurrency Currency

The currency the price is in.

destinationCurrency Currency

The currency to convert the price to.

Returns

double

The price in destinationCurrency.

Exchange(double, double, double)

Converts the specified price from one currency rate to another.

protected abstract double Exchange(double price, double sourceRate, double destinationRate)

Parameters

price double

The price to convert.

sourceRate double

The rate of the currency the price is in.

destinationRate double

The rate of the currency to convert the price to.

Returns

double

The price at destinationRate.

MinusVat(double, double)

Subtracts VAT from the specified price.

protected abstract double MinusVat(double price, double percent)

Parameters

price double

The price to subtract VAT from.

percent double

The VAT percent contained in the price.

Returns

double

The price without VAT.

PlusVat(double, double)

Adds VAT to the specified price.

protected abstract double PlusVat(double price, double percent)

Parameters

price double

The price to add VAT to.

percent double

The VAT percent to add.

Returns

double

The price including VAT.

Round(Currency?, double)

Rounds the specified price to the number of decimals the currency uses.

public abstract double Round(Currency? currency, double price)

Parameters

currency Currency

The currency that determines the number of decimals. When it has no culture, two decimals are assumed.

price double

The price to round.

Returns

double

The rounded price.

Round(int, double)

Rounds the specified price to the specified number of decimals.

public abstract double Round(int decimalDigits, double price)

Parameters

decimalDigits int

The number of decimals to round to.

price double

The price to round.

Returns

double

The rounded price.

To top