com.ibm.commerce.taxation.commands
Class TaxCalculationRuleCalculateCmdImpl

com.ibm.commerce.taxation.commands.TaxCalculationRuleCalculateCmdImpl
All Implemented Interfaces:
TaxCalculationRuleCalculateCmd

public class TaxCalculationRuleCalculateCmdImpl
implements TaxCalculationRuleCalculateCmd

The default implementation adds the results from each applicable CalculationScale.

A CalculationScale is applicable if it can calculate a MonetaryAmount in the Order currency, except a CalculationScale whose currStr indicates a currency other than the Order currency is not applicable if either:

  1. another applicable CalculationScale has a currStr that does indicate the Order currency, or
  2. a set of applicable CalculationScales with a common yet different different currStr attribute exists and can produce a lower total result.
Effectively, if any scales have a currency, only one such currency will be used, and it will be the Order currency if such a scale exists. Otherwise it will be the currency of the set of scales that gives the lowest result.

The default implementation's algorithm is:

  1. If a CalculationScale throws a conversion exception, continue processing as if we did not call that CalculationScale.
  2. Start with a zero total result for each OrderItem.
  3. For each CalculationScale associated with this CalculationRule whose currStr attribute is empty:
    1. Obtain a MonetaryAmount result for each OrderItem in the Order currency from the CalculationScale. Add this result to the total result for each OrderItem.
  4. Determine the set of currencies indicated by the currStr attributes of the CalculationScales whose currStr attributes indicate currencies that can be converted to the Order currency.
  5. If the set of currencies includes the Order currency:
    1. Start with a zero candidate result for each OrderItem.
    2. For each CalculationScale associated with this CalculationRule whose currStr attribute indicates the CalculationScale is in that currency:
    3. Obtain a MonetaryAmount result for each OrderItem in that currency from the CalculationScale. Add these results to the candidate results.
  6. However, If the set of currencies does not include the Order currency:
    1. For each currency in the set, calculate a candidate result for each OrderItem using steps 5a, 5b, and 5b1.
  7. Choose the set of candidate results (i.e. One per OrderItem) whose sum is the lowest, and add those results to the total result for each OrderItem.
  8. Return the total results, one for each OrderItem.


Field Summary
static java.lang.String COPYRIGHT
           
 
Fields inherited from interface com.ibm.commerce.taxation.commands.TaxCalculationRuleCalculateCmd
defaultCommandClassName, NAME
 
Constructor Summary
TaxCalculationRuleCalculateCmdImpl()
           
 
Method Summary
 void performExecute()
          Executes main business logic of the command.
 void setCalculationRuleAB(CalculationRuleAccessBean calculationRuleAB)
          Sets the CalculationRuleAccessBean.
 void setOrderItemABHash(java.util.Hashtable orderItemABHash)
          Sets the list of OrderItemAccessBean.
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
Constructor Detail

TaxCalculationRuleCalculateCmdImpl

public TaxCalculationRuleCalculateCmdImpl()
Method Detail

performExecute

public void performExecute()
                    throws ECException
Executes main business logic of the command.

setCalculationRuleAB

public void setCalculationRuleAB(CalculationRuleAccessBean calculationRuleAB)
Sets the CalculationRuleAccessBean.
Parameters:
calculationRuleAB - The CalculationRuleAccessBean.

setOrderItemABHash

public void setOrderItemABHash(java.util.Hashtable orderItemABHash)
Sets the list of OrderItemAccessBean.
Parameters:
orderItemABHash - The list of OrderItemAccessBean.