com.ibm.commerce.order.calculation
Class CalculationCodeCalculateCmdImpl

java.lang.Object
  |
  +--CacheableCommandImpl
        |
        +--com.ibm.commerce.command.AbstractECTargetableCommand
              |
              +--com.ibm.commerce.command.TaskCommandImpl
                    |
                    +--com.ibm.commerce.command.BusinessPolicyCommandImpl
                          |
                          +--com.ibm.commerce.order.calculation.CalculationCmdImpl
                                |
                                +--com.ibm.commerce.order.calculation.CalculationCodeCalculateCmdImpl
All Implemented Interfaces:
BusinessPolicyCommand, CalculationCmd, CalculationCodeCalculateCmd, ECCommand, ECTargetableCommand, TaskCommand

public class CalculationCodeCalculateCmdImpl
extends CalculationCmdImpl
implements CalculationCodeCalculateCmd

The default implementation of CalculationCodeCalculateCmd.

Its behaviour is as follows:

  1. invokes the calculation method of type "CalculationRuleCombine" referenced by the current store (see STENCALUSG.ACTRC_CALMETHOD_ID, CalculationRuleCombineCmd) to determine the following:
  2. merges the lists of values by tax category*.
  3. rounds the merged list of values by "fudging" (see CalculationHelper.round(BigDecimal[], String, CommandContext)) for each tax category*.
*for sales/shipping tax only.

Commands used:

Access beans used:
See Also:
Serialized Form

Field Summary
static java.lang.String COPYRIGHT
          The IBM copyright notice field.
 
Fields inherited from class com.ibm.commerce.command. BusinessPolicyCommandImpl
policyId, requestProperties
 
Fields inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
commandContext
 
Fields inherited from interface com.ibm.commerce.order.calculation. CalculationCodeCalculateCmd
defaultCommandClassName, NAME
 
Fields inherited from interface com.ibm.commerce.command. ECCommand
defaultCommandClassName
 
Constructor Summary
CalculationCodeCalculateCmdImpl()
          Constructor for CalculationCodeCalculateCmdImpl.
 
Method Summary
protected   CalculationRuleCombineCmd callRuleCombine()
          Invokes the calculation method of type "CalculationRuleCombine" referenced by the current store (see STENCALUSG.ACTRC_CALMETHOD_ID, CalculationRuleCombineCmd).
protected  Item[] getItems()
          Returns the items.
protected  java.lang.Integer[] getTaxCategoryIds()
          Returns the tax categories.
 java.math.BigDecimal[] getValues()
          Returns the values corresponding to the items.
 java.math.BigDecimal[] getValues(java.lang.Integer anTaxCategoryId)
          Returns the values for a tax category.
 void performExecute()
          The business logic for this command.
 void reset()
          This method should be called after a command has been executed to reset its states variables.
protected  void roundValues()
          Rounds the merged list of values by "fudging" for each tax category.
 void setCode(CalculationCodeAccessBean aabCode)
          Sets the calculation code.
 void setItems( Item[] aItems)
          Sets the items.
 void setTaxCategoryIds(java.lang.Integer[] anTaxCategoryIds)
          Sets the tax categories that should be active during execution.
protected  void setValues(java.math.BigDecimal[] adValues)
          Sets the values corresponding to the items.
protected  void setValues(java.lang.Integer anTaxCategoryId, java.math.BigDecimal[] adValues)
          Sets the values for a tax category.
 
Methods inherited from class com.ibm.commerce.order.calculation. CalculationCmdImpl
createCommand, getCurrency, getCustomProperties, getCustomProperty, getTimestamp, getUsageId, setCurrency, setCustomProperties, setCustomProperty, setTimestamp, setUsageId
 
Methods inherited from class com.ibm.commerce.command. BusinessPolicyCommandImpl
getPolicyId, getRequestProperties, setPolicyId, setRequestProperties
 
Methods inherited from class com.ibm.commerce.command. AbstractECTargetableCommand
accessControlCheck, checkIsAllowed, checkParameters, checkResourcePermission, createCommandExecutionEvent, execute, finalize, getAccCheck, getCommandContext, getCommandIfName, getCommandName, getCommandStoreId, getDefaultProperties, getResources, getStoreId, getUser, getUserId, isReadyToCallExecute, setAccCheck, setCommandContext, setCommandIfName, setCommandStoreId, setDefaultProperties, validateParameters
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.commerce.order.calculation. CalculationCmd
getCurrency, getCustomProperties, getCustomProperty, getTimestamp, getUsageId, setCurrency, setCustomProperties, setCustomProperty, setTimestamp, setUsageId
 
Methods inherited from interface com.ibm.commerce.command. BusinessPolicyCommand
getPolicyId, getRequestProperties, setPolicyId, setRequestProperties
 

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

CalculationCodeCalculateCmdImpl

public CalculationCodeCalculateCmdImpl()
Constructor for CalculationCodeCalculateCmdImpl.
Method Detail

callRuleCombine

protected CalculationRuleCombineCmd callRuleCombine()
                                             throws ECException
Invokes the calculation method of type "CalculationRuleCombine" referenced by the current store (see STENCALUSG.ACTRC_CALMETHOD_ID, CalculationRuleCombineCmd). This method is called by performExecute().
Returns:
the command.
Throws:
ECException

getItems

protected Item[] getItems()
Returns the items.
Returns:
the items.

getTaxCategoryIds

protected java.lang.Integer[] getTaxCategoryIds()
Returns the tax categories.
Returns:
the tax category IDs.

getValues

public java.math.BigDecimal[] getValues()
Returns the values corresponding to the items.
Specified by:
getValues in interface CalculationCodeCalculateCmd
Returns:
the values.

getValues

public java.math.BigDecimal[] getValues(java.lang.Integer anTaxCategoryId)
Returns the values for a tax category.
Specified by:
getValues in interface CalculationCodeCalculateCmd
Parameters:
anTaxCategoryId - the tax category ID.
Returns:
the values for the tax category.

performExecute

public void performExecute()
                    throws ECException
Description copied from class: AbstractECTargetableCommand
The business logic for this command. This method should be overwritten by all command writers. Command writers should call super.performExecute() as the first line in their method.
Specified by:
performExecute in interface ECCommand
Overrides:
performExecute in class AbstractECTargetableCommand
Throws:
ECException
See Also:
ECCommand.performExecute()

reset

public void reset()
Description copied from class: AbstractECTargetableCommand
This method should be called after a command has been executed to reset its states variables. After the call to reset, we should be able to execute the command again.
Overrides:
reset in class CalculationCmdImpl
See Also:
com.ibm.websphere.command.Command#reset()

roundValues

protected void roundValues()
                    throws ECException
Rounds the merged list of values by "fudging" for each tax category. For more information, refer to CalculationHelper.round(BigDecimal[], String, CommandContext).
Throws:
ECException

setCode

public void setCode(CalculationCodeAccessBean aabCode)
Sets the calculation code.
Specified by:
setCode in interface CalculationCodeCalculateCmd
Parameters:
aabCode - the calculation code.

setItems

public void setItems(Item[] aItems)
Sets the items.
Specified by:
setItems in interface CalculationCodeCalculateCmd
Parameters:
aItems - the items.

setTaxCategoryIds

public void setTaxCategoryIds(java.lang.Integer[] anTaxCategoryIds)
Sets the tax categories that should be active during execution. Normally that would be all sales/shipping tax categories defined in the current store. For sales/shipping tax only.
Specified by:
setTaxCategoryIds in interface CalculationCodeCalculateCmd
Parameters:
anTaxCategoryIds - the tax category IDs.

setValues

protected void setValues(java.math.BigDecimal[] adValues)
Sets the values corresponding to the items.
Parameters:
adValues - the values.

setValues

protected void setValues(java.lang.Integer anTaxCategoryId,
                         java.math.BigDecimal[] adValues)
Sets the values for a tax category.
Parameters:
anTaxCategoryId - the tax category ID.
adValues - the values.