com.ibm.commerce.marketing.promotion.reward

Class FixedCostAdjustment

  • java.lang.Object
    • com.ibm.commerce.marketing.promotion.reward.FixedCostAdjustment
  • All Implemented Interfaces:
    Adjustment, MonetaryAdjustment, XMLizable, java.io.Serializable, java.lang.Cloneable


    public class FixedCostAdjustment
    extends java.lang.Object
    implements MonetaryAdjustment
    FixedCostAdjustment offers a fixed discounted price. This class extends Adjustment interface. XML Snippet for this type of Adjustment:
     

    <Adjustment impl="com.ibm.commerce.marketing.promotion.reward.FixedCostAdjustment"> <FixedCost>45</FixedCost> <Currency>CAD</Currency> <!-- AllAffectedItems or IndividualAffectedItems --> <AdjustmentType>IndividualAffectedItems</AdjustmentType> <!-- 0 or 1 --> <AdjustmentComparison>0</AdjustmentComparison> </Adjustment>

    If the AdjustmentComparison flag exist in the XML and the value is 1, then it compares the fixed price with the current price and returns the lowest one, otherwise it returns the fixed price.
    See Also:
    Serialized Form
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
    • Constructor Detail

      • FixedCostAdjustment

        public FixedCostAdjustment()
        Constructor for FixedCostAdjustment.
    • Method Detail

      • getFixedCost

        public java.math.BigDecimal getFixedCost()
        This method gets the Fixed Cost of the affected line items.
        Returns:
        java.math.BigDecimal Fixed Cost of the affected line items
      • getCurrency

        public java.lang.String getCurrency()
        This method gets the Currency.
        Returns:
        java.lang.String
      • setFixedCost

        public void setFixedCost(java.math.BigDecimal newFixedCost)
        This method sets the Fixed Cost of the affected line items.
        Parameters:
        newFixedCost - The fixed cost to set.
      • setCurrency

        public void setCurrency(java.lang.String newCurrency)
        This method sets the Currency.
        Parameters:
        newCurrency - The currency to set.
      • getAdjustmentType

        public java.lang.Integer getAdjustmentType()
        Description copied from interface: Adjustment
        This method gets the type of Adjustment. An adjustment can be of the following types: for the whole Order, for All the Affected Items, or for Individual Affected Items.
        Specified by:
        getAdjustmentType in interface Adjustment
        Returns:
        one of the defined constants of WHOLE_ORDER, ALL_AFFECTED_ITEMS or INDIVIDUAL_AFFECTED_ITEMS.
        See Also:
        Adjustment.getAdjustmentType()
      • setAdjustmentType

        public void setAdjustmentType(java.lang.Integer aAdjustmentType)
        Description copied from interface: Adjustment
        This method sets the type of Adjustment. An adjustment can be of the following types for whole Order, for All Affected Items, and for Individual Affected Items. Set adjustmentType to one of the defined constants of WHOLE_ORDER, ALL_AFFECTED_ITEMS or INDIVIDUAL_AFFECTED_ITEMS.
        Specified by:
        setAdjustmentType in interface Adjustment
        See Also:
        Adjustment.setAdjustmentType(Integer)
      • clone

        public java.lang.Object clone()
        Returns null if the CloneNotSupportedException is thrown.
        Specified by:
        clone in interface Adjustment
        Overrides:
        clone in class java.lang.Object
        See Also:
        Object.clone()
      • getTheTypeOfMonetaryValueToBeAdjusted

        public int getTheTypeOfMonetaryValueToBeAdjusted()
        Returns the value of PRICE=1
        Specified by:
        getTheTypeOfMonetaryValueToBeAdjusted in interface MonetaryAdjustment
        Returns:
        target of a monetary adjustment
        See Also:
        com.ibm.commerce.marketing.promotion.reward.MonetaryAdjustment#getAdjustmentTarget()
      • getPerUnitAdjustment

        public java.math.BigDecimal getPerUnitAdjustment(AssociatedOrderItem one,
                                                         AssociatedOrderItem[] all,
                                                         PromotionContext context)
        Description copied from interface: MonetaryAdjustment
        This method returns the monetary adjustment that needs to be applied to each unit. One unit could be an order item or a portion of an order item (as identified by the AssociationOrderItem). It is guaranteed that all units in one have been adjusted by exactly the same set of monetary adjustments.
        Specified by:
        getPerUnitAdjustment in interface MonetaryAdjustment
        Parameters:
        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 - PromotionContext
        Returns:
        a perUnit value, value could be positive which means a discount, negative which means a markup or zero which means no change is needed.
        See Also:
        MonetaryAdjustment.getPerUnitAdjustment(AssociatedOrderItem, AssociatedOrderItem[], PromotionContext)
      • apply

        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
        Description copied from interface: Adjustment
        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). Depending upon if and what conditions are fulfilled, an Adjustment object is added to the 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.
        Specified by:
        apply in interface Adjustment
        Parameters:
        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.
        Returns:
        A boolean value indicating whether the conditions of the adjustment were fulfilled successfully or not. A true value indicates that the conditions of the adjustment were fulfilled successully, otherwise a false value is returned.
        Throws:
        PromotionRuntimeException - when the computation encounters a problem.
        See Also:
        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)
      • getPriceAdjustmentBase

        public int getPriceAdjustmentBase()
        Returns the price adjustment base. The possible value is: standard offer price, contract price or discounted price. This value is not used in this implementation.
        Returns:
        the price adjustment base.
      • setPriceAdjustmentBase

        public void setPriceAdjustmentBase(int i)
        Sets the price adjustment base. The possible value is: standard offer price, contract price or discounted price. This value is not used in this implementation.
        Parameters:
        i - the new price adjustment base
      • setAdjustmentComparison

        public void setAdjustmentComparison(java.lang.Integer isCompared)
        Sets the adjustment comparison flag. If the flag is true(value of 1) then the contract price will be compared with the fixed price.
        Parameters:
        isCompared - is the comparison flag
      • getAdjustmentComparison

        public java.lang.Integer getAdjustmentComparison()
        Returns the adjustment comparison flag. The possible value is 1(true) or 0(false).
        Returns:
        the adjustment comparison flag.