Calculation codes represent ways of determining monetary amounts associated with OrderItems. The CalculationCode object and its associated CalculationMethod objects define how to calculate amounts such as price adjustments (coupons and discounts), shipping charges, sales or use taxes, and shipping taxes.
The OrderCalculate and OrderPrepare commands determine which kinds of calculations should be performed by inspecting the STENCALUSG table. (You can define additional kinds of calculations to be performed, and provide or extend the business logic associated with each kind of calculation. Refer to the WebSphere Commerce Calculation Framework Guide for more information.)
The default CalculationMethod objects determine which CalculationCode objects apply to the items in an Order by searching for attachment relationships in the CATENCALCD, CATGPCALCD, ORDCALCD, and ORDICALCD tables. They calculate their amounts and take into account the calculation code, member group membership, calculation scales, start and end dates, and the sequence in which calculations should be performed, as well as quantitative attributes of the product, such as weight, quantity, and price.
Product Managers can define CalculationCode objects and attach them to catalog entries or groups in their catalogs. Attaching a calculation code to a catalog group has the same effect as attaching it to all the catalog entries directly in the catalog group. More than one discount or shipping charge calculation code may be attached to a catalog entry, and amounts will be calculated for each calculation code. However, if more than one tax calculation code of a particular tax type is attached to a catalog entry, only the one with the highest sequence attribute will be used. You can also limit a CalculationCode attachment to specific TradingAgreements. Calculation codes attached to catalog entries and groups are considered to be indirectly attached to OrderItem objects that refer to those catalog entries.
Store Customer Service Representatives can directly attach CalculationCode objects to specific Order or OrderItem objects, to override the discounts and shipping charges that would otherwise be calculated by indirectly attached calculation codes. CalculationCode objects that are directly attached to an Order are considered to be directly attached to all the OrderItems in that Order.
Calculation codes can be restricted for use only by qualifying customers. When the CalculationCode flags attribute specifies the "restricted" bit, the CalculationCodeQualify CalculationMethod is invoked. The default implementation of that method allows use of the calculation code only if the customer appears in one of the member group objects listed in the CALCODEMGP table, and only if the membergroup also appears in the STOREMBRGP table for the store.