com.ibm.commerce.order.calculation

Class CalculationHelper

  • java.lang.Object
    • com.ibm.commerce.order.calculation.CalculationHelper
  • All Implemented Interfaces:
    CalculationConstants


    public class CalculationHelper
    extends java.lang.Object
    implements CalculationConstants
    This class defines various helper methods used by the Calculation Framework.
    • Field Detail

      • COPYRIGHT

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

      • getInMemoryAdjustmentFlag

        public static boolean getInMemoryAdjustmentFlag()
      • applyCalculationUsages

        public void applyCalculationUsages(OrderItemAccessBean[] aabOrderItems,
                                           java.lang.String astrCurrency,
                                           java.util.HashMap ahshCustomProperties,
                                           CommandContext commandContext)
                                    throws ECException
        This method is called by OrderPrepare/PrepareOrder to apply all calculation usages enabled in the store.
        Parameters:
        aabOrderItems - the OrderItems.
        astrCurrency - the (Order) currency.
        ahshCustomProperties - the custom properties. Key: property name (String). Value: property value (Object).
        commandContext - the command context.
        Throws:
        ECException
      • compare

        public int compare(java.lang.Comparable[] c1,
                           java.lang.Comparable[] c2)
        Compares two arrays of Comparables. The algorithm is as follows:
        1. if both arrays are null, return 0
        2. if only
          c1
          is null, return -1
        3. if only
          c2
          is null, return 1
        4. compare each pair of elements using the method compare(Comparable, Comparable). And return the first non-zero result
        5. return c1.length - c2.length
        Parameters:
        c1 - the first array.
        c2 - the second array.
        Returns:
        the comparison result.
      • compare

        public int compare(java.lang.Comparable c1,
                           java.lang.Comparable c2)
        Compares two Comparables. Null is considered to be the smallest.
        Parameters:
        c1 - the first Comparable.
        c2 - the second Comparable.
        Returns:
        the comparison result.
      • containsAny

        public boolean containsAny(java.lang.Object[] a1,
                                   java.lang.Object[] a2)
        Returns whether the first array contains any element in the second array.
        Parameters:
        a1 - the first array.
        a2 - the second array.
        Returns:
        true if the first array does contain an element in the second array.
      • convert

        public static java.math.BigDecimal convert(java.math.BigDecimal value,
                                                   StoreAccessBean storeAB,
                                                   java.lang.String fromCurrency,
                                                   java.lang.String toCurrency)
                                            throws ECException
        Throws:
        ECException
      • convertMonetaryValue

        public java.math.BigDecimal convertMonetaryValue(java.math.BigDecimal adValue1,
                                                         java.lang.String astrCurrency1,
                                                         java.lang.String astrCurrency2,
                                                         CommandContext commandContext)
                                                  throws ECException
        This method converts the monetary value from one currency to another using the forward conversion rate.
        Parameters:
        adValue1 - the original monetary value.
        astrCurrency1 - the original currency.
        astrCurrency2 - the target currency.
        commandContext - the command context.
        Returns:
        the monetary value converted to the target currency.
        Throws:
        ECException
      • convertMonetaryValueR

        public java.math.BigDecimal convertMonetaryValueR(java.math.BigDecimal adValue1,
                                                          java.lang.String astrCurrency1,
                                                          java.lang.String astrCurrency2,
                                                          CommandContext commandContext)
                                                   throws ECException
        This method converts the monetary value from one currency to another using the backward conversion rate.
        Parameters:
        adValue1 - the original monetary value.
        astrCurrency1 - the original currency.
        astrCurrency2 - the target currency.
        commandContext - the command context.
        Returns:
        the monetary value converted to the target currency.
        Throws:
        ECException
      • convertQuantityValue

        public java.math.BigDecimal convertQuantityValue(java.math.BigDecimal adValue1,
                                                         java.lang.String astrUnit1,
                                                         java.lang.String astrUnit2)
                                                  throws ECException
        This method converts the quantity value from one unit to another.
        Parameters:
        adValue1 - the original quantity value.
        astrUnit1 - the original unit.
        astrUnit2 - the target unit.
        Returns:
        the quantity value converted to the target unit.
        Throws:
        ECException
      • correctZeroBoundaryCrossings

        public void correctZeroBoundaryCrossings(Item[] aItems,
                                                 java.math.BigDecimal[] adAdjustments,
                                                 java.lang.String astrCurrency,
                                                 CommandContext commandContext)
                                          throws ECException
        This method is called by DiscountCalculationCodeApply to correct discounts that cross the zero boundary.
        Parameters:
        aItems - the Items.
        adAdjustments - the adjustments to be corrected.
        astrCurrency - the currency which the adjustments are in.
        commandContext - the commandContext.
        Throws:
        ECException
      • correctZeroBoundaryCrossings

        public void correctZeroBoundaryCrossings(Item[] aItems,
                                                 java.math.BigDecimal[] adAdjustments,
                                                 java.lang.String astrCurrency,
                                                 CommandContext commandContext,
                                                 java.util.List calUsgList)
                                          throws ECException
        This method corrects discounts that cross the zero boundary across multiple calculation usages.
        Parameters:
        aItems - the Items.
        adAdjustments - the adjustments to be corrected.
        astrCurrency - the currency which the adjustments are in.
        commandContext - the commandContext.
        calUsgList - the list of calculation usages.
        Throws:
        ECException
      • destructiveAdd

        public java.math.BigDecimal[] destructiveAdd(java.math.BigDecimal[] adValues1,
                                                     java.math.BigDecimal[] adValues2)
        Returns the sum of two BigDecimal arrays. The source arrays will be modified and reused.
        Parameters:
        adValues1 - the first BigDecimal array.
        adValues2 - the second BigDecimal array.
        Returns:
        the sum of the two BigDecimal arrays.
      • divide

        public java.math.BigDecimal divide(java.math.BigDecimal ad1,
                                           java.math.BigDecimal ad2)
        Returns
        ad1.divide(ad2, 20, BigDecimal.ROUND_HALF_UP)
        .
        Parameters:
        ad1 - the first BigDecimal.
        ad2 - the second BigDecimal.
        Returns:
        ad1.divide(ad2, 20, BigDecimal.ROUND_HALF_UP)
        .
      • finalizeCalculationUsages

        public void finalizeCalculationUsages(OrderAccessBean aabOrder,
                                              OrderItemAccessBean[] aabOrderItems,
                                              java.lang.String astrCurrency,
                                              java.util.HashMap ahshCustomProperties,
                                              CommandContext commandContext)
                                       throws ECException
        This method is called by OrderProcess/ProcessOrder to apply all calculation usages enabled in the store.
        Parameters:
        aabOrder - the Order.
        aabOrderItems - the OrderItems.
        astrCurrency - the (Order) currency.
        ahshCustomProperties - the custom properties. Key: property name (String). Value: property value (Object).
        commandContext - the command context.
        Throws:
        ECException
      • findMax

        public int findMax(java.math.BigDecimal[] e)
        Returns the index of the largest value in a BigDecimal array.
        Parameters:
        e - the BigDecimal array.
        Returns:
        the index.
      • findMin

        public int findMin(java.math.BigDecimal[] e)
        Returns the index of the smallest value in a BigDecimal array.
        Parameters:
        e - the BigDecimal array.
        Returns:
        the index.
      • getCodeId

        public java.lang.Integer getCodeId(java.lang.Integer anRuleId)
                                    throws ECException
        Returns the CalculationCode ID of the specified CalculationRule.
        Parameters:
        anRuleId - the CalculationRule ID.
        Returns:
        the CalculationCode ID.
        Throws:
        ECException
      • getInstance

        public static CalculationHelper getInstance()
        Returns an instance of this class.
        Returns:
        an instance of this class.
      • getProductAndItemIds

        public java.lang.Long[] getProductAndItemIds(java.lang.Long anCatalogEntryId)
                                              throws ECException
        Returns the parent product of an item and the item itself.
        Parameters:
        anCatalogEntryId - the CatalogEntry ID of the item.
        Returns:
        the CatalogEntry IDs of the item and its parent product.
        Throws:
        ECException
      • getProductOrItemIds

        public java.lang.Long[] getProductOrItemIds(java.lang.Long anCatalogEntryId)
                                             throws ECException
        Returns the parent product of an item. If it does not have one, returns the item itself.
        Parameters:
        anCatalogEntryId - the CatalogEntry ID of the item.
        Returns:
        the CatalogEntry IDs of the item or its parent product.
        Throws:
        ECException
      • getQuantity

        public java.math.BigDecimal getQuantity(java.lang.Long anCatalogEntryId,
                                                java.math.BigDecimal adNormalizedQuantity,
                                                java.lang.String astrUnit)
                                         throws ECException
        Returns the quantity value represented by the specified normalized quantity.
        Parameters:
        anCatalogEntryId - the CatalogEntry ID.
        adNormalizedQuantity - the normalized quantity.
        astrUnit - the target unit.
        Returns:
        the quantity value converted to the target unit.
        Throws:
        ECException
      • getRoundingMultiple

        public java.math.BigDecimal getRoundingMultiple(java.lang.String astrCurrency,
                                                        CommandContext commandContext)
                                                 throws ECException
        Returns the rounding multiple of the specified currency.
        Parameters:
        astrCurrency - the currency.
        commandContext - the command context.
        Returns:
        the rounding multiple.
        Throws:
        ECException
      • getStoreGroupId

        public java.lang.Integer getStoreGroupId(java.lang.Integer anStoreId)
                                          throws ECException
        Returns the StoreGroup ID of the specified Store.
        Parameters:
        anStoreId - the Store ID.
        Returns:
        the StoreGroup ID.
        Throws:
        ECException
      • getStorePath

        public java.lang.Integer[] getStorePath(java.lang.Integer anStoreId,
                                                java.lang.String anStoreRelationShipTypeId)
                                         throws ECException
        Returns the Store ID array in the
        storepath
        of the specified Store.
        Parameters:
        anStoreId - the Store ID.
        anStoreRelationShipTypeId - the store relationship type ID.
        Returns:
        the Store Path ID array.
        Throws:
        ECException
      • getTaxableAdjustmentTotal

        public java.math.BigDecimal getTaxableAdjustmentTotal(java.lang.Long anOrderItemId,
                                                              java.lang.Integer anTaxCategoryId)
                                                       throws ECException
        Returns the taxable adjustment total of the specified OrderItem and TaxCategory.
        Parameters:
        anOrderItemId - the OrderItem ID.
        anTaxCategoryId - the TaxCategory ID.
        Returns:
        the taxable adjustment total.
        Throws:
        ECException
      • getOrderItemAdjustmentTotal

        public java.math.BigDecimal getOrderItemAdjustmentTotal(java.lang.Long anOrderItemId,
                                                                java.lang.Integer anCalculationUsageId)
                                                         throws ECException
        Returns the adjustment amount for specific
        orderitem
        and
        calculationusage
        .
        Parameters:
        anOrderItemId -
        anCalculationUsageId -
        Returns:
        BigDecimal
        Throws:
        ECException
      • getOrderAdjustmentTotal

        public java.math.BigDecimal getOrderAdjustmentTotal(java.lang.Long anOrderId,
                                                            java.lang.Integer anCalculationUsageId)
                                                     throws ECException
        Returns the adjustment amount for specific order and
        calculationusage
        .
        Parameters:
        anOrderId -
        anCalculationUsageId -
        Returns:
        adjustment amount
        Throws:
        ECException
      • getTaxCategoryIds

        public java.lang.Integer[] getTaxCategoryIds(StoreAccessBean aabStore,
                                                     java.lang.Integer anUsageId)
                                              throws ECException
        Returns the tax categories of a particular calculation usage:
        Calculation Usage Tax Categories
        sales tax all sales tax categories
        shipping tax all shipping tax categories
        other null
        Parameters:
        aabStore - the Store.
        anUsageId - the CalculationUsage ID.
        Returns:
        the TaxCategory IDs.
        Throws:
        ECException
      • getWeight

        public java.math.BigDecimal getWeight(java.lang.Long anCatalogEntryId,
                                              java.math.BigDecimal adNormalizedQuantity,
                                              java.lang.String astrUnit)
                                       throws ECException
        Returns the weight value represented by the specified normalized quantity.
        Parameters:
        anCatalogEntryId - the CatalogEntry ID.
        adNormalizedQuantity - the normalized quantity.
        astrUnit - the target unit.
        Returns:
        the weight value converted to the target unit.
        Throws:
        ECException
      • initializeCalculationUsages

        public void initializeCalculationUsages(OrderAccessBean aabOrder,
                                                OrderItemAccessBean[] aabOrderItems,
                                                java.lang.String astrCurrency,
                                                java.util.HashMap ahshCustomProperties,
                                                CommandContext commandContext)
                                         throws ECException
        This method is called by OrderPrepare/PrepareOrder to initialize all calculation usages enabled by the store.
        Parameters:
        aabOrder - the Order.
        aabOrderItems - the OrderItems.
        astrCurrency - the (Order) currency.
        ahshCustomProperties - the custom properties. Key: property name (String). Value: property value (Object).
        commandContext - the command context.
        Throws:
        ECException
      • isCurrentUserInMemberGroup

        public boolean isCurrentUserInMemberGroup(java.lang.Long anMemberGroupId,
                                                  CommandContext commandContext)
                                           throws ECException
        This method checks whether the current user is in the member group.
        Parameters:
        anMemberGroupId - the member group id
        commandContext - the command context
        Returns:
        true if current user is in the member group, else false.
        Throws:
        ECException
      • isEffective

        public boolean isEffective(CalculationCodeAccessBean aabCode,
                                   java.sql.Timestamp aTimestamp)
                            throws ECException
        Returns whether a CalculationCode is effective at the specified time.
        Parameters:
        aabCode - the CalculationCode.
        aTimestamp - the time.
        Returns:
        true if the CalculationCode is effective.
        Throws:
        ECException
      • isEffective

        public boolean isEffective(CalculationRuleAccessBean aabRule,
                                   java.sql.Timestamp aTimestamp)
                            throws ECException
        Returns whether a CalculationRule is effective at the specified time.
        Parameters:
        aabRule - the CalculationRule.
        aTimestamp - the time.
        Returns:
        true if the CalculationRule is effective.
        Throws:
        ECException
      • isPublished

        public boolean isPublished(CalculationCodeAccessBean aabCode)
                            throws ECException
        Returns whether a CalculationCode is published.
        Parameters:
        aabCode - the CalculationCode.
        Returns:
        true if the CalculationCode is published.
        Throws:
        ECException
      • remapValues

        public java.math.BigDecimal[] remapValues(Item[] aItems1,
                                                  java.math.BigDecimal[] adValues1,
                                                  Item[] aItems2)
        Returns a BigDecimal array adValues2 such that, if aItems1[i] == aItems2[j], then adValues1[i] == adValues2[j].
        Parameters:
        aItems1 - the first Item array.
        adValues1 - the first BigDecimal array.
        aItems2 - the second Item array.
        Returns:
        the remapped BigDecimal array.
      • round

        public void round(java.math.BigDecimal[] a,
                          java.lang.String astrCurrency,
                          CommandContext commandContext)
                   throws ECException
        Rounds a BigDecimal array using the "fudging" algorithm.
        Parameters:
        a - the BigDecimal array.
        astrCurrency - the currency.
        commandContext - the command context.
        Throws:
        ECException
      • round

        public java.math.BigDecimal round(java.math.BigDecimal adValue,
                                          java.lang.String astrCurrency,
                                          CommandContext commandContext)
                                   throws ECException
        Rounds a monetary value in the specified currency.
        Parameters:
        adValue - the monetary value.
        astrCurrency - the currency.
        commandContext - the command context.
        Returns:
        the rounded monetary value.
        Throws:
        ECException
      • spread

        public java.math.BigDecimal[] spread(java.math.BigDecimal adValue,
                                             java.math.BigDecimal[] adWeights)
                                      throws ECException
        Spreads a value using the specified mathematical weights.
        Parameters:
        adValue - the value to be spread.
        adWeights - the mathematical weights.
        Returns:
        the spread values. A spread value will be null if the corresponding mathematical weight is null.
        Throws:
        ECException
      • sum

        public java.math.BigDecimal sum(java.math.BigDecimal[] adValues)
        Sums the elements of a BigDecimal array.
        Parameters:
        adValues - the array.
        Returns:
        the sum.
      • summarizeCalculationUsages

        public void summarizeCalculationUsages(OrderAccessBean aabOrder,
                                               SubOrderAccessBean[] aabSubOrders,
                                               OrderItemAccessBean[] aabOrderItems,
                                               java.lang.String astrCurrency,
                                               java.util.HashMap ahshCustomProperties,
                                               CommandContext commandContext)
                                        throws ECException
        This method is called by OrderPrepare/PrepareOrder to summarize all calculation usages enabled by the store.
        Parameters:
        aabOrder - the Order.
        aabSubOrders - the SubOrders.
        aabOrderItems - the OrderItems.
        astrCurrency - the (Order) currency.
        ahshCustomProperties - the custom properties. Key: property name (String). Value: property value (Object).
        commandContext - the command context.
        Throws:
        ECException
      • toString

        public java.lang.String toString(java.lang.Object[] a)
        Returns the string representation of the specified array.
        Parameters:
        a - the array.
        Returns:
        the string representation.
      • toArray

        public static java.lang.Object[] toArray(java.util.Enumeration anEnum,
                                                 java.lang.Class aClass)
      • toArray

        public static java.lang.Object[] toArray(java.util.Vector vector,
                                                 java.lang.Class aClass)
      • toVector

        public static java.util.Vector toVector(java.util.Enumeration anEnum)
      • updateSubOrders

        public SubOrderAccessBean[] updateSubOrders(java.lang.Long anOrderId,
                                                    OrderItemAccessBean[] aabOrderItems,
                                                    CommandContext aCommandContext)
                                             throws ECException
        This method is called by OrderPrepare/PrepareOrder to update the suborder totals of an order.
        Parameters:
        anOrderId - the Order ID.
        aabOrderItems - the OrderItems.
        aCommandContext - the command context.
        Returns:
        the SubOrders being updated.
        Throws:
        ECException
      • updateSubOrders

        public SubOrderAccessBean[] updateSubOrders(java.lang.Long anOrderId,
                                                    OrderItemAccessBean[] aabOrderItems)
                                             throws ECException
        Deprecated. 
        This method is called by OrderPrepare/PrepareOrder to update the suborder totals of an order.
        Parameters:
        anOrderId - the Order ID.
        aabOrderItems - the OrderItems.
        Returns:
        the SubOrders being updated.
        Throws:
        ECException
      • applyCalculationUsages

        public void applyCalculationUsages(OrderItemAccessBean[] aabOrderItems,
                                           java.lang.String astrCurrency,
                                           java.util.HashMap ahshCustomProperties,
                                           java.util.Set aEnabledUsageIds,
                                           java.util.Set aDisabledUsageIds,
                                           CommandContext commandContext)
                                    throws ECException
        This method is called by OrderPrepare/PrepareOrder to apply all calculation usages enabled in the store.
        Parameters:
        aabOrderItems - the OrderItems.
        astrCurrency - the (Order) currency.
        ahshCustomProperties - the custom properties. Key: property name (String). Value: property value (Object).
        aEnabledUsageIds - if not null, CalculationUsages not in this set will be disabled. Value: CalculationUsage ID (Integer).
        aDisabledUsageIds - if not null, CalculationUsages in this set will be disabled. Value: CalculationUsage ID (Integer).
        commandContext - the command context.
        Throws:
        ECException
      • finalizeCalculationUsages

        public void finalizeCalculationUsages(OrderAccessBean aabOrder,
                                              OrderItemAccessBean[] aabOrderItems,
                                              java.lang.String astrCurrency,
                                              java.util.HashMap ahshCustomProperties,
                                              java.util.Set aEnabledUsageIds,
                                              java.util.Set aDisabledUsageIds,
                                              CommandContext commandContext)
                                       throws ECException
        This method is called by OrderProcess/ProcessOrder to apply all calculation usages enabled by the store.
        Parameters:
        aabOrder - the Order.
        aabOrderItems - the OrderItems.
        astrCurrency - the (Order) currency.
        ahshCustomProperties - the custom properties. Key: property name (String). Value: property value (Object).
        aEnabledUsageIds - if not null, CalculationUsages not in this set will be disabled. Value: CalculationUsage ID (Integer).
        aDisabledUsageIds - if not null, CalculationUsages in this set will be disabled. Value: CalculationUsage ID (Integer).
        commandContext - the command context.
        Throws:
        ECException
      • initializeCalculationUsages

        public void initializeCalculationUsages(OrderAccessBean aabOrder,
                                                OrderItemAccessBean[] aabOrderItems,
                                                java.lang.String astrCurrency,
                                                java.util.HashMap ahshCustomProperties,
                                                java.util.Set aEnabledUsageIds,
                                                java.util.Set aDisabledUsageIds,
                                                CommandContext commandContext)
                                         throws ECException
        This method is called by OrderPrepare/PrepareOrder to initialize all calculation usages enabled by the store.
        Parameters:
        aabOrder - the Order.
        aabOrderItems - the OrderItems.
        astrCurrency - the (Order) currency.
        ahshCustomProperties - the custom properties. Key: property name (String). Value: property value (Object).
        aEnabledUsageIds - if not null, CalculationUsages not in this set will be disabled. Value: CalculationUsage ID (Integer).
        aDisabledUsageIds - if not null, CalculationUsages in this set will be disabled. Value: CalculationUsage ID (Integer).
        commandContext - the command context.
        Throws:
        ECException
      • summarizeCalculationUsages

        public void summarizeCalculationUsages(OrderAccessBean aabOrder,
                                               SubOrderAccessBean[] aabSubOrders,
                                               OrderItemAccessBean[] aabOrderItems,
                                               java.lang.String astrCurrency,
                                               java.util.HashMap ahshCustomProperties,
                                               java.util.Set aEnabledUsageIds,
                                               java.util.Set aDisabledUsageIds,
                                               CommandContext commandContext)
                                        throws ECException
        This method is called by OrderPrepare/PrepareOrder to summarize all calculation usages enabled by the store.
        Parameters:
        aabOrder - the Order.
        aabSubOrders - the SubOrders.
        aabOrderItems - the OrderItems.
        astrCurrency - the (Order) currency.
        ahshCustomProperties - the custom properties. Key: property name (String). Value: property value (Object).
        aEnabledUsageIds - if not null, CalculationUsages not in this set will be disabled. Value: CalculationUsage ID (Integer).
        aDisabledUsageIds - if not null, CalculationUsages in this set will be disabled. Value: CalculationUsage ID (Integer).
        commandContext - the command context.
        Throws:
        ECException
      • getRoundingMultiple

        public java.math.BigDecimal getRoundingMultiple(java.lang.String astrCurrency,
                                                        java.lang.String astrNumberUsage,
                                                        CommandContext commandContext)
                                                 throws ECException
        Returns the rounding multiple of the specified currency.
        Parameters:
        astrCurrency - the currency.
        astrNumberUsage - the number usage.
        commandContext - the command context.
        Returns:
        the rounding multiple.
        Throws:
        ECException
      • getRoundMethod

        public int getRoundMethod(java.lang.String astrCurrency,
                                  java.lang.String astrNumberUsage,
                                  CommandContext commandContext)
                           throws ECException
        Returns the rounding method of the specified currency.
        Parameters:
        astrCurrency - the currency.
        astrNumberUsage - the number usage.
        commandContext - the command context.
        Returns:
        The rounding method.
        Throws:
        ECException
      • round

        public void round(java.math.BigDecimal[] a,
                          java.lang.String astrCurrency,
                          java.lang.String astrNumberUsage,
                          CommandContext commandContext)
                   throws ECException
        Rounds a BigDecimal array using the "fudging" algorithm.
        Parameters:
        a - the BigDecimal array.
        astrNumberUsage - the number usage.
        astrCurrency - the currency.
        commandContext - the command context.
        Throws:
        ECException
      • round

        public java.math.BigDecimal round(java.math.BigDecimal adValue,
                                          java.lang.String astrCurrency,
                                          java.lang.String astrNumberUsage,
                                          CommandContext commandContext)
                                   throws ECException
        Rounds a monetary value in the specified currency.
        Parameters:
        adValue - the monetary value.
        astrCurrency - the currency.
        astrNumberUsage - the number usage.
        commandContext - the command context.
        Returns:
        the rounded monetary value.
        Throws:
        ECException
      • getTaxableAdjustmentTotals

        public java.util.Map getTaxableAdjustmentTotals(Item[] aItems,
                                                        java.lang.Integer anTaxCategoryId,
                                                        java.util.HashMap ahshCustomProperties)
                                                 throws ECException
        Returns the taxable adjustment total of the specified Items and TaxCategory.
        Parameters:
        aItems - the Items.
        anTaxCategoryId - the TaxCategory ID.
        ahshCustomProperties - the custom properties. Key: property name (String). Value: property value (Object).
        Returns:
        the taxable adjustment totals. Key: Item (Item). Value: taxable adjustment total (BigDecimal).
        Throws:
        ECException
      • getTaxableAdjustmentTotals

        public java.util.Map getTaxableAdjustmentTotals(Item[] aItems,
                                                        java.lang.Integer anTaxCategoryId,
                                                        java.util.HashMap ahshCustomProperties,
                                                        java.util.Set asetTaxExemptedAdjustmentUsageIds)
                                                 throws ECException
        Returns the taxable adjustment total of the specified Items and TaxCategory.
        Parameters:
        aItems - the Items.
        anTaxCategoryId - the TaxCategory ID.
        ahshCustomProperties - the custom properties. Key: property name (String). Value: property value (Object).
        asetTaxExemptedAdjustmentUsageIds - the adjustment usage IDs that are tax exempted. Value: adjustment usage ID (Integer).
        Returns:
        the taxable adjustment totals. Key: Item (Item). Value: taxable adjustment total (BigDecimal).
        Throws:
        ECException
      • getTSRShippingAdjustmentRoleLimits

        public java.util.Hashtable getTSRShippingAdjustmentRoleLimits(java.lang.Long aTSRId,
                                                                      java.lang.Integer aStoreId)
                                                               throws ECException
        This method returns a hash table of TSR shipping adjustment role limits.
        Parameters:
        aTSRId - the TSR id
        aStoreId - the store id
        Returns:
        the hash table
        Throws:
        ECException
      • getEffectiveRules

        public static final CalculationRuleAccessBean[] getEffectiveRules(java.lang.Integer anCalculationCodeId,
                                                                          java.util.Map amapCustomProperties,
                                                                          CommandContext aCommandContext)
                                                                   throws ECException
        Gets the currently effective CalculationRule access beans for a calculation code. If they are already in amapCustomProperties, they are retrieved from there. Otherwise, they are retrieved from the CalculationRegistry, and placed in amapCustomProperties.
        Parameters:
        anCalculationCodeId - the calculation code id.
        amapCustomProperties - the map of custom properties.
        aCommandContext - the command context.
        Returns:
        the effective CalculationRule access beans.
        Throws:
        ECException
      • getTaxJurisdictionsByAddress

        public java.lang.Integer[] getTaxJurisdictionsByAddress(java.lang.Long anAddressId,
                                                                CommandContext commandContext,
                                                                java.util.Map amapCustomProperties)
                                                         throws ECException
        Get the tax jurisdictions by shipping Address
        Parameters:
        anAddress - the address id.
        aCommandContext - the command context.
        amapCustomProperties - the map of custom properties.
        Returns:
        the array of shipping jurisdiction Id.
        Throws:
        ECException
      • getShippingJurisdictionsByAddress

        public java.lang.Integer[] getShippingJurisdictionsByAddress(java.lang.Long anAddressId,
                                                                     CommandContext commandContext,
                                                                     java.util.Map amapCustomProperties)
                                                              throws ECException
        Get the shipping jurisdictions by shipping Address
        Parameters:
        anAddress - the ship address id.
        aCommandContext - the command context.
        amapCustomProperties - the map of custom properties.
        Returns:
        the array of shipping jurisdiction Id.
        Throws:
        ECException
      • getEffectiveRulesForShipping

        public CalculationRuleAccessBean[] getEffectiveRulesForShipping(java.lang.Integer aShipCalculationCodeId,
                                                                        java.lang.Integer aFulfillmentCenterId,
                                                                        java.lang.Long addressId,
                                                                        java.lang.Integer aShippingModeId,
                                                                        java.util.Map amapCustomProperties,
                                                                        CommandContext aCommandContext)
                                                                 throws ECException
        Get the effective shipping calculation rules for specified shipping calculation code Id, fulfillment center Id, ship to address Id.
        Parameters:
        aShipCalculationCodeId - shipping calculation code Id.
        aFulfillmentCenterId - fulfillment center Id.
        addressId - shipping address Id.
        aShippingModeId - shipping mode Id.
        amapCustomProperties - the map of custom properties.
        aCommandContext - the command context.
        Returns:
        the effective CalculationRule access beans.
        Throws:
        ECException
      • getEffectiveRulesForTax

        public CalculationRuleAccessBean[] getEffectiveRulesForTax(java.lang.Integer aTaxCalculationCodeId,
                                                                   java.lang.Integer aFulfillmentCenterId,
                                                                   java.lang.Long aAddress,
                                                                   java.lang.Integer[] aTaxCategoryIds,
                                                                   java.util.Map amapCustomProperties,
                                                                   CommandContext aCommandContext)
                                                            throws ECException
        Get the effective tax rules for specified tax calculation code Id, fulfillment center Id, address Id, and tax categories.
        Parameters:
        aTaxCalculationCodeId - tax calculation code Id.
        aFulfillmentCenterId - fulfillment center Id.
        aAddress - address Id.
        aTaxCategoryIds - tax category Ids.
        amapCustomProperties - the map of custom properties.
        aCommandContext - the command context.
        Returns:
        the effective CalculationRule access beans.
        Throws:
        ECException
      • getEffectiveRulesForTax

        public CalculationRuleAccessBean[] getEffectiveRulesForTax(java.lang.Integer aTaxCalculationCodeId,
                                                                   java.lang.Integer aFulfillmentCenterId,
                                                                   java.lang.Long aAddressId,
                                                                   java.util.Map amapCustomProperties,
                                                                   CommandContext aCommandContext)
                                                            throws ECException
        Get the effective tax rules for specified tax calculation code Id, fulfillment center Id, add address Id.
        Parameters:
        aTaxCalculationCodeId - tax calculation code Id.
        aFulfillmentCenterId - fulfillment center Id.
        aAddress - address Id.
        amapCustomProperties - the map of custom properties.
        aCommandContext - the command context.
        Returns:
        the effective CalculationRule access beans.
        Throws:
        ECException
      • getEffectiveRuleIds

        public static final java.util.Set getEffectiveRuleIds(java.lang.Integer anCalculationCodeId,
                                                              java.util.Map amapCustomProperties,
                                                              CommandContext aCommandContext)
                                                       throws ECException
        Gets the calculation rule ids of the currently effective CalculationRule access beans for a calculation code. If they are already in amapCustomProperties, they are retrieved from there. Otherwise, they are retrieved from the CalculationRegistry, and placed in amapCustomProperties.
        Parameters:
        anCalculationCodeId - the calculation code id.
        amapCustomProperties - the map of custom properties.
        aCommandContext - the command context.
        Returns:
        the Integer ids of the effective CalculationRule access beans.
        Throws:
        ECException
      • createCommand

        public static final CalculationCmd createCommand(CalculationMethodAccessBean aabMethod,
                                                         CommandContext aCommandContext,
                                                         java.util.HashMap amapCustomProperties,
                                                         java.sql.Timestamp aTimestamp,
                                                         java.lang.String astrCurrency,
                                                         java.lang.Integer anUsageId)
                                                  throws ECException
        Returns a calculation command corresponding to a calculation method. Returns a recycled command if it can be found in the custom properties. Otherwise, creates a new one. The following properties are set by this method:
        • commandContext
        • custom properties
        • timestamp
        • currency
        • usageId
        Parameters:
        aabMethod - the calculation method.
        aCommandContext - the command context.
        amapCustomProperties - the custom properties.
        aTimestamp - the timestamp.
        astrCurrency - the currency.
        anUsageId - the usageId.
        Returns:
        the command.
        Throws:
        ECException
      • recycleCommand

        public static final void recycleCommand(CalculationCmd aCalculationCmd,
                                                CalculationMethodAccessBean aabMethod,
                                                CommandContext aCommandContext,
                                                java.util.HashMap amapCustomProperties)
                                         throws ECException
        Saves a command created using the createCommand method. It is saved as a custom property. A subsequent call to createCommand can return the saved command rather than creating a new one.
        Parameters:
        aCalculationCmd - the command to be saved.
        aabMethod - the calculation method that was used to create it.
        aCommandContext - the command context.
        amapCustomProperties - the custom properties.
        Throws:
        ECException
      • isSubOrderSupported

        public boolean isSubOrderSupported()
        Return if the sub order is supported, it is configured in instance xml.
        <Order/SubOrderSupported="false"/>
        or
         <Order/SubOrderSupported="false"/> 
        Returns:
        true SubOrder is supported. false SubOrder is not supported.
      • getOrderTotalAmount

        public java.math.BigDecimal getOrderTotalAmount(OrderAccessBean abOrder,
                                                        CommandContext aCommandContext)
                                                 throws ECException
        This method gets the order's total amount.
        Parameters:
        abOrder -
        aCommandContext -
        Returns:
        Throws:
        ECException
      • getHistoryOrderTotalAmount

        public java.math.BigDecimal getHistoryOrderTotalAmount(HistoryOrder anOrder,
                                                               CommandContext aCommandContext)
                                                        throws ECException
        This method gets the history order's total amount.
        Parameters:
        anOrder -
        aCommandContext -
        Returns:
        Throws:
        ECException
      • getOrderItemTotalAmount

        public java.math.BigDecimal getOrderItemTotalAmount(OrderItemAccessBean abOrderItem,
                                                            CommandContext aCommandContext)
                                                     throws ECException
        This method gets the order item's total amount.
        Parameters:
        abOrderItem -
        aCommandContext -
        Returns:
        Throws:
        ECException
      • getOrderItemsTotalAmount

        public java.math.BigDecimal getOrderItemsTotalAmount(OrderItemAccessBean[] abOrderItems,
                                                             CommandContext aCommandContext)
                                                      throws ECException
        This method gets the order item array's total amount.
        Parameters:
        abOrderItems -
        aCommandContext -
        Returns:
        Throws:
        ECException
      • getOrderReleaseTotalAmount

        public java.math.BigDecimal getOrderReleaseTotalAmount(OrderReleaseTotalsAccessBean[] abOrderReleaseTotals,
                                                               CommandContext aCommandContext)
                                                        throws ECException
        This method gets the order release total array's total amount.
        Parameters:
        abOrderReleaseTotals -
        aCommandContext -
        Returns:
        Throws:
        ECException
      • getPromotionDetailsByCalcodeID

        public static java.util.HashMap getPromotionDetailsByCalcodeID(java.lang.Integer calculationCodeID)
                                                                throws ECException
        Returns the details of a promotion based on the passed calculation code ID. This CALCODE_ID must be associated with a promotion.
        Parameters:
        calculationCodeID - A CALCODE_ID.
        Returns:
        A HashMap with the following keys:
         1. isCodeRequired - boolean value to indicate if the promotion requires a promotion code. 
        2. promotionType - the promotion type.
        Throws:
        ECException
      • intersectTaxCategoryIdsByOrder

        public static java.lang.Integer[] intersectTaxCategoryIdsByOrder(java.lang.Long nOrderId,
                                                                         java.lang.Integer[] nTaxCategoryIds)
        Get the tax category Ids from ORDTAX table for an order, and intersect the Ids with the passed-in list of tax category Ids.
        Parameters:
        nOrderId - The order ID.
        nTaxCategoryIds - A list of tax category Ids.
        Returns:
        The intersection of the 2 sets of Ids.