atg.commerce.pricing
Class DiscountCalculatorService

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.pricing.DiscountCalculatorService
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener
Direct Known Subclasses:
ItemDiscountCalculator, OrderDiscountCalculator, ShippingDiscountCalculator, TaxDiscountCalculator

public class DiscountCalculatorService
extends GenericService

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:

See Also:
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 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  int getDiscountType(java.lang.String pDiscountType)
          Returns the int discount type for the string discount type provided.
 PricingModelProperties getPricingModelProperties()
          Get property PricingModelProperties
 Qualifier getQualifierService()
          Get property QualifierService
 boolean isNegativeAmountException()
          Get property negativeAmountException.
 void setNegativeAmountException(boolean pNegativeAmountException)
           
 void setPricingModelProperties(PricingModelProperties pPricingModelProperties)
          Set property PricingModelProperties
 void setQualifierService(Qualifier pQualifierService)
          Set property QualifierService
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
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

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string


ILLEGAL_TYPE

protected static final int ILLEGAL_TYPE
Integer representation of an illegal discount type. An illegal type is defined as being not one of the valid types below

See Also:
Constant Field Values

AMOUNT_OFF_TYPE

protected static final int AMOUNT_OFF_TYPE
Integer representation of an Amount Off discount

See Also:
Constant Field Values

PERCENT_OFF_TYPE

protected static final int PERCENT_OFF_TYPE
Integer representation of a Percent Off discount

See Also:
Constant Field Values

FIXED_PRICE_TYPE

protected static final int FIXED_PRICE_TYPE
Integer representation of a Fixed Price discount

See Also:
Constant Field Values

AMOUNT_INCREASE_TYPE

protected static final int AMOUNT_INCREASE_TYPE
Integer representation of an Amount Increase adjustment

See Also:
Constant Field Values
Constructor Detail

DiscountCalculatorService

public DiscountCalculatorService()
Constructs a new DiscountCalculatorService

Method Detail

setQualifierService

public void setQualifierService(Qualifier pQualifierService)
Set property QualifierService

Parameters:
pQualifierService - new value to set

getQualifierService

public Qualifier getQualifierService()
Get property QualifierService

Returns:
property QualifierService

setPricingModelProperties

public void setPricingModelProperties(PricingModelProperties pPricingModelProperties)
Set property PricingModelProperties

Parameters:
pPricingModelProperties - new value to set

getPricingModelProperties

public PricingModelProperties getPricingModelProperties()
Get property PricingModelProperties

Returns:
PricingModelProperties

setNegativeAmountException

public void setNegativeAmountException(boolean pNegativeAmountException)

isNegativeAmountException

public boolean isNegativeAmountException()
Get property negativeAmountException. If negativeAmountException is true and a discount causes the amount to be negative throw an exception, otherwise log a warning message and set the amount to 0.0. The default is false

Returns:
property NegativeAmountException

getDiscountType

protected int getDiscountType(java.lang.String pDiscountType)
Returns the int discount type for the string discount type provided.

Parameters:
pDiscountType -
Returns:
int discount type
See Also:
FIXED_PRICE_TYPE, AMOUNT_OFF_TYPE, PERCENT_OFF_TYPE, AMOUNT_INCREASE_TYPE

adjust

protected double adjust(double pAmount,
                        double pAdjuster,
                        java.lang.String pDiscountType,
                        java.lang.String pId)
                 throws PricingException
Returns the input pAmount adjusted by the input pAdjuster in the manner specified by pDiscountType. For example:

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.

Parameters:
pAmount - The amount to adjust
pAdjuster - The adjustment parameter, used according to the pDiscountType
pDiscountType - 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
Returns:
The adjusted amount
Throws:
PricingException - if there was a problem finding the adjusted price.

adjustAmount

protected double adjustAmount(double pAmount,
                              double pAdjuster,
                              java.lang.String pDiscountType)
                       throws PricingException
Throws:
PricingException