Table of Contents

Class PriceInfo

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

Represents price-related information, including VAT, currency, and formatted prices. This class handles operations related to price calculations, such as addition, subtraction, multiplication, division, and formatting with or without VAT.

[Serializable]
public class PriceInfo : IPriceReferenceInfo, IInformativePriceInfo, IPriceInfo, IPriceSourceInfo
Inheritance
PriceInfo
Implements
Derived
Inherited Members

Constructors

PriceInfo(Currency)

Initializes a new instance of the PriceInfo class.

public PriceInfo(Currency currency)

Parameters

currency Currency

The currency for the price information.

Fields

_vatPercent

protected double _vatPercent

Field Value

double

Properties

Currency

Gets or sets the currency.

public virtual Currency Currency { get; set; }

Property Value

Currency

DiscountPercentage

Gets or sets the discount percentage

public virtual double DiscountPercentage { get; set; }

Property Value

double

IsInformative

Gets or sets whether the price is informative. An informative price is not used for price calculations but only acts as informational, like MRP etc.

public virtual bool IsInformative { get; set; }

Property Value

bool

True if the price is informative; otherwise false.

Price

Gets the price, including or excluding VAT based on the Dynamicweb.Ecommerce.Prices.PriceInfo.ShowPricesWithVat property.

public virtual double Price { get; }

Property Value

double

PriceFormatted

Gets the price formatted based on the current currency.

public virtual string PriceFormatted { get; }

Property Value

string

Examples

For example, if the price is 25.0d and the currency is DKK, the formatted string will be "25,00 kr".

PriceFormattedNoSymbol

Gets the price formatted without a currency symbol.

public virtual string PriceFormattedNoSymbol { get; }

Property Value

string

Examples

For example, if the price is 25.0d and the currency is DKK, the formatted string will be "25,00".

PricePIP

Minimum fluctuation or smallest increment of price movement.

public virtual long PricePIP { get; }

Property Value

long

Examples

For example, if the price is 25.12 the pip amount will be 2512 (25.12 * 100 where 100 is 10 POW number of decimals of the currency, e.g 10^2)

PriceReference

Gets or sets the price reference.

public virtual string? PriceReference { get; set; }

Property Value

string

PriceSource

Gets or sets a value indicating what price provider generated the price.

public PriceSource? PriceSource { get; set; }

Property Value

PriceSource?

PriceWithVAT

Gets or sets the price including VAT.

public virtual double PriceWithVAT { get; set; }

Property Value

double

The price including VAT.

PriceWithVATFormatted

Gets the price including VAT, formatted based on the current currency.

public virtual string PriceWithVATFormatted { get; }

Property Value

string

Examples

For example, if the price with VAT is 25.0d and the currency is DKK, the formatted string will be "25,00 kr".

PriceWithVATFormattedNoSymbol

Gets the price with formatted VAT without symbol.

public virtual string PriceWithVATFormattedNoSymbol { get; }

Property Value

string

Examples

For example, if the price with VAT is 25.0d and the currency is DKK, the formatted string will be "25,00".

PriceWithoutVAT

Gets or sets the price excluding VAT.

public virtual double PriceWithoutVAT { get; set; }

Property Value

double

The price excluding VAT.

PriceWithoutVATFormatted

Gets the price without VAT formatted.

public virtual string PriceWithoutVATFormatted { get; }

Property Value

string

Examples

For example, if the price without VAT is 25.0d and the currency is DKK, the formatted string will be "25,00".

PriceWithoutVATFormattedNoSymbol

Gets the price without VAT formatted no symbol.

public virtual string PriceWithoutVATFormattedNoSymbol { get; }

Property Value

string

Examples

For example, if the price without VAT is 25.0d and the currency is DKK, the formatted string will be "25,00".

ReverseChargeForVat

Gets or sets a value indicating whether this PriceInfo has reverse charge for VAT.

public bool ReverseChargeForVat { get; set; }

Property Value

bool

true if the price has reverse charge for VAT; otherwise, false.

VAT

Gets or sets the VAT amount.

public virtual double VAT { get; set; }

Property Value

double

The VAT amount.

VATFormatted

Gets the VAT amount formatted based on the current currency.

public virtual string VATFormatted { get; }

Property Value

string

Examples

For example, if the VAT amount is 25.0d and the currency is DKK, the formatted string will be "25,00 kr".

VATFormattedNoSymbol

Gets the VAT formatted without a currency symbol.

public virtual string VATFormattedNoSymbol { get; }

Property Value

string

Examples

For example, if the VAT amount is 25.0d and the currency is DKK, the formatted string will be "25,00".

VATPercent

Gets or sets the VAT percentage. If the percentage is not set, it is calculated from VAT and price.

public virtual double VATPercent { get; set; }

Property Value

double

Remarks

The calculation is done by dividing the VAT amount by the price excluding VAT and multiplying by 100. If the calculated percentage is NaN or Infinity, it defaults to 0.0d.

Exceptions

ArgumentException

VATPercent is not a number or VATPercent is infinite.

VATPercentFormatted

Gets the VAT percent formatted as a string with a percent symbol.

public virtual string VATPercentFormatted { get; }

Property Value

string

Examples

For example, if the VAT percent is 25.0d, the formatted string will be "25%".

Methods

Add(IPriceInfo)

Adds the specified price information to the current price information.

public virtual PriceInfo Add(IPriceInfo info)

Parameters

info IPriceInfo

The price information to add.

Returns

PriceInfo

A new PriceInfo instance with the combined price information.

Exceptions

PriceInfoCurrencyException

Thrown when the currencies of the two PriceInfo instances do not match and neither price is zero.

InvalidOperationException

Thrown when attempting to add informative and non-informative price information.

Add(IPriceReferenceInfo)

Adds the specified price information from IPriceReferenceInfo.

public virtual PriceInfo Add(IPriceReferenceInfo info)

Parameters

info IPriceReferenceInfo

The price reference information.

Returns

PriceInfo

The PriceInfo.

Divide(double)

Divides the price by a factor.

public virtual PriceInfo Divide(double factor)

Parameters

factor double

The factor.

Returns

PriceInfo

The PriceInfo.

HasSamePrice(PriceInfo)

Determines whether the given PriceInfo object has the same price as this one.

public virtual bool HasSamePrice(PriceInfo priceInfo)

Parameters

priceInfo PriceInfo

The price information to compare.

Returns

bool

true if prices are the same; otherwise, false.

Multiply(double)

Multiplies the price by a factor.

public virtual PriceInfo Multiply(double factor)

Parameters

factor double

The factor.

Returns

PriceInfo

The PriceInfo.

Multiply(double, int)

Multiplies the price by a factor and rounds the result to a specific number of decimals.

public virtual PriceInfo Multiply(double factor, int roundingDecimals)

Parameters

factor double

The factor.

roundingDecimals int

Number of decimals to round the result.

Returns

PriceInfo

The PriceInfo.

Substract(IPriceInfo)

Subtracts the specified price information.

public virtual PriceInfo Substract(IPriceInfo info)

Parameters

info IPriceInfo

The price information.

Returns

PriceInfo

The PriceInfo.

Substract(IPriceReferenceInfo)

Subtracts the specified price information from IPriceReferenceInfo.

public virtual PriceInfo Substract(IPriceReferenceInfo info)

Parameters

info IPriceReferenceInfo

The price reference information.

Returns

PriceInfo

The PriceInfo.

ToPrice(Currency)

Converts the current price to a price with a new currency.

public PriceInfo? ToPrice(Currency toCurrency)

Parameters

toCurrency Currency

The new currency.

Returns

PriceInfo

Returns new PriceInfo class if successful, otherwise null.

ToString()

Returns a string that represents this instance.

public override string ToString()

Returns

string

A string that represents this instance.

To top