atg.commerce.pricing
Class GWPDiscountCalculator

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.commerce.pricing.GWPDiscountCalculator
All Implemented Interfaces:
CalculatorInfoProvider, ItemPricingCalculator, atg.naming.AbsoluteNameable, NameContextBindingListener, NameContextElement, atg.naming.NameContextParentable, NameResolver, AdminableService, atg.nucleus.Configured, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class GWPDiscountCalculator
extends ItemDiscountCalculator
implements CalculatorInfoProvider

GWP calculator to target items to make free and also to generate GWPInfo objects so free items can be auto added to the cart.


Nested Class Summary
static class GWPDiscountCalculator.GWP_GIFT_TYPES
           
 
Field Summary
static java.lang.String AUTO_REMOVE_ATTRIBUTE
           
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String DISCOUNT_DETAIL_NAME
           
static java.lang.String GIFT_DETAIL_ATTRIBUTE
           
static java.lang.String GIFT_TYPE_ATTRIBUTE
           
static java.lang.String GWP_CALCULATOR_TYPE
           
static java.lang.String GWP_GIFT_TYPE_CATEGORY
           
static java.lang.String GWP_GIFT_TYPE_PRODUCT
           
static java.lang.String GWP_GIFT_TYPE_PRODUCT_CONTENT_GROUP
           
static java.lang.String GWP_GIFT_TYPE_SKU
           
static java.lang.String GWP_GIFT_TYPE_SKU_CONTENT_GROUP
           
protected  atg.commerce.promotion.GWPMarkerManager mGwpMarkerManager
           
static java.lang.String QUANTITY_ATTRIBUTE
           
 
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, mPromotionTools, 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
GWPDiscountCalculator()
           
 
Method Summary
protected  long determineNextRangeMap(QualifiedItem pQualifiedItem, long pQuantity, PricingContext pPricingContext, java.util.Map pExtraParametersMap)
          Updates the given qualified item detail map to apply the given quantity of discount.
 CalculatorInfo getCalculatorInfo()
          Allows a calculator provide it's own CalculatorInfo
 atg.commerce.promotion.GWPMarkerManager getGwpMarkerManager()
          Getter for the GWP marker manager
protected  long getQualifiedItemQuantity(QualifiedItem pQualifiedItem, int pDetailIndex)
          Method to get the total discountable quantity of a qualified item for this detail index
 void priceItems(java.util.List pPriceQuotes, java.util.List pItems, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, Order pOrder, java.util.Map pExtraParameters)
          If called with a null pricing model then it applies a zero fixed price
adjustment to make any GWP quantity free on the item.
 void setGwpMarkerManager(atg.commerce.promotion.GWPMarkerManager pGwpMarkerManager)
          Setter for the GWP marker manager
 
Methods inherited from class atg.commerce.pricing.ItemDiscountCalculator
determineDiscountNumber, doStartService, findAdjustedPrice, findQualifyingItems, getAmountToDiscount, getPricingTools, getRangeComparator, priceDetailedItemPriceInfo, priceEachItem, priceItem, priceQualifyingItem, priceQualifyingItems, setPricingTools, setRangeComparator, updateDetailedPriceInfos, updateQualifyingDetails, updateQuantityAsQualifier, validateQualifierService
 
Methods inherited from class atg.commerce.pricing.DiscountCalculatorService
adjust, adjustAmount, getAdjuster, getDiscountType, getDiscountType, getPricingModelProperties, getPromotionTools, getQualifierService, getQualifierService, isNegativeAmountException, setNegativeAmountException, setPricingModelProperties, setPromotionTools, setQualifierService
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, 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 final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values

GWP_CALCULATOR_TYPE

public static final java.lang.String GWP_CALCULATOR_TYPE
See Also:
Constant Field Values

DISCOUNT_DETAIL_NAME

public static final java.lang.String DISCOUNT_DETAIL_NAME
See Also:
Constant Field Values

AUTO_REMOVE_ATTRIBUTE

public static final java.lang.String AUTO_REMOVE_ATTRIBUTE
See Also:
Constant Field Values

QUANTITY_ATTRIBUTE

public static final java.lang.String QUANTITY_ATTRIBUTE
See Also:
Constant Field Values

GIFT_TYPE_ATTRIBUTE

public static final java.lang.String GIFT_TYPE_ATTRIBUTE
See Also:
Constant Field Values

GIFT_DETAIL_ATTRIBUTE

public static final java.lang.String GIFT_DETAIL_ATTRIBUTE
See Also:
Constant Field Values

GWP_GIFT_TYPE_SKU

public static final java.lang.String GWP_GIFT_TYPE_SKU
See Also:
Constant Field Values

GWP_GIFT_TYPE_PRODUCT

public static final java.lang.String GWP_GIFT_TYPE_PRODUCT
See Also:
Constant Field Values

GWP_GIFT_TYPE_CATEGORY

public static final java.lang.String GWP_GIFT_TYPE_CATEGORY
See Also:
Constant Field Values

GWP_GIFT_TYPE_SKU_CONTENT_GROUP

public static final java.lang.String GWP_GIFT_TYPE_SKU_CONTENT_GROUP
See Also:
Constant Field Values

GWP_GIFT_TYPE_PRODUCT_CONTENT_GROUP

public static final java.lang.String GWP_GIFT_TYPE_PRODUCT_CONTENT_GROUP
See Also:
Constant Field Values

mGwpMarkerManager

protected atg.commerce.promotion.GWPMarkerManager mGwpMarkerManager
Constructor Detail

GWPDiscountCalculator

public GWPDiscountCalculator()
Method Detail

getGwpMarkerManager

public atg.commerce.promotion.GWPMarkerManager getGwpMarkerManager()
Getter for the GWP marker manager

Returns:
GWPMarkerManager

setGwpMarkerManager

public void setGwpMarkerManager(atg.commerce.promotion.GWPMarkerManager pGwpMarkerManager)
Setter for the GWP marker manager

Parameters:
pItemMarkerManager - GWPMarkerManager

priceItems

public void priceItems(java.util.List pPriceQuotes,
                       java.util.List pItems,
                       RepositoryItem pPricingModel,
                       java.util.Locale pLocale,
                       RepositoryItem pProfile,
                       Order pOrder,
                       java.util.Map pExtraParameters)
                throws PricingException
If called with a null pricing model then it applies a zero fixed price
adjustment to make any GWP quantity free on the item.
Only applies for automatic or selected GWP quantity.

It is expected that pricing model will be null if called as a pre-calculator.

Specified by:
priceItems in interface ItemPricingCalculator
Overrides:
priceItems in class ItemDiscountCalculator
Parameters:
pPriceQuotes - List of ItemPriceInfo with latest price details for the item
pItems - List of CommerceItem being priced
pPricingModel - RepositoryItem promotion, may be null
pLocale - Locale for pricing
pProfile - Profile for pricing
pOrder - Order for pricing
pExtraParameters - Optional Map of extra parameters
Throws:
PricingException - for problems during pricing

determineNextRangeMap

protected long determineNextRangeMap(QualifiedItem pQualifiedItem,
                                     long pQuantity,
                                     PricingContext pPricingContext,
                                     java.util.Map pExtraParametersMap)
                              throws PricingException
Updates the given qualified item detail map to apply the given quantity of discount.
Uses the Qualifier service to filter quantity not valid to be discounted.
Returns any discount quantity that could not be mapped.

Parameters:
pQualifiedItem - QualifiedItem containing the discount details
pQuantity - long quantity to discount
pPricingContext - PricingContext for this pricing operation
pExtraParametersMap - Optional Map of extra parameters
Returns:
quantity that was not available for discount
Throws:
PricingException

getQualifiedItemQuantity

protected long getQualifiedItemQuantity(QualifiedItem pQualifiedItem,
                                        int pDetailIndex)
Method to get the total discountable quantity of a qualified item for this detail index

Parameters:
pQualifiedItem - QualifiedItem to check
pDetailIndex - int detail index
Returns:
long quantity

getCalculatorInfo

public CalculatorInfo getCalculatorInfo()
Description copied from interface: CalculatorInfoProvider
Allows a calculator provide it's own CalculatorInfo

Specified by:
getCalculatorInfo in interface CalculatorInfoProvider
Returns:
CalculatorInfo