Develop > Controller layer > Application developer > Calculation framework


Calculation codes

Items for sale in a retail store often have attached price tags indicating information other than the price of the item. For example, if the item is on sale, the price tag indicates the percentage discount to apply to the price. Similarly, WebSphere Commerce attaches calculation codes to order items to indicate the calculations to be performed. The following figure shows a representation of price tags in a retail store compared with calculation codes in WebSphere Commerce.


Calculation codes indicate the calculations that must be performed

In the same way price tags are attached to the items for sale in a retail store, calculation codes are considered to be attached to order items. The attachment of a calculation code can be direct or indirect, depending on where the calculation code is specified within WebSphere Commerce.

Direct attachment of a calculation code to an item is similar to a cashier providing a one-time discount on a purchase; the calculation code is specified as part of the order or as part of the order item. When a calculation code is specified as part of an order, it is attached to all of the items that make up the order. Information that relates a calculation code to an order is stored in the ORDCALCD database table. Information that relates a calculation code to an order item is stored in the ORDICALCD database table.

Indirect attachment of a calculation code is similar to posting a sign in a retail store indicating which items in the store are on sale. The information about the discount is not shown on the price tags of the individual items, but the cashier knows to apply the discount when calculating the cost of an order. Indirect attachment of a calculation code in WebSphere Commerce occurs when the calculation code is specified as part of a catalog entry or catalog group.

Attachment of a calculation code to a catalog entry is similar to the sign in the retail store indicating that a discount applies to a particular product. Specifying a calculation code as part of a catalog group is similar to applying a discount to all products in a particular department. In WebSphere Commerce, such a calculation code applies to all catalog entries in the catalog group. Information that relates a calculation code to a catalog entry is stored in the CATENCALCD database table. Information that relates a calculation code to a catalog group is stored in the CATGPCALCD database table. The CATENCALCD database table is also used to attach a calculation code to all catalog entries.

You can also implicitly attach calculation codes to order items by specifying the default calculation code for a calculation usage in the STENCALUSG database table. The default calculation code is used for those items in an order that do not have any directly or indirectly attached calculation codes of a particular calculation usage. You can specify a default calculation code for a particular calculation usage at the store level and at the store group level. You specify a default calculation code at the store group level only when the store level default calculation code is not specified.

While attachment is defined outside of a calculation code, the following properties are defined as part of a calculation code:

These properties are defined in the CALCODE database table. The next section discusses the CALCODE database table and other database tables that affect the way calculation codes are used.


Database tables for calculation codes

In WebSphere Commerce, information about calculation codes is stored in the following database tables:

CALCODE

Defines calculation codes.

CALCODEDSC

Contains national language descriptions of a calculation code, allowing one calculation code to have a description in multiple languages.

CALCODEMGP

Associates a calculation code with a member group, allowing only a certain member group to use a calculation code.

CALCODTXEX

Associates a calculation code with a tax category, indicating that the monetary amounts that are determined by the calculation code are exempt from the taxes in that category.

CATGPCALCD

Attaches a calculation code to a catalog group in a specific store and, optionally, for a specific trading agreement. An example of a trading agreement is a contract.

All catalog entries belonging to the catalog group are associated with the calculation code that is assigned to the catalog group.

CATENCALCD

Attaches a calculation code with catalog entries in a specific store and, optionally, for a specific trading agreement. An example of a trading agreement is a contract.

ORDCALCD

Attaches a calculation code to an order. This table allows you to specify whether calculations should ignore indirectly attached calculation codes.

ORDICALCD

Attaches a calculation code to an order item. This table allows you to specify whether calculations should ignore indirectly attached calculation codes.

STENCALUSG

Defines the default calculation code for a calculation usage in a store or group of stores. This table also specifies the subclass of the CalculationCodeCombine calculation method that determines how multiple calculation codes for an order item are combined.


Calculation code data model diagrams

The following data model diagrams illustrate the relationships between the database tables used to define calculation codes, direct attachment of calculation codes, and indirect attachment of calculation codes.


Calculation methods for calculation codes

There are four calculation method subclasses associated with calculation codes:


Related concepts

Calculation framework

Related reference

Example: Discounts

Examples: Applying the calculation framework

Example: Shipping charges

Example: Sales tax and shipping tax calculations


+

Search Tips   |   Advanced Search