java.lang.Object | +--com.ibm.commerce.order.calculation.CalculationHelper
This class defines various helper methods used by the Calculation Framework.
Field Summary | |
---|---|
static java.lang.String |
COPYRIGHT The IBM copyright notice field. |
Constructor Summary | |
---|---|
protected |
CalculationHelper() Constructor for CalculationHelper. |
Method Summary | |
---|---|
void |
applyCalculationUsages(
OrderItemAccessBean[] aabOrderItems, java.lang.String astrCurrency,
java.util.HashMap ahshCustomProperties,
CommandContext commandContext) This method is called by OrderPrepare/PrepareOrder to apply all calculation usages enabled in the store. |
void |
applyCalculationUsages(
OrderItemAccessBean[] aabOrderItems, java.lang.String astrCurrency,
java.util.HashMap ahshCustomProperties, java.util.Set aEnabledUsageIds,
java.util.Set aDisabledUsageIds,
CommandContext commandContext) This method is called by OrderPrepare/PrepareOrder to apply all calculation usages enabled in the store. |
int |
compare(java.lang.Comparable[] c1,
java.lang.Comparable[] c2) Compares 2 arrays of Comparables. |
int |
compare(java.lang.Comparable c1, java.lang.Comparable c2) Compares 2 Comparables. |
boolean |
containsAny(java.lang.Object[] a1, java.lang.Object[] a2) Returns whether the first array contains any element in the second array. |
java.math.BigDecimal |
convertMonetaryValue(java.math.BigDecimal adValue1,
java.lang.String astrCurrency1, java.lang.String astrCurrency2,
CommandContext commandContext) This method converts the monetary value from one currency to another using the forward conversion rate. |
java.math.BigDecimal |
convertMonetaryValueR(java.math.BigDecimal adValue1,
java.lang.String astrCurrency1, java.lang.String astrCurrency2,
CommandContext commandContext) This method converts the monetary value from one currency to another using the backward conversion rate. |
java.math.BigDecimal |
convertQuantityValue(java.math.BigDecimal adValue1,
java.lang.String astrUnit1, java.lang.String astrUnit2) This method converts the quantity value from one unit to another. |
void |
correctZeroBoundaryCrossings(
Item[] aItems, java.math.BigDecimal[] adAdjustments,
java.lang.String astrCurrency,
CommandContext commandContext) This method is called by DiscountCalculationCodeApply to correct discounts that cross the zero boundary. |
protected
boolean |
correctZeroBoundaryCrossingsIteration(
Item[] aItems, java.math.BigDecimal[] adAdjustments) This method represents a single iteration in the "correct zero boundary crossing" algorithm. |
java.math.BigDecimal[] |
destructiveAdd(java.math.BigDecimal[] adValues1,
java.math.BigDecimal[] adValues2) Returns the sum of 2 BigDecimal arrays. |
java.math.BigDecimal |
divide(java.math.BigDecimal ad1, java.math.BigDecimal ad2) Returns ad1.divide(ad2, 20, BigDecimal.ROUND_HALF_UP). |
void |
finalizeCalculationUsages(
OrderAccessBean aabOrder,
OrderItemAccessBean[] aabOrderItems, java.lang.String astrCurrency,
java.util.HashMap ahshCustomProperties,
CommandContext commandContext) This method is called by OrderProcess/ProcessOrder to apply all calculation usages enabled in the store. |
void |
finalizeCalculationUsages(
OrderAccessBean aabOrder,
OrderItemAccessBean[] aabOrderItems, java.lang.String astrCurrency,
java.util.HashMap ahshCustomProperties, java.util.Set aEnabledUsageIds,
java.util.Set aDisabledUsageIds,
CommandContext commandContext) This method is called by OrderProcess/ProcessOrder to apply all calculation usages enabled by the store. |
int |
findMax(java.math.BigDecimal[] e) Returns the index of the largest value in a BigDecimal array. |
int |
findMin(java.math.BigDecimal[] e) Returns the index of the smallest value in a BigDecimal array. |
java.lang.Integer |
getCodeId(java.lang.Integer anRuleId) Returns the CalculationCode ID of the specified CalculationRule. |
static
CalculationHelper |
getInstance() Returns an instance of this class. |
java.lang.Long[] |
getProductAndItemIds(java.lang.Long anCatalogEntryId) Returns the parent product of an item and the item itself. |
java.lang.Long[] |
getProductOrItemIds(java.lang.Long anCatalogEntryId) Returns the parent product of an item. |
java.math.BigDecimal |
getQuantity(java.lang.Long anCatalogEntryId,
java.math.BigDecimal adNormalizedQuantity,
java.lang.String astrUnit) Returns the quantity value represented by the specified normalized quantity. |
java.math.BigDecimal |
getRoundingMultiple(java.lang.String astrCurrency,
CommandContext commandContext) Returns the rounding multiple of the specified currency. |
java.math.BigDecimal |
getRoundingMultiple(java.lang.String astrCurrency,
java.lang.String astrNumberUsage,
CommandContext commandContext) Returns the rounding multiple of the specified currency. |
java.lang.Integer |
getStoreGroupId(java.lang.Integer anStoreId) Returns the StoreGroup ID of the specified Store. |
java.math.BigDecimal |
getTaxableAdjustmentTotal(java.lang.Long anOrderItemId,
java.lang.Integer anTaxCategoryId) Returns the taxable adjustment total of the specified OrderItem and TaxCategory. |
java.util.Map |
getTaxableAdjustmentTotals(
Item[] aItems, java.lang.Integer anTaxCategoryId,
java.util.HashMap ahshCustomProperties) Returns the taxable adjustment total of the specified Items and TaxCategory. |
java.lang.Integer[] |
getTaxCategoryIds(
StoreAccessBean aabStore, java.lang.Integer anUsageId) 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 |
java.math.BigDecimal |
getWeight(java.lang.Long anCatalogEntryId,
java.math.BigDecimal adNormalizedQuantity,
java.lang.String astrUnit) Returns the weight value represented by the specified normalized quantity. |
void |
initializeCalculationUsages(
OrderAccessBean aabOrder,
OrderItemAccessBean[] aabOrderItems, java.lang.String astrCurrency,
java.util.HashMap ahshCustomProperties,
CommandContext commandContext) This method is called by OrderPrepare/PrepareOrder to initialize all calculation usages enabled by the store. |
void |
initializeCalculationUsages(
OrderAccessBean aabOrder,
OrderItemAccessBean[] aabOrderItems, java.lang.String astrCurrency,
java.util.HashMap ahshCustomProperties, java.util.Set aEnabledUsageIds,
java.util.Set aDisabledUsageIds,
CommandContext commandContext) This method is called by OrderPrepare/PrepareOrder to initialize all calculation usages enabled by the store. |
boolean |
isCurrentUserInMemberGroup(java.lang.Long anMemberGroupId,
CommandContext commandContext) |
boolean |
isEffective(CalculationCodeAccessBean aabCode,
java.sql.Timestamp aTimestamp) Returns whether a CalculationCode is effective at the specified time. |
boolean |
isPublished(CalculationCodeAccessBean aabCode) Returns whether a CalculationCode is published. |
CalculationCodeAccessBean[] |
merge(CalculationCodeAccessBean[] aabCodes1,
CalculationCodeAccessBean[] aabCodes2) Merges 2 CalculationCode arrays into a single array with no duplicate element. |
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]. |
void |
round(java.math.BigDecimal[] a, java.lang.String astrCurrency,
CommandContext commandContext) Rounds a BigDecimal array using the "fudging" algorithm. |
void |
round(java.math.BigDecimal[] a, java.lang.String astrCurrency,
java.lang.String astrNumberUsage,
CommandContext commandContext) Rounds a BigDecimal array using the "fudging" algorithm. |
java.math.BigDecimal |
round(java.math.BigDecimal adValue, java.lang.String astrCurrency,
CommandContext commandContext) Rounds a monetary value in the specified currency. |
java.math.BigDecimal |
round(java.math.BigDecimal adValue, java.lang.String astrCurrency,
java.lang.String astrNumberUsage,
CommandContext commandContext) Rounds a monetary value in the specified currency. |
java.math.BigDecimal[] |
spread(java.math.BigDecimal adValue,
java.math.BigDecimal[] adWeights) Spreads a value using the specified mathematical weights. |
java.math.BigDecimal |
sum(java.math.BigDecimal[] adValues) Sums the elements of a BigDecimal array. |
void |
summarizeCalculationUsages(
OrderAccessBean aabOrder,
SubOrderAccessBean[] aabSubOrders,
OrderItemAccessBean[] aabOrderItems, java.lang.String astrCurrency,
java.util.HashMap ahshCustomProperties,
CommandContext commandContext) This method is called by OrderPrepare/PrepareOrder to summarize all calculation usages enabled by the store. |
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) This method is called by OrderPrepare/PrepareOrder to summarize all calculation usages enabled by the store. |
java.lang.String |
toString(java.lang.Object[] a) Returns the string representation of the specified array. |
SubOrderAccessBean[] |
updateSubOrders(java.lang.Long anOrderId,
OrderItemAccessBean[] aabOrderItems) This method is called by OrderPrepare/PrepareOrder to update the suborder totals of an order. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll,
toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String COPYRIGHT
Constructor Detail |
---|
protected CalculationHelper()
Method Detail |
---|
public void applyCalculationUsages(OrderItemAccessBean[] aabOrderItems, java.lang.String astrCurrency, java.util.HashMap ahshCustomProperties, CommandContext commandContext) throws ECException
aabOrderItems
- the OrderItems.astrCurrency
- the (Order) currency.ahshCustomProperties
- the custom properties. Key: property
name (String). Value: property value (Object).commandContext
- the command context.ECException
public int compare(java.lang.Comparable[] c1, java.lang.Comparable[] c2)
compare(Comparable, Comparable)
and return the first non-zero
resultc1
- the first array.c2
- the second array.public int compare(java.lang.Comparable c1, java.lang.Comparable c2)
c1
- the first Comparable.c2
- the second Comparable.public boolean containsAny(java.lang.Object[] a1, java.lang.Object[] a2)
a1
- the first array.a2
- the second array.public java.math.BigDecimal convertMonetaryValue(java.math.BigDecimal adValue1, java.lang.String astrCurrency1, java.lang.String astrCurrency2, CommandContext commandContext) throws ECException
adValue1
- the original monetary value.astrCurrency1
- the original currency.astrCurrency2
- the target currency.commandContext
- the command context.ECException
public java.math.BigDecimal convertMonetaryValueR(java.math.BigDecimal adValue1, java.lang.String astrCurrency1, java.lang.String astrCurrency2, CommandContext commandContext) throws ECException
adValue1
- the original monetary value.astrCurrency1
- the original currency.astrCurrency2
- the target currency.commandContext
- the command context.ECException
public java.math.BigDecimal convertQuantityValue(java.math.BigDecimal adValue1, java.lang.String astrUnit1, java.lang.String astrUnit2) throws ECException
adValue1
- the original quantity value.ECException
public void correctZeroBoundaryCrossings(Item[] aItems, java.math.BigDecimal[] adAdjustments, java.lang.String astrCurrency, CommandContext commandContext) throws ECException
aItems
- the Items.adAdjustments
- the adjustments to be corrected.astrCurrency
- the currency which the adjustments are in.commandContext
- the commandContext.ECException
protected boolean correctZeroBoundaryCrossingsIteration(Item[] aItems, java.math.BigDecimal[] adAdjustments) throws ECException
ECException
public java.math.BigDecimal[] destructiveAdd(java.math.BigDecimal[] adValues1, java.math.BigDecimal[] adValues2)
adValues1
- the first BigDecimal array.adValues2
- the second BigDecimal array.public java.math.BigDecimal divide(java.math.BigDecimal ad1, java.math.BigDecimal ad2)
ad1
- the first BigDecimal.ad2
- the second BigDecimal.public void finalizeCalculationUsages(OrderAccessBean aabOrder, OrderItemAccessBean[] aabOrderItems, java.lang.String astrCurrency, java.util.HashMap ahshCustomProperties, CommandContext commandContext) throws ECException
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.ECException
public int findMax(java.math.BigDecimal[] e)
e
- the BigDecimal array.public int findMin(java.math.BigDecimal[] e)
e
- the BigDecimal array.public java.lang.Integer getCodeId(java.lang.Integer anRuleId) throws ECException
anRuleId
- the CalculationRule ID.ECException
public static CalculationHelper getInstance()
public java.lang.Long[] getProductAndItemIds(java.lang.Long anCatalogEntryId) throws ECException
anCatalogEntryId
- the CatalogEntry ID of the item.ECException
public java.lang.Long[] getProductOrItemIds(java.lang.Long anCatalogEntryId) throws ECException
anCatalogEntryId
- the CatalogEntry ID of the item.ECException
public java.math.BigDecimal getQuantity(java.lang.Long anCatalogEntryId, java.math.BigDecimal adNormalizedQuantity, java.lang.String astrUnit) throws ECException
anCatalogEntryId
- the CatalogEntry ID.adNormalizedQuantity
- the normalized quantity.astrUnit
- the target unit.ECException
public java.math.BigDecimal getRoundingMultiple(java.lang.String astrCurrency, CommandContext commandContext) throws ECException
astrCurrency
- the currency.commandContext
- the command context.ECException
public java.lang.Integer getStoreGroupId(java.lang.Integer anStoreId) throws ECException
anStoreId
- the Store ID.ECException
public java.math.BigDecimal getTaxableAdjustmentTotal(java.lang.Long anOrderItemId, java.lang.Integer anTaxCategoryId) throws ECException
anOrderItemId
- the OrderItem ID.anTaxCategoryId
- the TaxCategory ID.ECException
public java.lang.Integer[] getTaxCategoryIds(StoreAccessBean aabStore, java.lang.Integer anUsageId) throws ECException
Calculation Usage | Tax Categories |
---|---|
sales tax | all sales tax categories |
shipping tax | all shipping tax categories |
other | null |
aabStore
- the Store.anUsageId
- the CalculationUsage ID.ECException
public java.math.BigDecimal getWeight(java.lang.Long anCatalogEntryId, java.math.BigDecimal adNormalizedQuantity, java.lang.String astrUnit) throws ECException
anCatalogEntryId
- the CatalogEntry ID.adNormalizedQuantity
- the normalized quantity.astrUnit
- the target unit.ECException
public void initializeCalculationUsages(OrderAccessBean aabOrder, OrderItemAccessBean[] aabOrderItems, java.lang.String astrCurrency, java.util.HashMap ahshCustomProperties, CommandContext commandContext) throws ECException
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.ECException
public boolean isCurrentUserInMemberGroup(java.lang.Long anMemberGroupId, CommandContext commandContext) throws ECException
ECException
public boolean isEffective(CalculationCodeAccessBean aabCode, java.sql.Timestamp aTimestamp) throws ECException
aabCode
- the CalculationCode.aTimestamp
- the time.ECException
public boolean isPublished(CalculationCodeAccessBean aabCode) throws ECException
aabCode
- the CalculationCode.ECException
public CalculationCodeAccessBean[] merge(CalculationCodeAccessBean[] aabCodes1, CalculationCodeAccessBean[] aabCodes2) throws ECException
aabCodes1
- the first array.aabCodes2
- the second array.ECException
public java.math.BigDecimal[] remapValues(Item[] aItems1, java.math.BigDecimal[] adValues1, Item[] aItems2)
aItems1
- the first Item array.adValues1
- the first BigDecimal array.aItems2
- the second Item array.public void round(java.math.BigDecimal[] a, java.lang.String astrCurrency, CommandContext commandContext) throws ECException
a
- the BigDecimal array.astrCurrency
- the currency.commandContext
- the command context.ECException
public java.math.BigDecimal round(java.math.BigDecimal adValue, java.lang.String astrCurrency, CommandContext commandContext) throws ECException
adValue
- the monetary value.astrCurrency
- the currency.commandContext
- the command context.ECException
public java.math.BigDecimal[] spread(java.math.BigDecimal adValue, java.math.BigDecimal[] adWeights) throws ECException
adValue
- the value to be spreaded.adWeights
- the mathematical weights.ECException
public java.math.BigDecimal sum(java.math.BigDecimal[] adValues)
adValues
- the array.public void summarizeCalculationUsages(OrderAccessBean aabOrder, SubOrderAccessBean[] aabSubOrders, OrderItemAccessBean[] aabOrderItems, java.lang.String astrCurrency, java.util.HashMap ahshCustomProperties, CommandContext commandContext) throws ECException
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.ECException
public java.lang.String toString(java.lang.Object[] a)
a
- the array.public SubOrderAccessBean[] updateSubOrders(java.lang.Long anOrderId, OrderItemAccessBean[] aabOrderItems) throws ECException
anOrderId
- the Order ID.aabOrderItems
- the OrderItems.ECException
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
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.ECException
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
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.ECException
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
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.ECException
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
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.ECException
public java.math.BigDecimal getRoundingMultiple(java.lang.String astrCurrency, java.lang.String astrNumberUsage, CommandContext commandContext) throws ECException
astrCurrency
- the currency.astrNumberUsage
- the number usage.commandContext
- the command context.ECException
public void round(java.math.BigDecimal[] a, java.lang.String astrCurrency, java.lang.String astrNumberUsage, CommandContext commandContext) throws ECException
a
- the BigDecimal array.astrNumberUsage
- the number usage.astrCurrency
- the currency.commandContext
- the command context.ECException
public java.math.BigDecimal round(java.math.BigDecimal adValue, java.lang.String astrCurrency, java.lang.String astrNumberUsage, CommandContext commandContext) throws ECException
adValue
- the monetary value.astrCurrency
- the currency.commandContext
- the command context.ECException
public java.util.Map getTaxableAdjustmentTotals(Item[] aItems, java.lang.Integer anTaxCategoryId, java.util.HashMap ahshCustomProperties) throws ECException
aItems
- the Items.anTaxCategoryId
- the TaxCategory ID.ahshCustomProperties
- the custom properties. Key: property
name (String). Value: property value (Object).ECException