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
-
Price
Info
- Implements
- Derived
- Inherited Members
Constructors
PriceInfo(Currency)
Initializes a new instance of the Price
Parameters
currency
CurrencyThe currency for the price information.
Fields
_vatPercent
Field Value
Properties
Currency
Gets or sets the currency.
Property Value
DiscountPercentage
Gets or sets the discount percentage
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.
Property Value
- bool
True
if the price is informative; otherwisefalse
.
Price
Gets the price, including or excluding VAT based on the Dynamicweb.
Property Value
PriceFormatted
Gets the price formatted based on the current currency.
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.
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.
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.
Property Value
PriceSource
Gets or sets a value indicating what price provider generated the price.
Property Value
PriceWithVAT
Gets or sets the price including VAT.
Property Value
- double
The price including VAT.
PriceWithVATFormatted
Gets the price including VAT, formatted based on the current currency.
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.
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.
Property Value
- double
The price excluding VAT.
PriceWithoutVATFormatted
Gets the price without VAT formatted.
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.
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 Price
Property Value
- bool
true
if the price has reverse charge for VAT; otherwise,false
.
VAT
Gets or sets the VAT amount.
Property Value
- double
The VAT amount.
VATFormatted
Gets the VAT amount formatted based on the current currency.
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.
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.
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
- Argument
Exception VATPercent is not a number or VATPercent is infinite.
VATPercentFormatted
Gets the VAT percent formatted as a string with a percent symbol.
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.
Parameters
info
IPriceInfo The price information to add.
Returns
Exceptions
- Price
Info Currency Exception Thrown when the currencies of the two Price
Info instances do not match and neither price is zero.- Invalid
Operation Exception Thrown when attempting to add informative and non-informative price information.
Add(IPriceReferenceInfo)
Adds the specified price information from IPriceReferenceInfo.
Parameters
info
IPriceReference Info The price reference information.
Returns
Divide(double)
Divides the price by a factor.
Parameters
factor
doubleThe factor.
Returns
HasSamePrice(PriceInfo)
Determines whether the given Price
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.
Parameters
factor
doubleThe factor.
Returns
Multiply(double, int)
Multiplies the price by a factor and rounds the result to a specific number of decimals.
Parameters
Returns
Substract(IPriceInfo)
Subtracts the specified price information.
Parameters
info
IPriceInfo The price information.
Returns
Substract(IPriceReferenceInfo)
Subtracts the specified price information from IPriceReferenceInfo.
Parameters
info
IPriceReference Info The price reference information.
Returns
ToPrice(Currency)
Converts the current price to a price with a new currency.
Parameters
toCurrency
CurrencyThe new currency.
Returns
ToString()
Returns a string that represents this instance.