public class PercentOffAdjustment extends java.lang.Object implements MonetaryAdjustment
PercentOffAdjustment
offers a percentage discount, including a
cap on the maximum amount of money to be given as a discount. It provides
percentage-off implementation of a monetary adjustment. The fragment of
promotion runtime promotion XML for this type of Adjustment
is
as follows:
<p> <Adjustment impl="com.ibm.commerce.marketing.promotion.reward.PercentOffAdjustment"> <Percentage>15</Percentage> <!-- wholeOrder or AllAffectedItems or IndividualAffectedItems --> <AdjustmentType>wholeOrder</AdjustmentType> <!-- Max Amount is the cap (optional) --> <MaxAmount>20</MaxAmount> <!-- If the above Max Amount is provided, the following should be provided too --> <Currency>USD</Currency> <!-- -1 for Standard Offer Price, -2 for Contract Price, -3 for Discounted Price --> <PriceAdjustmentBase>-3</PriceAdjustmentBase> </Adjustment> </p>
Modifier and Type | Field and Description |
---|---|
static int |
CONTRACT_PRICE
The basis for price adjustment.
|
static java.lang.String |
COPYRIGHT
IBM copyright notice field.
|
static int |
DISCOUNTED_PRICE
The basis for price adjustment.
|
static int |
STANDARD_OFFER_PRICE
The basis for price adjustment.
|
MAX_SCALE_FOR_DIVIDE, PRICE, SHIPPING, SHIPPING_TAX, TAX, ZERO
ALL_AFFECTED_ITEMS, INDIVIDUAL_AFFECTED_ITEMS, WHOLE_ORDER
Constructor and Description |
---|
PercentOffAdjustment()
Constructor for PercentOffAdjustment.
|
Modifier and Type | Method and Description |
---|---|
boolean |
apply(LineItemSet targeted,
java.math.BigDecimal targetedAmount,
int targetedAmountTypes,
LineItemSet affected,
java.util.Vector affectedVector,
java.util.Vector adjustmentVector,
PromotionContext context)
This method evaluates the targeted order items to see if they fulfill the
conditions of this adjustment ( for example, if the quantity of the order
items falls into one of the ranges of the adjustment).
|
java.lang.Object |
clone()
Returns null if the
CloneNotSupportedException is thrown. |
void |
fromXML(org.w3c.dom.Node anXMLNode)
Transforms the XML node into its corresponding real Object.
|
java.lang.Integer |
getAdjustmentType()
This method gets the type of Adjustment.
|
java.lang.String |
getCurrency()
This method gets the currency.
|
java.math.BigDecimal |
getMaxAmount()
This method gets a maximum amount as the discount.
|
java.math.BigDecimal |
getPercent()
This method gets the percent to be given as discount.
|
java.math.BigDecimal |
getPerUnitAdjustment(AssociatedOrderItem one,
AssociatedOrderItem[] all,
PromotionContext context)
This method returns the monetary adjustment that needs to be applied to each
unit.
|
int |
getPriceAdjustmentBasis()
This method gets the price adjustment base.
|
int |
getTheTypeOfMonetaryValueToBeAdjusted()
Returns the target of a monetary adjustment.
|
void |
setAdjustmentType(java.lang.Integer _adjustmentType)
This method sets the type of Adjustment.
|
void |
setCurrency(java.lang.String currency)
This method sets the currency.
|
void |
setMaxAmount(java.math.BigDecimal newMaxAmount)
This method sets the maximum amount to be given as the discount.
|
void |
setPercent(java.math.BigDecimal newPercent)
This method sets the percent to be given as discount.
|
void |
setPriceAdjustmentBasis(int priceAdjustmentBasis)
This method sets the price adjustment base.
|
java.lang.String |
toXML()
Converts the object into its corresponding XML format representation.
|
public static final java.lang.String COPYRIGHT
public static final int STANDARD_OFFER_PRICE
public static final int CONTRACT_PRICE
public static final int DISCOUNTED_PRICE
public PercentOffAdjustment()
public java.math.BigDecimal getMaxAmount()
public void setMaxAmount(java.math.BigDecimal newMaxAmount)
java
- .math.BigDecimal newMaxAmount the max amount to set as the
discount.public java.math.BigDecimal getPercent()
public void setPercent(java.math.BigDecimal newPercent)
newPercent
- Sets the percent to be given as discount.public java.lang.Integer getAdjustmentType()
Adjustment
getAdjustmentType
in interface Adjustment
WHOLE_ORDER
, ALL_AFFECTED_ITEMS
or INDIVIDUAL_AFFECTED_ITEMS
.Adjustment.getAdjustmentType()
public void setAdjustmentType(java.lang.Integer _adjustmentType)
Adjustment
WHOLE_ORDER
, ALL_AFFECTED_ITEMS
or INDIVIDUAL_AFFECTED_ITEMS
.setAdjustmentType
in interface Adjustment
Adjustment.setAdjustmentType(Integer)
public java.lang.String toXML() throws XMLizationException
XMLizable
toXML
in interface XMLizable
XMLizationException
- when this process failsXMLizable.toXML()
public void fromXML(org.w3c.dom.Node anXMLNode) throws DeXMLizationException
XMLizable
fromXML
in interface XMLizable
anXMLNode
- The node that represents an XMLizable objectDeXMLizationException
- when this process failsXMLizable.fromXML(Node)
public java.lang.Object clone()
CloneNotSupportedException
is thrown.clone
in interface Adjustment
clone
in class java.lang.Object
Object.clone()
public int getTheTypeOfMonetaryValueToBeAdjusted()
MonetaryAdjustment
getTheTypeOfMonetaryValueToBeAdjusted
in interface MonetaryAdjustment
com.ibm.commerce.marketing.promotion.reward.MonetaryAdjustment#getAdjustmentTarget()
public java.math.BigDecimal getPerUnitAdjustment(AssociatedOrderItem one, AssociatedOrderItem[] all, PromotionContext context)
MonetaryAdjustment
AssociationOrderItem
). It is guaranteed that all units in
one
have been adjusted by exactly the same set of
monetary adjustments.getPerUnitAdjustment
in interface MonetaryAdjustment
one
- the order item or portion of an order item for which a per unit adjustment
amount needs to be calculated.all
- all of the AssociatedOrderItems to which this adjustment applies.context
- PromotionContextMonetaryAdjustment.getPerUnitAdjustment(AssociatedOrderItem,
AssociatedOrderItem[], PromotionContext)
public boolean apply(LineItemSet targeted, java.math.BigDecimal targetedAmount, int targetedAmountTypes, LineItemSet affected, java.util.Vector affectedVector, java.util.Vector adjustmentVector, PromotionContext context) throws PromotionRuntimeException
Adjustment
adjustmentVector
Vector object passed as a parameter. The
affectedVector
Vector object passed as a parameter is
updated by adding the affected order items. This method is called in the
invoke(LineItemSet, BigDecimal, int, Vector, Vector, PromotionContext)
method of AdjustmentFunction
.apply
in interface Adjustment
targeted
- The targeted order items. This is a set of order items (or
portions of order items) that are used to qualify for the
promotion of which this adjustment is a part.affected
- The affected order items. This is a set of order items,
identified by the promotion, to which this adjustment will be
attached.affectedVector
- A Vector which contains the affected LineItemSets.adjustmentVector
- A Vector which contains the Adjustment objects.context
- The PromotionContext
object which may be used to build
the Adjustment to add to the adjustmentVector parameter.PromotionRuntimeException
- when the computation encounters a problem.com.ibm.commerce.marketing.promotion.reward.Adjustment#apply(com.ibm.commerce.marketing.promotion.runtime.LineItemSet,
com.ibm.commerce.marketing.promotion.runtime.LineItemSet,
com.ibm.commerce.marketing.promotion.runtime.PromotionContext)
public java.lang.String getCurrency()
public void setCurrency(java.lang.String currency)
String
- currency is the currency to set.public int getPriceAdjustmentBasis()
public void setPriceAdjustmentBasis(int priceAdjustmentBasis)
int
- priceAdjustmentBasis is the value of price adjustment base (-1
for STANDARD_OFFER_PRICE, -2 for CONTRACT_PRICE, -3 for
DISCOUNTED_PRICE).