com.ibm.commerce.price.commands
Class DiscountCalculationCodeApplyCmdImpl

java.lang.Object
  |
  +--CalculationCmdImpl
        |
        +--com.ibm.commerce.price.commands.DiscountCalculationCodeApplyCmdImpl

public class DiscountCalculationCodeApplyCmdImpl
extends CalculationCmdImpl

The default implementation for the discount calculationUsage adds the specified MonetaryAmounts to the total adjustment of the orderItem. Order item adjustments and an order adjustment are also created for each calculation code applied.

NOTE : Order adjustments can not make the net price of an order item cross the zero boundary. That is, if an order item has a gross price that is on the opposite side of zero from the resulting net price (after applying the discount) then the net price is adjusted to zero and the discount is changed accordingly. Any left-over discount is distributed over the other order items that also qualify for the same discount. The distribution is done in proportion to the original discount. Any order item that has a gross price that is zero can only have a net price (price after applying discounts) that is positive.

This command calls the following TaskCommands:

This command uses the following AccessBeans:
See Also:
Serialized Form

Constructor Summary
DiscountCalculationCodeApplyCmdImpl()
          DiscountCalculationCodeApplyCmdImpl constructor.
 
Method Summary
protected  void distributeExtraDiscount(java.math.BigDecimal discountToRedistribute, java.math.BigDecimal[] weights, java.math.BigDecimal[] netPrices, java.math.BigDecimal[] discounts)
          Calculate distribute extra discount on weight
 void performExecute()
          Execute the command.
protected  java.math.BigDecimal roundCustomized(java.math.BigDecimal value, java.lang.String currency)
          Get round customized price
 void setCalculationCodeAB(CalculationCodeAccessBean calculationCodeAB)
          Set the CalculationCodeAccessBean.
 void setOrderItemABHash(java.util.Hashtable orderItemABHash)
          Set the orderItemABHash.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DiscountCalculationCodeApplyCmdImpl

public DiscountCalculationCodeApplyCmdImpl()
DiscountCalculationCodeApplyCmdImpl constructor.
Method Detail

distributeExtraDiscount

protected void distributeExtraDiscount(java.math.BigDecimal discountToRedistribute,
                                       java.math.BigDecimal[] weights,
                                       java.math.BigDecimal[] netPrices,
                                       java.math.BigDecimal[] discounts)
Calculate distribute extra discount on weight
Parameters:
discountToRedistribute -
weights -
netPrices -
discounts -

performExecute

public void performExecute()
                    throws ECException
Execute the command.
Throws:
ECException

roundCustomized

protected java.math.BigDecimal roundCustomized(java.math.BigDecimal value,
                                               java.lang.String currency)
                                        throws ECException
Get round customized price
Parameters:
value - price value before round
currency - a currency string
Returns:
BigDecimal The round customized value
Throws:
ECException

setCalculationCodeAB

public void setCalculationCodeAB(CalculationCodeAccessBean calculationCodeAB)
Set the CalculationCodeAccessBean.
Parameters:
calculationCodeAB - A CalculationCodeAccessBean.

setOrderItemABHash

public void setOrderItemABHash(java.util.Hashtable orderItemABHash)
Set the orderItemABHash.
Parameters:
orderItemABHash - An orderItemABHash.

java.util.Hashtable orderItemABHash

  • key: com.ibm.commerce.order.objects.OrderItemAccessBean orderItemAB
  • element: com.ibm.commerce.price.CategorizedMonetaryAmount monetaryAmount