The atg.commerce.pricing.DiscountCalculatorService
class is an extension of GenericService
. DiscountCalculatorService
computes a price based on the type of discount, the discount amount, and the current price. It holds information common to all the discount calculators, which can extend this class to eliminate redundant configuration code.
The adjust
method can be used as a quick way to apply a discount. It calculates a price based on an existing price, the discount type, and the discount amount. This functionality is used by all discount calculators.
The DiscountCalculatorService
also includes getAdjuster()
and getDiscountType()
methods, which make it easy to override the default means of determining the adjuster and discount types.
The following list describes important properties in the DiscountCalculatorService
class:
pricingModelProperties
: Points to a configuration bean that holds the names of all the properties of a pricing model repository item.negativeAmountException
: Oracle ATG Web Commerce never discounts the price of an object to less than zero. This property determines what happens when a discount would cause the amount to be negative.True
: Throw an exception when a discount causes an amount to be negative.False
: (default) Log a warning message and set the amount to 0.0 when a discount causes an amount to be negative.