|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectatg.nucleus.logging.VariableArgumentApplicationLoggingImpl
atg.nucleus.GenericService
atg.commerce.pricing.DiscountCalculatorService
public class DiscountCalculatorService
A GenericService version of a discount calculator. Discount calculators
can extend this class so as to eliminate redundant configuration code. Additionally,
the adjust
method can be leveraged as a means of quickly applying a
discount.
Properties:
adjust
method should return negative amounts (if this property is false), or should throw
an exception instead (if true)
Qualifier
,
PricingModelProperties
Field Summary | |
---|---|
protected static int |
AMOUNT_INCREASE_TYPE
Integer representation of an Amount Increase adjustment |
protected static int |
AMOUNT_OFF_TYPE
Integer representation of an Amount Off discount |
static java.lang.String |
CLASS_VERSION
Class version string |
protected static int |
FIXED_PRICE_TYPE
Integer representation of a Fixed Price discount |
protected static int |
ILLEGAL_TYPE
Integer representation of an illegal discount type. |
protected PromotionTools |
mPromotionTools
Utility service to help with processing promotion items |
protected static int |
PERCENT_OFF_TYPE
Integer representation of a Percent Off discount |
Fields inherited from class atg.nucleus.GenericService |
---|
SERVICE_INFO_KEY |
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging |
---|
DEFAULT_LOG_TRACE_STATUS |
Fields inherited from interface atg.nucleus.logging.ApplicationLogging |
---|
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS |
Constructor Summary | |
---|---|
DiscountCalculatorService()
Constructs a new DiscountCalculatorService |
Method Summary | |
---|---|
protected double |
adjust(double pAmount,
double pAdjuster,
java.lang.String pDiscountType,
java.lang.String pId)
Returns the input pAmount adjusted by the input pAdjuster in the manner specified by pDiscountType. |
protected double |
adjustAmount(double pAmount,
double pAdjuster,
java.lang.String pDiscountType)
|
protected double |
getAdjuster(RepositoryItem pPricingModel,
java.util.Map pExtraParameters)
Determines the amount of adjustment to apply. |
protected java.lang.String |
getDiscountType(RepositoryItem pPricingModel,
java.util.Map pExtraParameters)
Determines the discount type to apply. |
protected int |
getDiscountType(java.lang.String pDiscountType)
Returns the int discount type for the string discount type provided. |
PricingModelProperties |
getPricingModelProperties()
Get property PricingModelProperties |
PromotionTools |
getPromotionTools()
Get property PromotionTools |
Qualifier |
getQualifierService()
Get property QualifierService |
protected Qualifier |
getQualifierService(RepositoryItem pPricingModel,
java.util.Map pExtraParameters)
Gets the Qualifier service this calculator should use to process promotions. |
boolean |
isNegativeAmountException()
Get property negativeAmountException. |
void |
setNegativeAmountException(boolean pNegativeAmountException)
|
void |
setPricingModelProperties(PricingModelProperties pPricingModelProperties)
Set property PricingModelProperties |
void |
setPromotionTools(PromotionTools pPromotionTools)
Set property PromotionTools |
void |
setQualifierService(Qualifier pQualifierService)
Set property QualifierService |
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl |
---|
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String CLASS_VERSION
protected static final int ILLEGAL_TYPE
protected static final int AMOUNT_OFF_TYPE
protected static final int PERCENT_OFF_TYPE
protected static final int FIXED_PRICE_TYPE
protected static final int AMOUNT_INCREASE_TYPE
protected PromotionTools mPromotionTools
Constructor Detail |
---|
public DiscountCalculatorService()
Method Detail |
---|
public void setQualifierService(Qualifier pQualifierService)
pQualifierService
- new value to setpublic Qualifier getQualifierService()
public void setPromotionTools(PromotionTools pPromotionTools)
pPromotionTools
- new value to setpublic PromotionTools getPromotionTools()
public void setPricingModelProperties(PricingModelProperties pPricingModelProperties)
pPricingModelProperties
- new value to setpublic PricingModelProperties getPricingModelProperties()
public void setNegativeAmountException(boolean pNegativeAmountException)
public boolean isNegativeAmountException()
protected int getDiscountType(java.lang.String pDiscountType)
pDiscountType
-
FIXED_PRICE_TYPE
,
AMOUNT_OFF_TYPE
,
PERCENT_OFF_TYPE
,
AMOUNT_INCREASE_TYPE
protected double adjust(double pAmount, double pAdjuster, java.lang.String pDiscountType, java.lang.String pId) throws PricingException
If pAmount is 30, pAdjuster is 10, and pDiscountType is "amountOff", then the amount 30 will have the fixed amount 10 subtracted from it to produce a result of 20.
pAmount
- The amount to adjustpAdjuster
- The adjustment parameter, used according to the pDiscountTypepDiscountType
- The manner in which pAmount should be adjusted by pAdjuster.pId
- An identifier to associate with this operation if an expception is thrown or a warning logged
PricingException
- if there was a problem finding the adjusted price.protected double adjustAmount(double pAmount, double pAdjuster, java.lang.String pDiscountType) throws PricingException
PricingException
protected double getAdjuster(RepositoryItem pPricingModel, java.util.Map pExtraParameters) throws PricingException
pPricingModel
- RepositoryItem pricing modelpExtraParameters
- Map of optional extra parameters, may be null
PricingException
- if the method fails to get a valid double adjusterprotected java.lang.String getDiscountType(RepositoryItem pPricingModel, java.util.Map pExtraParameters) throws PricingException
pPricingModel
- RepositoryItem pricing modelpExtraParameters
- Map of optional extra parameters
PricingException
- if the method fails to determine a valid discount type.protected Qualifier getQualifierService(RepositoryItem pPricingModel, java.util.Map pExtraParameters)
pPricingModel
- pExtraParameters
-
PromotionTools.getQualifierService(RepositoryItem, Map, Qualifier)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |