public class DiscountValue extends java.lang.Object implements java.lang.Cloneable, java.io.Serializable, PDTValue
| Constructor and Description |
|---|
DiscountValue(java.lang.String code,
double value,
boolean absolute,
double appliedValue,
java.lang.String isoCode)
creates a new discount value with applied value.
|
DiscountValue(java.lang.String code,
double value,
boolean absolute,
double appliedValue,
java.lang.String isoCode,
boolean asTargetPrice) |
DiscountValue(java.lang.String code,
double value,
boolean absolute,
java.lang.String currencyIsoCode)
creates a new discount value without applied value ( will be 0.0 ).
|
DiscountValue(java.lang.String code,
double value,
java.lang.String currencyIsoCode,
boolean asTargetPrice)
Creates a new un-applied absolute discount value.
|
| Modifier and Type | Method and Description |
|---|---|
static java.util.List |
apply(double quantity,
double startPrice,
int digits,
java.util.List values,
java.lang.String currencyIsoCode)
Creates a collection of applied discount values for a given price and a tax value collection.
|
DiscountValue |
apply(double quantity,
double price,
int digits,
java.lang.String currencyIsoCode)
Creates a copy of this discount value holding the applied value for a given price rounded to given digits.
|
java.lang.Object |
clone() |
static DiscountValue |
createAbsolute(java.lang.String code,
java.lang.Double doubleValue,
java.lang.String currencyIsoCode) |
protected DiscountValue |
createAbsoluteAppliedValue(double quantity,
int digits,
java.lang.String currencyIsoCode) |
static DiscountValue |
createRelative(java.lang.String code,
java.lang.Double doubleValue) |
protected DiscountValue |
createRelativeAppliedValue(double price,
int digits,
java.lang.String currencyIsoCode) |
static DiscountValue |
createTargetPrice(java.lang.String code,
java.lang.Double doubleValue,
java.lang.String currencyIsoCode) |
protected DiscountValue |
createTargetPriceAppliedValue(double quantity,
double totalPriceWithoutDiscounts,
int digits,
java.lang.String currencyIsoCode) |
boolean |
equals(java.lang.Object object) |
boolean |
equalsIgnoreAppliedValue(DiscountValue discountValue) |
double |
getAppliedValue()
the actual value of this discount.
|
java.lang.String |
getCode() |
java.lang.String |
getCurrencyIsoCode() |
double |
getValue()
The discount value.
|
int |
hashCode() |
boolean |
isAbsolute()
Returns
true if the DiscountValue is an absolute discount, otherwise false is
returned. |
boolean |
isAsTargetPrice()
If true the contained value represents the intended target price.
|
static DiscountValue |
parseDiscountValue(java.lang.String str)
creates a discount value object from its string representation created via @see #toString().
|
static java.util.Collection |
parseDiscountValueCollection(java.lang.String str)
creates a discount value collection from its string representation created via @see #toString(Collection).
|
static double |
sumAppliedValues(java.util.Collection values) |
java.lang.String |
toString() |
static java.lang.String |
toString(java.util.Collection discountValueCollection)
creates the string representation of a collection of discount values.
|
public DiscountValue(java.lang.String code,
double value,
boolean absolute,
java.lang.String currencyIsoCode)
code - the code of the actual discount item - cannot be nullvalue - the discount rate or valueabsolute - tells whether this value is relative or absolutepublic DiscountValue(java.lang.String code,
double value,
java.lang.String currencyIsoCode,
boolean asTargetPrice)
public DiscountValue(java.lang.String code,
double value,
boolean absolute,
double appliedValue,
java.lang.String isoCode)
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 discountpublic DiscountValue(java.lang.String code,
double value,
boolean absolute,
double appliedValue,
java.lang.String isoCode,
boolean asTargetPrice)
public static DiscountValue createRelative(java.lang.String code, java.lang.Double doubleValue)
public static DiscountValue createAbsolute(java.lang.String code, java.lang.Double doubleValue, java.lang.String currencyIsoCode)
public static DiscountValue createTargetPrice(java.lang.String code, java.lang.Double doubleValue, java.lang.String currencyIsoCode)
public DiscountValue apply(double quantity, double price, int digits, java.lang.String currencyIsoCode)
price - the price to apply this tax value todigits - the digits to round the value to, if < 0 no rounding is doneprotected DiscountValue createRelativeAppliedValue(double price, int digits, java.lang.String currencyIsoCode)
protected DiscountValue createAbsoluteAppliedValue(double quantity, int digits, java.lang.String currencyIsoCode)
protected DiscountValue createTargetPriceAppliedValue(double quantity, double totalPriceWithoutDiscounts, int digits, java.lang.String currencyIsoCode)
public static java.util.List apply(double quantity,
double startPrice,
int digits,
java.util.List values,
java.lang.String currencyIsoCode)
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 donepublic static double sumAppliedValues(java.util.Collection values)
public java.lang.String getCode()
public java.lang.String getCurrencyIsoCode()
public double getValue()
public boolean isAsTargetPrice()
public double getAppliedValue()
DiscountValue.public boolean isAbsolute()
true if the DiscountValue is an absolute discount, otherwise false is
returned.true if the DiscountValue is an absolute discount, otherwise false.public java.lang.Object clone()
clone in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Objectpublic static java.lang.String toString(java.util.Collection discountValueCollection)
discountValueCollection - a collection containing StandardDiscountValuespublic static java.util.Collection parseDiscountValueCollection(java.lang.String str)
throws java.lang.IllegalArgumentException
str - the string representation of the discount values.java.lang.IllegalArgumentException - if a parse error occuredpublic static DiscountValue parseDiscountValue(java.lang.String str) throws java.lang.IllegalArgumentException
str - the string representation of the discount values.java.lang.IllegalArgumentException - if the string is not validpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object object)
equals in class java.lang.Objectpublic boolean equalsIgnoreAppliedValue(DiscountValue discountValue)
Copyright © 2018 SAP SE. All Rights Reserved.