com.ibm.commerce.marketing.promotion.runtime

Class ItemRunningTotal

  • java.lang.Object
    • com.ibm.commerce.marketing.promotion.runtime.ItemRunningTotal


  • public class ItemRunningTotal
    extends java.lang.Object
    This class keeps track of the running total (total plus tax including shipping fees) of associated order item or a part of an order item.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String COPYRIGHT
      IBM Copyright
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean equals(java.lang.Object obj) 
      AssociatedOrderItem getItem()
      Returns the AssociatedOrderItem for which this ItemRunningTotal is kept
      java.math.BigDecimal getShippingCharge()
      Returns shipping charge running total
      java.math.BigDecimal getShippingTax()
      Returns shipping tax running total
      java.math.BigDecimal getSubTotal()
      Returns subtotal running total
      java.math.BigDecimal getSumOfEverything()
      Returns the sum of all four monetary attributes
      java.math.BigDecimal getTax()
      Returns tax running total
      int hashCode() 
      ItemRunningTotal[] split(java.math.BigDecimal quantity)
      Splits this running total based on the quantity specified.
      ItemRunningTotal[] split(java.math.BigDecimal[] quantities)
      Splits this running total based on the quantities specified.
      static java.math.BigDecimal splitBasedOnPartialQuantity(java.math.BigDecimal value, java.math.BigDecimal fquant, java.math.BigDecimal pquant)
      Calculates value * pquant / fquant
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • COPYRIGHT

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

      • ItemRunningTotal

        public ItemRunningTotal(AssociatedOrderItem _item,
                                java.math.BigDecimal _subTotal,
                                java.math.BigDecimal _shippingCharge,
                                java.math.BigDecimal _shippingTax,
                                java.math.BigDecimal _tax)
        This constructor creates a running total object.
        Parameters:
        _item - the AssociatedOrderItem
        _subTotal - the sub total of the AssociatedOrderItem
        _shippingCharge - shipping charges on the AssociatedOrderItem
        _shippingTax - shipping tax levied on the shipping charges
        _tax - tax levied on the sub total
      • ItemRunningTotal

        public ItemRunningTotal(OrderItem oitem)
        Constructor. Constructs an ItemRunningTotal based on an OrderItem. Usually used to initialize item running totals. Assume no adjustments have been made on this order item. The sub total, shipping charge, shipping tax and tax of this ItemRunningTotal object will be the same as those of the order item.
        Parameters:
        oitem - the order item
      • ItemRunningTotal

        public ItemRunningTotal()
        Default constructor
    • Method Detail

      • splitBasedOnPartialQuantity

        public static final java.math.BigDecimal splitBasedOnPartialQuantity(java.math.BigDecimal value,
                                                                             java.math.BigDecimal fquant,
                                                                             java.math.BigDecimal pquant)
        Calculates value * pquant / fquant
        Parameters:
        value - value
        fquant - full quantity
        pquant - partial quantity
        Returns:
        value * pquant / fquant
      • equals

        public boolean equals(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
        See Also:
        java.lang.Object.equals(Object)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
        See Also:
        java.lang.Object.hashCode()
      • split

        public ItemRunningTotal[] split(java.math.BigDecimal quantity)
        Splits this running total based on the quantity specified. An array of one or two elements will be returned. One when quantity is the same as the quantity of the AssociatedOrderItem for which this ItemRunningTotal is kept. Note that no checks is performed for the situation where quantity is actually larger than that of the AssociatedOrderItem. Caller must ensure the quantity as specified by the input parameter is smaller than that of the AssociatedOrderItem.
        Parameters:
        quantity - quantity of the first element.
        Returns:
        split result
      • split

        public ItemRunningTotal[] split(java.math.BigDecimal[] quantities)
        Splits this running total based on the quantities specified. Note that no checks is performed for the situation where sum of all quantities is actually larger than that of the AssociatedOrderItem. Caller must ensure the sum of all quantities as specified by the input parameter is smaller than that of the AssociatedOrderItem.
        Parameters:
        quantities - quantities of each element after the RunningTotal are split.
        Returns:
        result of the split.
      • getItem

        public AssociatedOrderItem getItem()
        Returns the AssociatedOrderItem for which this ItemRunningTotal is kept
        Returns:
        the AssociatedOrderItem for which this ItemRunningTotal is kept
      • getShippingCharge

        public java.math.BigDecimal getShippingCharge()
        Returns shipping charge running total
        Returns:
        shipping charge running total
      • getShippingTax

        public java.math.BigDecimal getShippingTax()
        Returns shipping tax running total
        Returns:
        shipping tax running total
      • getSubTotal

        public java.math.BigDecimal getSubTotal()
        Returns subtotal running total
        Returns:
        subtotal running total
      • getTax

        public java.math.BigDecimal getTax()
        Returns tax running total
        Returns:
        tax running total
      • getSumOfEverything

        public java.math.BigDecimal getSumOfEverything()
        Returns the sum of all four monetary attributes
        Returns:
        the sum of all four monetary attributes