atg.commerce.pricing.priceLists
Class ItemSalesTieredPriceCalculator

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.pricing.priceLists.ItemSalesTieredPriceCalculator
All Implemented Interfaces:
ItemPriceSourceHandler, ItemSchemePriceCalculator, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class ItemSalesTieredPriceCalculator
extends GenericService
implements ItemSchemePriceCalculator, ItemPriceSourceHandler

A calculator which determines the sales tiered price of an item and sets the itemPriceInfo to be that amount.

The definition of tiered pricing can be referenced in ItemTieredPriceCalculator

See Also:
ItemTieredPriceCalculator

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
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
ItemSalesTieredPriceCalculator()
           
 
Method Summary
protected  void addToSalesLevel(long pQuantity, double pTotal, java.util.List pSalesLevel)
           
protected  java.util.List adjustmentDetailedItemPriceInfo(DetailedItemPriceInfo pOldItemPriceInfo, java.util.List pSalesLevel, java.util.List pAdjustments)
          Sets the DetailedItemPriceInfo for its ItemPriceInfo.
 ItemPriceSource getItemPriceSource(ItemPriceInfo pPriceQuote, CommerceItem pItem, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          This method is called by the calculator to return the ItemPriceSource that should be used to price the given CommerceItem
protected  double getListTotalForRange(java.util.List pListLevels, long pStartRange, long pEndRange)
          Using the given levels for list prices, returns the total list price for the given range.
 java.lang.String getPriceLevelPropertyName()
          the name of the property for the PriceLevel
 java.util.List getPriceLevels(ItemPriceSource pItemPriceSource, RepositoryItem pPrice, ItemPriceInfo pPriceQuote, CommerceItem pItem, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          This method is called by the calculator to provide the List of priceLevel repository items used to price the given commerce item.
 java.lang.String getPricePropertyName()
          the name of the property for the price of each price level
 PricingTools getPricingTools()
          pricing tools to help with price calculation
 java.lang.String getQuantityPropertyName()
          the name of the property for the quantity of each price level
 java.lang.String getSalesComplexPricePropertyName()
          the name of the property for the SalesComplexPrice
 boolean populateItemPriceSource(ItemPriceSource pItemPriceSource, Order pOrder, CommerceItem pCommerceItem, CommerceItem pParentCommerceItem, java.util.Map pExtraParameters)
          Generates the ItemPriceSource saleVolumeLevels based on the PricingAdjustments added by this calculator to the given CommerceItem.
 void priceItem(RepositoryItem pPrice, ItemPriceInfo pPriceQuote, CommerceItem pItem, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Sets the tiered price with the given determined price.
 void setPriceLevelPropertyName(java.lang.String pPriceLevelPropertyName)
          the name of the property for the PriceLevel
 void setPricePropertyName(java.lang.String pPricePropertyName)
          the name of the property for the price of each price level
 void setPricingTools(PricingTools pPricingTools)
          pricing tools to help with price calculation
 void setQuantityPropertyName(java.lang.String pQuantityPropertyName)
          the name of the property for the quantity of each price level
 void setSalesComplexPricePropertyName(java.lang.String pSalesComplexPricePropertyName)
          the name of the property for the SalesComplexPrice
 boolean shouldConsumeSource(ItemPriceSource pItemPriceSource)
          This implementation is only here to satisfy the interface.
 
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, reResolveThis, 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

ItemSalesTieredPriceCalculator

public ItemSalesTieredPriceCalculator()
Method Detail

setPricingTools

public void setPricingTools(PricingTools pPricingTools)
pricing tools to help with price calculation

Parameters:
pPricingTools - new value to set

getPricingTools

public PricingTools getPricingTools()
pricing tools to help with price calculation

Returns:
property PricingTools

setSalesComplexPricePropertyName

public void setSalesComplexPricePropertyName(java.lang.String pSalesComplexPricePropertyName)
the name of the property for the SalesComplexPrice

Parameters:
pSalesComplexPricePropertyName - new value to set

getSalesComplexPricePropertyName

public java.lang.String getSalesComplexPricePropertyName()
the name of the property for the SalesComplexPrice

Returns:
property SalesComplexPricePropertyName

setPriceLevelPropertyName

public void setPriceLevelPropertyName(java.lang.String pPriceLevelPropertyName)
the name of the property for the PriceLevel

Parameters:
pPriceLevelPropertyName - new value to set

getPriceLevelPropertyName

public java.lang.String getPriceLevelPropertyName()
the name of the property for the PriceLevel

Returns:
property PriceLevelPropertyName

setQuantityPropertyName

public void setQuantityPropertyName(java.lang.String pQuantityPropertyName)
the name of the property for the quantity of each price level

Parameters:
pQuantityPropertyName - new value to set

getQuantityPropertyName

public java.lang.String getQuantityPropertyName()
the name of the property for the quantity of each price level

Returns:
property QuantityPropertyName

setPricePropertyName

public void setPricePropertyName(java.lang.String pPricePropertyName)
the name of the property for the price of each price level

Parameters:
pPricePropertyName - new value to set

getPricePropertyName

public java.lang.String getPricePropertyName()
the name of the property for the price of each price level

Returns:
property PricePropertyName

addToSalesLevel

protected void addToSalesLevel(long pQuantity,
                               double pTotal,
                               java.util.List pSalesLevel)

adjustmentDetailedItemPriceInfo

protected java.util.List adjustmentDetailedItemPriceInfo(DetailedItemPriceInfo pOldItemPriceInfo,
                                                         java.util.List pSalesLevel,
                                                         java.util.List pAdjustments)
Sets the DetailedItemPriceInfo for its ItemPriceInfo. This will split the price info if necessary. (Possibly more than once.) Depending on how the new tiers compare to the range of the incoming detail.

Parameters:
pQuantity - The quantity to set in the DetailedItemPriceInfo
pTotal - The total amount to set in the DetailedItemPriceInfo
pPriceQuote - ItemPriceInfo representing the current price quote for the item
pDetailList - The list of DetailedItemPriceInfo for the current ItemPriceInfo
pAdjustments - The list of PriceAdjustment for the current ItemPriceInfo
Returns:
Any newly created DetailedItemPriceInfos

priceItem

public void priceItem(RepositoryItem pPrice,
                      ItemPriceInfo pPriceQuote,
                      CommerceItem pItem,
                      RepositoryItem pPricingModel,
                      java.util.Locale pLocale,
                      RepositoryItem pProfile,
                      java.util.Map pExtraParameters)
               throws PricingException
Sets the tiered price with the given determined price.

This method calls getPriceLevels to determine the list of price levels that should be used to price the item.

Specified by:
priceItem in interface ItemSchemePriceCalculator
Parameters:
pPrice - the price as extracted from the PriceList
pPriceQuote - ItemPriceInfo representing the current price quote for the item
pItem - The item to price
pPricingModel - A RepositoryItem representing a PricingModel
pLocale - the locale in which this item should be priced
pProfile - The user's profile
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null
Throws:
PricingException - if there was a problem pricing the input pItem
See Also:
#getPriceLevels(RepositoryItem, ItemPriceInfo, CommerceItem, RepositoryItem, Locale, RepositoryItem, Map)

getPriceLevels

public java.util.List getPriceLevels(ItemPriceSource pItemPriceSource,
                                     RepositoryItem pPrice,
                                     ItemPriceInfo pPriceQuote,
                                     CommerceItem pItem,
                                     RepositoryItem pPricingModel,
                                     java.util.Locale pLocale,
                                     RepositoryItem pProfile,
                                     java.util.Map pExtraParameters)
                              throws PricingException
This method is called by the calculator to provide the List of priceLevel repository items used to price the given commerce item.

This method first checks for a ItemPriceSource and returns its sale volume levels. Otherwise, it returns the levels from the given price repository item.

Parameters:
pItemPriceSource - the ItemPriceSource that is being use to price the item. The value can be null when no source is being used.
pPrice - the price object found for the item. This value can be null when a price source is being used.
pPriceQuote - the current price info
pItem - the item being priced
pPricingModel -
pLocale -
pProfile -
pExtraParameters - the extra parameter map
Returns:
the List of priceLevel repository items
Throws:
PricingException

getItemPriceSource

public ItemPriceSource getItemPriceSource(ItemPriceInfo pPriceQuote,
                                          CommerceItem pItem,
                                          RepositoryItem pPricingModel,
                                          java.util.Locale pLocale,
                                          RepositoryItem pProfile,
                                          java.util.Map pExtraParameters)
This method is called by the calculator to return the ItemPriceSource that should be used to price the given CommerceItem

Specified by:
getItemPriceSource in interface ItemPriceSourceHandler
Parameters:
pPriceQuote - the new ItemPriceInfo for that's being generated in the pricing operation
pItem - the commerce item that's being priced
pPricingModel - the current pricing model
pLocale - the locale
pProfile - the customer profile reference
pExtraParameters - the extra parameter map passed to the pricing operation.
Returns:
If not null, the ItemPriceSource that should be used to price the item.
See Also:
PricingTools.getItemPriceSource(ItemPriceInfo, CommerceItem, RepositoryItem, Locale, RepositoryItem, Map)

populateItemPriceSource

public boolean populateItemPriceSource(ItemPriceSource pItemPriceSource,
                                       Order pOrder,
                                       CommerceItem pCommerceItem,
                                       CommerceItem pParentCommerceItem,
                                       java.util.Map pExtraParameters)
Generates the ItemPriceSource saleVolumeLevels based on the PricingAdjustments added by this calculator to the given CommerceItem. The PricingAdjustments are used to reverse engineer the levels used to originally price the item. Note that the levels can only be determined up to the last one used to originally price the item.

Specified by:
populateItemPriceSource in interface ItemPriceSourceHandler
Parameters:
pItemPriceSource - the source being generated and populated with pricing data.
pOrder - the Order
pCommerceItem - the item for which the source is being created
pParentCommerceItem - the item that contained pCommerceItem
pExtraParameters - a Map of extra parameters objects that was passed to the initial call to generate the source objects.
Returns:
return true if any of the ItemPriceSource properties were updated

getListTotalForRange

protected double getListTotalForRange(java.util.List pListLevels,
                                      long pStartRange,
                                      long pEndRange)
Using the given levels for list prices, returns the total list price for the given range.

This method is used when reverse engineering the sale calculator adjustments into the original tier levels.

Since the adjustment values added by the sale calculator are relative to the list cost, the list must be known to calculate the sale tier price.

Parameters:
pListLevels - the list price levels
pStartRange - the start of the range for which the total list price is determined
pEndRange - the end of the range for which the total list price is determine
Returns:
the total list cost for the given range

shouldConsumeSource

public boolean shouldConsumeSource(ItemPriceSource pItemPriceSource)
This implementation is only here to satisfy the interface. It is not actually called by the calculator since the parent price list calculator decides which scheme calculator should price the item based on the priceListScheme in the ItemPriceSource

Specified by:
shouldConsumeSource in interface ItemPriceSourceHandler