WebSphere Commerce Version 8.0.4.0

Example: Surcharge tax calculations

This example shows how you can use the calculation framework to calculate surcharge taxes.

Example description

Your store collects extra surcharge for the order in some geographical zone. The tax of surcharge must be calculated according to local business lines.

The following tables describes the tax that must be collected:

Table 1. Tax rate
Geographical zone Tax rate
A 5%

Surcharge tax calculation example implementation

To use the calculation framework to calculate taxes for this example, complete the following steps:

  1. Define the jurisdiction groups and jurisdictions.
  2. Define the tax categories.
  3. Define the calculation codes.
  4. Define the calculation rules.
  5. Define the calculation scales.
  6. Define the calculation ranges.
  7. Define the look-up results for the calculation ranges.
  8. Associate the calculation scales with the calculation rules.
  9. Attach the calculation codes to the all catalog entries.
  10. Associate the calculation rules with the fulfillment center.
  11. Allow the calculation usages to not calculate a value for an OrderItem.
  12. Optional: Set the default surcharge tax calculation codes for the store. You only complete this step if your store does not already have default calculation codes for surcharge tax.
Important: Text identifiers are used in the following sections to make it easier to see the relationships between components.

Text identifiers are often not valid in the WebSphere Commerce database. You should convert the text identifiers to integers or allow WebSphere Commerce to generate the identifiers for you. Check the database schema in the online information for the type of value that is valid for identifiers in a particular database table.

Defining tax jurisdiction groups and tax jurisdictions

The information for jurisdictions, jurisdiction groups, and the relationships between them are defined in the following database tables:

JURSTGROUP
This table defines jurisdiction groups.
JURST
This table defines jurisdictions.
JURSTGPREL
This table defines which jurisdictions belong to which jurisdiction groups.

Based on the description in the surcharge tax calculation example description, the jurisdiction, jurisdiction group and the relationship between them can be defined based on the following table:

Table 2. Tax jurisdiction groups and tax jurisdictions
Geographical zone Jurisdiction Jurisdiction group
A A GroupA

Defining tax category

The default value for the surcharge tax type is defined in the language-independent bootstrap file. A tax category is required for each combination of tax type and jurisdiction group.

The following table shows the tax category that can be defined based on the example description:

Table 3. Tax category
Tax category Tax type Description
GroupA_SurchargeTax -9 (surcharge tax) Geographical zone A, Surcharge tax (5%)

Each tax category is assigned a unique identifier. The unique identifier is used to associate a calculation rule with a tax category.

Defining tax calculation code

Calculation code must be defined in this example because the tax applies to all items in an order. Calculation code should be associated with a CalculationCodeQualify calculation method.

Here are the key properties that you must define for the calculation code:

Table 4. Tax calculation code
Property Value Description of value
Grouping method 0 No grouping of products is required
Qualification flag 0 The CalculationCodeQualify calculation method specified for this calculation code will not be invoked
Identifying string Surcharge tax example code This is a character string that uniquely identifies this calculation code, given a particular calculation usage and store or store group
Published 1 The calculation code is active
Calculation usage -9 This is the ID for surcharge tax calculation usage
CalculationCodeQualify calculation method -92 This is the ID for CalculationCodeQualifyCmd
CalculationCodeApply calculation method -94 This is the ID for SalesTaxCalculationCodeApplyCmd
CalculationCodeCalculate calculation method -93 This is the ID for CalculationCodeCalculateCmd

Defining tax calculation rule

Generally, percentage tax calculation requires one calculation rule for each calculation code and each tax category.

Here are the key properties that you must define for the calculation rule:

Table 5. Tax calculation rule
Property Value Description of value
Calculation code SurchargeTaxCalcCode This is the surcharge tax calculation code defined earlier
Identifying number 1 This is a number that, along with its calculation code, uniquely identifies this calculation rule
Qualification flag 1 Invoke the qualify calculation method defined for this calculation rule to check that this calculation rule applies to each item in the order
Combination 2 The results of this calculation rule can be combined with other calculation rules that have a 0 or 2 combination property
Tax category GroupA_SurchargeTax This is the ID for the calculation usage for surcharge tax
CalculationRuleQualify calculation method -96 This is the ID for TaxCalculationRuleQualifyCmd
CalculationRuleCalculate calculation method -97 This is the ID for CalculationRuleCalculateCmd

Defining tax calculation scale

A calculation scale is required for each combination of calculation usage and jurisdiction group. It is a percentage calculation scale and all its calculation ranges start with zero, which is convertible to all currencies. The calculation scale is used to find the percentage tax rate.

Here are the key properties that you must define for the calculation scale:

Table 6. Tax calculation scale
Property Value Description of value
Calculation usage -9 This is the calculation usage for surcharge tax
Identifying string Taxation example This is a character string that uniquely identifies this calculation scale, given a particular calculation usage and store or store group
CalculationScaleLookup calculation method -99 TaxableSurchargeCalculationScaleLookupCmd

Defining tax calculation range

Because the tax rate applies to all items in an order regardless of the item price, weight, or quantity, only one calculation range is required for calculation scale.

Here are the key properties you must define for the calculation range:

Table 7. Tax calculation range
Property Value Description of value
Calculation scale ID GroupASurchargeScale This is the calculation scale that was defined earlier
Calculation range starting value 0 Any total surcharge amount for an order greater than or equal to zero is subject to this range
Cumulative calculation range indicator 0 This calculation range is non-cumulative
CalculationRange calculation method -59 PercentageCalculationRangeCmd

Defining look-up results for tax calculation range

Each calculation range needs a set of look-up results. For this example, the look-up result is the percentage tax rate. The look-up result is a percentage value, so you do not need to associate currencies or quantity units with the look-up results.

Here are the key properties that you must define for each calculation range look-up result:

Table 8. Look-up results for tax calculation range
Property Value Description of value
Look-up result 5.0 This is the 5% surcharge tax rate for Group A
Calculation range ID GroupASurchargeRange This is the identifier of the calculation range to which this look-up result belongs

Associating tax calculation scale with tax calculation rule

Each of the calculation scales that you have defined must be associated with the defined calculation rules in the CRULESCALE database table. The relationship between the defined calculation scales and the defined calculation rules is shown in the following table:

Table 9. Tax calculation scale with tax calculation rule
Calculation scale Calculation rule
GroupASurchargeScale GroupASurchargeRule

Attaching tax calculation codes

To use the newly defined surcharge tax calculation code, you must attach the calculation code to the order items. Attach them indirectly, because the calculation code applies to all order items resulting from a customer purchasing a product from the store catalog, not just to one item.

To associate the calculation code with all items in the store catalog, use a catalog entry ID of null. The identifier for the store will be called Store.

Populate the CATENCALCD database table with the following information:

Table 10. Attaching tax calculation codes
Store ID Catalog entry ID Calculation code
Store null SurchargeTaxCalcCode

Associating tax calculation rule with fulfillment center

To associate a fulfillment center with a tax calculation rule in the TAXJCRULE database table. This ensures that the TaxCalculationRuleQualify calculation method chooses a calculation rule that matches one of the tax jurisdictions when shipping from a fulfillment center to a shipping address.

Table 11. Associating tax calculation rule with fulfillment center
Fulfillment center Tax jurisdiction Precedence Tax calculation rule
FulfillmentA GroupA 1 GroupASurchargeRule

Allow surcharge calculation usage to not calculate a value for an OrderItem

By default, WebSphere Commerce throws an exception when a calculation usage does not return a value for an order item. You can prevent this by setting the calculation usage indicator (STENCALUSG.USAGEFLAG) to 1. When the indicator is set to 1 and the calculation usage does not return a value, WebSphere Commerce assumes that the calculated value is 0.

The following table contains the information required to allow surcharge tax calculation usage to not calculate a value for an OrderItem:

Table 12. Allow surcharge calculation usage to not calculate a value for an OrderItem
Store ID Calculation usage Calculation code Usage indicator
Store -9 (surcharge tax) SurchargeTaxCalcCode 1

Defining default tax calculation codes for a store (optional)

The STENCALUSG database table is also used to define the default calculation codes for a store. Default calculation code information must appear in the same database row where the USAGEFLAG column will be set.

The following table contains the information required to define the default surcharge tax calculation code for the store:

Table 13. Defining default tax calculation codes for a store
Store ID Calculation Usage Calculation Code
Store -9 (surcharge tax) SurchargeTaxCalcCode