Develop > Controller layer > Application developer > Order Management subsystem
Calculation codes for orders
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, and taxes.
The OrderCalculate and OrderPrepare commands determine which kinds of calculations should be performed by inspecting the STENCALUSG table. OrderCalculate will accept the `calculationUsageId' parameter, which will determine the kinds of charges calculated in OrderCalculate. (You can define additional kinds of calculations to be performed, and provide or extend the business logic associated with each kind of calculation.)
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, in addition to quantitative attributes of the product such as weight, quantity, and price, they take into account the following attributes:
- Calculation code
- Member group membership
- Calculation scales
- Start and end dates
- Sequence in which calculations should be performed
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. 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, the calculation uses only the one with the highest sequence attribute. 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 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.
If an order contains an expired shipping promotion, it is removed from the order when either OrderCalculate or OrderPrepare run.
The database table PX_PROMOARG contains the information about all promotions applied to an order.
Related concepts
Related reference