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
currencyCurrencyThe currency for the price information.
Fields
_vatPercent
protected double _vatPercent
Field Value
Properties
AllowOrderDiscounts
Gets or sets the value indicating whether order discounts are allowed when calculated on this price.
public virtual bool AllowOrderDiscounts { get; set; }
Property Value
AllowOrderLineDiscounts
Gets or sets the value indicating whether order line discounts are allowed when calculating on this price. This also includes DiscountPercentage, if this is false, it will not be subtracted from the price.
public virtual bool AllowOrderLineDiscounts { get; set; }
Property Value
Currency
Gets or sets the currency.
public virtual Currency Currency { get; set; }
Property Value
DiscountPercentage
Gets or sets the discount percentage
public virtual double DiscountPercentage { get; set; }
Property Value
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
Trueif the price is informative; otherwisefalse.
Price
Gets the price, including or excluding VAT based on the Dynamicweb.Ecommerce.Prices.PriceInfo.ShowPricesWithVat property.
public virtual double Price { get; }
Property Value
PriceFormatted
Gets the price formatted based on the current currency.
public virtual string PriceFormatted { get; }
Property Value
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
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
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
PriceSource
Gets or sets a value indicating what price provider generated the price.
public PriceSource? PriceSource { get; set; }
Property Value
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
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
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
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
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
trueif 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
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
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
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
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
infoIPriceInfoThe price information to add.
Returns
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
infoIPriceReferenceInfoThe price reference information.
Returns
Divide(double)
Divides the price by a factor.
public virtual PriceInfo Divide(double factor)
Parameters
factordoubleThe factor.
Returns
HasSamePrice(PriceInfo)
Determines whether the given PriceInfo object has the same price as this one.
public virtual bool HasSamePrice(PriceInfo priceInfo)
Parameters
priceInfoPriceInfoThe price information to compare.
Returns
- bool
trueif prices are the same; otherwise,false.
Multiply(double)
Multiplies the price by a factor.
public virtual PriceInfo Multiply(double factor)
Parameters
factordoubleThe factor.
Returns
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
Returns
Substract(IPriceInfo)
Subtracts the specified price information.
public virtual PriceInfo Substract(IPriceInfo info)
Parameters
infoIPriceInfoThe price information.
Returns
Substract(IPriceReferenceInfo)
Subtracts the specified price information from IPriceReferenceInfo.
public virtual PriceInfo Substract(IPriceReferenceInfo info)
Parameters
infoIPriceReferenceInfoThe price reference information.
Returns
ToPrice(Currency)
Converts the current price to a price with a new currency.
public PriceInfo? ToPrice(Currency toCurrency)
Parameters
toCurrencyCurrencyThe new currency.
Returns
ToString()
Returns a string that represents this instance.
public override string ToString()