Package de.hybris.platform.util
Class DiscountValue
java.lang.Object
de.hybris.platform.util.DiscountValue
- All Implemented Interfaces:
PDTValue,Serializable,Cloneable
string-storeable discount value object.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDiscountValue(String code, double value, boolean absolute, double appliedValue, String isoCode) creates a new discount value with applied value.DiscountValue(String code, double value, boolean absolute, double appliedValue, String isoCode, boolean asTargetPrice) DiscountValue(String code, double value, boolean absolute, String currencyIsoCode) creates a new discount value without applied value ( will be 0.0 ).DiscountValue(String code, double value, String currencyIsoCode, boolean asTargetPrice) Creates a new un-applied absolute discount value. -
Method Summary
Modifier and TypeMethodDescriptionCreates a copy of this discount value holding the applied value for a given price rounded to given digits.static ListCreates a collection of applied discount values for a given price and a tax value collection.clone()static DiscountValuecreateAbsolute(String code, Double doubleValue, String currencyIsoCode) protected DiscountValuecreateAbsoluteAppliedValue(double quantity, int digits, String currencyIsoCode) static DiscountValuecreateRelative(String code, Double doubleValue) protected DiscountValuecreateRelativeAppliedValue(double price, int digits, String currencyIsoCode) static DiscountValuecreateTargetPrice(String code, Double doubleValue, String currencyIsoCode) protected DiscountValuecreateTargetPriceAppliedValue(double quantity, double totalPriceWithoutDiscounts, int digits, String currencyIsoCode) booleanbooleanequalsIgnoreAppliedValue(DiscountValue discountValue) doublethe actual value of this discount.getCode()doublegetValue()The discount value.inthashCode()booleanReturnstrueif theDiscountValueis an absolute discount, otherwisefalseis returned.booleanIf true the contained value represents the intended target price.static DiscountValueparseDiscountValue(String str) creates a discount value object from its string representation created via @see #toString().static Collectioncreates a discount value collection from its string representation created via @see #toString(Collection).static doublesumAppliedValues(Collection values) toString()static StringtoString(Collection discountValueCollection) creates the string representation of a collection of discount values.
-
Constructor Details
-
DiscountValue
creates a new discount value without applied value ( will be 0.0 ).- Parameters:
code- the code of the actual discount item - cannot be nullvalue- the discount rate or valueabsolute- tells whether this value is relative or absolute
-
DiscountValue
Creates a new un-applied absolute discount value. -
DiscountValue
public DiscountValue(String code, double value, boolean absolute, double appliedValue, String isoCode) creates a new discount value with applied value.- Parameters:
code- the code of the actual discount item - cannot be nullvalue- the discount rate or valueabsolute- tells whether this value is relative or absoluteappliedValue- the applied value of this discount
-
DiscountValue
-
-
Method Details
-
createRelative
-
createAbsolute
-
createTargetPrice
public static DiscountValue createTargetPrice(String code, Double doubleValue, String currencyIsoCode) -
apply
Creates a copy of this discount value holding the applied value for a given price rounded to given digits.- Parameters:
price- the price to apply this tax value todigits- the digits to round the value to, if < 0 no rounding is done- Returns:
- the copy of this discount vale
- Since:
- 2.20
-
createRelativeAppliedValue
protected DiscountValue createRelativeAppliedValue(double price, int digits, String currencyIsoCode) -
createAbsoluteAppliedValue
protected DiscountValue createAbsoluteAppliedValue(double quantity, int digits, String currencyIsoCode) -
createTargetPriceAppliedValue
protected DiscountValue createTargetPriceAppliedValue(double quantity, double totalPriceWithoutDiscounts, int digits, String currencyIsoCode) -
apply
public static List apply(double quantity, double startPrice, int digits, List values, String currencyIsoCode) Creates a collection of applied discount values for a given price and a tax value collection. All resulting applied values prices are rounded to the given number of digits.- Parameters:
values- the collection of discount values to apply to the pricestartPrice- the price to apply these discounts to - the discount values are applied iteratively decreasing the (start)price each time !digits- the number of digits to round, if < 0 no rounding is done- Returns:
- a list containing all applied discount values for a given price and a tax value collection.
- Since:
- 2.20
-
sumAppliedValues
-
getCode
- Returns:
- the code this values discount. normally this should match a @see de.hybris.platform.jalo.order.price.Discount item's code but dont rely on it (e.g. when discount values are imported along with their orders and the actual discount doesnt exist )
-
getCurrencyIsoCode
- Returns:
- the currency isocode
-
getValue
public double getValue()The discount value. This value represent the discount rate ( or discount value for absolute discount ) only - use @see #getAppliedValue() to get the actual (absolute) discout value for the order or entry. -
isAsTargetPrice
public boolean isAsTargetPrice()If true the contained value represents the intended target price. Therefore the applied value is determined from the difference between the base price and the target price.A target price discount value must also contain a currency iso code!
-
getAppliedValue
public double getAppliedValue()the actual value of this discount. means this is the value you get when the discount was applied to the order or entry which this value relates to.- Returns:
- the applied value of the
DiscountValue.
-
isAbsolute
public boolean isAbsolute()Returnstrueif theDiscountValueis an absolute discount, otherwisefalseis returned.- Returns:
trueif theDiscountValueis an absolute discount, otherwisefalse.
-
clone
-
toString
-
toString
creates the string representation of a collection of discount values. you may restore this collection via @see #parseDiscountValueCollection(String)(String).- Parameters:
discountValueCollection- a collection containing StandardDiscountValues- Returns:
- the string representation of a collection of discount values.
-
parseDiscountValueCollection
creates a discount value collection from its string representation created via @see #toString(Collection).- Parameters:
str- the string representation of the discount values.- Returns:
- a discount value collection from its string representation.
- Throws:
IllegalArgumentException- if a parse error occured
-
parseDiscountValue
creates a discount value object from its string representation created via @see #toString().- Parameters:
str- the string representation of the discount values.- Returns:
- a discount value object from its string representation.
- Throws:
IllegalArgumentException- if the string is not valid
-
hashCode
public int hashCode() -
equals
-
equalsIgnoreAppliedValue
-