atg.projects.b2cstore
Class ItemDiscountMultiplierCalculator

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.pricing.DiscountCalculatorService
              extended by atg.commerce.pricing.ItemDiscountCalculator
                  extended by atg.projects.b2cstore.ItemDiscountMultiplierCalculator
All Implemented Interfaces:
ItemPricingCalculator, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class ItemDiscountMultiplierCalculator
extends ItemDiscountCalculator

This calculator knows how to adjust the amount of a discount by factor N, where N is the adjuster amount as defined in a PricingModel. That is, if an item originally costs $20, and has had $5 taken off of the price for whatever reason, then the new price is $15. The ItemDiscountMultiplierCalculator takes this amount and multiplies it by the number N. So, if the number N is 2, then the new discount amount would be $10 and the new price would also be $10.

The parent class, ItemDiscountCalculator is used to determine which items should qualify for getting a double discount and then the overriden adjust method defined in this class applies determines the new adjustment.

See Also:
DiscountCalculatorService

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.commerce.pricing.ItemDiscountCalculator
EXTRA_PARAM_QUALIFIERSERVICE
 
Fields inherited from class atg.commerce.pricing.DiscountCalculatorService
AMOUNT_INCREASE_TYPE, AMOUNT_OFF_TYPE, FIXED_PRICE_TYPE, ILLEGAL_TYPE, PERCENT_OFF_TYPE
 
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
ItemDiscountMultiplierCalculator()
          Empty Constructor
 
Method Summary
protected  double adjust(double pCurrentPrice, double pDiscountAmount, double pAdjuster, java.lang.String pId)
          Adjust the price of an item.
 double findAdjustedPrice(DetailedItemPriceInfo pDetailedItemPriceInfo, java.util.List pPriceQuotes, java.util.List pItems, RepositoryItem pPricingModel, RepositoryItem pProfile, java.util.Locale pLocale, Order pOrder, java.util.Map pExtraParameters)
          Override the findAdjustedPrice to enable us to provide different parameters to the adjust() method of this function.
 
Methods inherited from class atg.commerce.pricing.ItemDiscountCalculator
determineDiscountNumber, doStartService, findQualifyingItems, getAmountToDiscount, getPricingTools, getRangeComparator, priceDetailedItemPriceInfo, priceEachItem, priceItem, priceItems, priceQualifyingItem, priceQualifyingItems, setPricingTools, setRangeComparator, updateDetailedPriceInfos
 
Methods inherited from class atg.commerce.pricing.DiscountCalculatorService
adjust, adjustAmount, getDiscountType, getPricingModelProperties, getQualifierService, isNegativeAmountException, setNegativeAmountException, setPricingModelProperties, setQualifierService
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, 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

Constructor Detail

ItemDiscountMultiplierCalculator

public ItemDiscountMultiplierCalculator()
Empty Constructor

Method Detail

findAdjustedPrice

public double findAdjustedPrice(DetailedItemPriceInfo pDetailedItemPriceInfo,
                                java.util.List pPriceQuotes,
                                java.util.List pItems,
                                RepositoryItem pPricingModel,
                                RepositoryItem pProfile,
                                java.util.Locale pLocale,
                                Order pOrder,
                                java.util.Map pExtraParameters)
                         throws PricingException
Override the findAdjustedPrice to enable us to provide different parameters to the adjust() method of this function. Specifically, the adjust funcion needs:

The amout that the DetailedItemPriceInfo has been discounted thus far is determined by iterating through the List of adjustments and retrieving their amounts.

Overrides:
findAdjustedPrice in class ItemDiscountCalculator
Parameters:
pDetailedItemPriceInfo - the details on the item being priced
pPriceQuotes - list of itemPriceInfo
pItems - list of commerceItems
pPricingModel - pricing model being used to calculate price
pProfile - users profile, not used here
pLocale - users locale, not used here
pOrder - users order, not used here
pExtraParameters - map of extra params, not used here
Returns:
a value of type 'double'
Throws:
PricingException - if an error occurs

adjust

protected double adjust(double pCurrentPrice,
                        double pDiscountAmount,
                        double pAdjuster,
                        java.lang.String pId)
                 throws PricingException
Adjust the price of an item. This method overrides the adjust method by calculating the price of an item in a new manner. It determines a new adjusted price by multiplying the previous adjusted amount by the adjuster amount specified in the PricingModel. This amount is then subtracted from the original price and returned to the calling method.

Parameters:
pCurrentPrice - the current price of the item
pDiscountAmount - the amount the item has been discounted thus far
pAdjuster - the adjuster for this discount
pId - the commerce id of the item
Returns:
a value of type 'double'
Throws:
PricingException - if there was a problem in adjusting the current price