Example: Surcharge tax calculations
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:
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:
- Define the jurisdiction groups and jurisdictions.
- Define the tax categories.
- Define the calculation codes.
- Define the calculation rules.
- Define the calculation scales.
- Define the calculation ranges.
- Define the look-up results for the calculation ranges.
- Associate the calculation scales with the calculation rules.
- Attach the calculation codes to the all catalog entries.
- Associate the calculation rules with the fulfillment center.
- Allow the calculation usages to not calculate a value for an OrderItem.
- 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.
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:
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:
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:
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:
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:
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:
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:
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:
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:
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.
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:
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:
Store ID | Calculation Usage | Calculation Code |
---|---|---|
Store | -9 (surcharge tax) | SurchargeTaxCalcCode |