This section describes the following pricing engine classes:
Item, Order, Tax, and Shipping Pricing Engine Classes
ItemPricingEngineImpl
ShippingPricingEngineImpl
TaxPricingEngineImpl
OrderPricingEngineImpl
PricingEngineService
The PricingEngineService
class is a GenericService
implementation of a PricingEngine
. PricingEngine
implementations can extend this class to leverage scheduling, global promotions, locale, and other configuration functionality.
The PricingEngineService
class contains the following properties:
scheduler
: Theatg.service.scheduler.Scheduler
that this service uses to run theglobalPromotionsQuery
. Re-running the query generates a new list of global promotions, which are then passed to into pricing engine methods.updateSchedule
: The schedule for running theglobalPromotionsQuery
.defaultLocale
: The default locale in which this pricing engine should generate prices.priceInfoClass
: The class of the prices that this engine generates. This property is configured based on the class extension. For example,ItemPricingEngine
sets this toItemPriceInfo
.pricingModelComparator
: The comparator used to sort promotions.pricingModelProperties
: A configuration bean that holds the name of every property of a pricing modelRepositoryItem
.profileProperties
: A list of profile properties to be checked for active promotions.promotionsRepository
: The name of the repository that holds the promotions this engine can use.promotionItemTypes
: An array of item descriptor names in the repository shown in thepromotionsRepository
property. A promotion that this engine uses as a pricing model must be of one of the types inpromotionItemTypes
.globalPromotionsQuery
: An RQL query that is run on thepromotionsRepository
to return all promotions that should always be taken into account in every pricing. A typical way to mark global promotions is to have assign all promotions in thepromotionsRepository
a boolean propertyglobal
, and to have the query return all promotions whoseglobal
property value istrue
.
Item, Order, Tax, and Shipping Pricing Engine Classes
The following four classes are implementations of their respective pricing engine interfaces:
The
ItemPricingEngineImpl
class is an implementation of theItemPricingEngine
interface. It computes the price of items both individually and in a larger context. It invokes a series ofItemPricingCalculators
.The
OrderPricingEngineImpl
class is an implementation of theOrderPricingEngine
interface. It computes the price for an order, invoking a series ofOrderPricingCalculators
.The
ShippingPricingEngineImpl
class is an implementation of theShippingPricingEngine
interface. It computes the shipping cost for an order by invoking a series ofShippingPricingCalculators
.The
TaxPricingEngineImpl
is an implementation of theTaxPricingEngine
interface. It computes the tax for an order, invoking a series ofTaxPricingCalculators
.
Each of these implementation classes also extends the abstract class, PricingEngineService
, which is described in the previous section.
As described earlier in How Pricing Services Generate Prices, each engine calls a series of calculators as follows:
The engine invokes one or more
preCalculators
to provide a base price to which subsequent calculators can then apply a discount. It invokes them on the inputpPriceQuote
in the order in which they appear in itspreCalculators
property. (Each type of engine calls its corresponding type of precalculator – for example, theOrderPricingEngineImpl
callsOrderPricingCalculators
and theTaxPricingEngineImpl
callsTaxPricingCalculators
.)The engine uses its
getPricingModels
method to extract any promotions from the customer’s profile, and then it processes the promotions one at a time, invoking the discount calculators from each one. (Discount calculators are specified in a promotion’spricingCalculatorService
property.)Finally the engine invokes any
postCalculators
configured for it. It invokes them on the inputpPriceQuote
in the order in which they appear in itspostCalculators
property. Again, each pricing engine calls postcalculators of its own type.