atg.commerce.pricing
Class OrderSubtotalCalculator

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.commerce.pricing.OrderSubtotalCalculator
All Implemented Interfaces:
OrderPricingCalculator, 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 OrderSubtotalCalculator
extends GenericService
implements OrderPricingCalculator

Computes the rawSubtotal and amount of an OrderPriceInfo that corresponds to the input Order. Unlike the many discount calculators, there is no rule that determines whether the subtotal should be calculated. The Order's subtotal is always calculated by adding up the amounts of the ItemPriceInfos that the order contains. If a pricing model (discount) is passed in, it is ignored.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
static java.lang.String DETAILED_ITEM_PRICE_AMOUNT_PROPERTY
           
 
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
OrderSubtotalCalculator()
           
 
Method Summary
protected  double calculatePriceFromOrderItems(Order pOrder)
          calculates a price from the sum of the order's item prices
protected  double calculateShippingGroupSubtotal(OrderPriceInfo pPriceQuote, Order pOrder, ShippingGroup pShippingGroup, java.util.Map pItemQuantities, java.util.Map pItemPrices, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          This method calculates the subtotal of the shipping group.
 void doStartService()
          Overrides GenericService's doStartService method to check for null properties
 OrderManager getOrderManager()
          order manager to consult for various order-related functions
 PricingTools getPricingTools()
          the PricingTools service to consult for pricing help
 void priceOrder(OrderPriceInfo pPriceQuote, Order pOrder, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Price a single order within a context.
 void setOrderManager(OrderManager pOrderManager)
          order manager to consult for various order-related functions
 void setPricingTools(PricingTools pPricingTools)
          the PricingTools service to consult for pricing help
 
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 final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values

DETAILED_ITEM_PRICE_AMOUNT_PROPERTY

public static final java.lang.String DETAILED_ITEM_PRICE_AMOUNT_PROPERTY
See Also:
Constant Field Values
Constructor Detail

OrderSubtotalCalculator

public OrderSubtotalCalculator()
Method Detail

setPricingTools

public void setPricingTools(PricingTools pPricingTools)
the PricingTools service to consult for pricing help

Parameters:
pPricingTools - new value to set

getPricingTools

public PricingTools getPricingTools()
the PricingTools service to consult for pricing help

Returns:
property PricingTools

setOrderManager

public void setOrderManager(OrderManager pOrderManager)
order manager to consult for various order-related functions

Parameters:
pOrderManager - new value to set

getOrderManager

public OrderManager getOrderManager()
order manager to consult for various order-related functions

Returns:
property OrderManager

priceOrder

public void priceOrder(OrderPriceInfo pPriceQuote,
                       Order pOrder,
                       RepositoryItem pPricingModel,
                       java.util.Locale pLocale,
                       RepositoryItem pProfile,
                       java.util.Map pExtraParameters)
                throws PricingException
Price a single order within a context. This implementation simply calculates the subtotal of the order by adding the cost of each item in the order.

Specified by:
priceOrder in interface OrderPricingCalculator
Parameters:
pPriceQuote - OrderPriceInfo representing the current price quote for the order
pOrder - The order to price
pPricingModel - A RepositoryItems representing a PricingModel
pProfile - The user's profile
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null
Throws:
PricingException
See Also:
atg.commerce.pricing.PricingTools.#isShippingSubtotalUsesAverageItemPrice

calculatePriceFromOrderItems

protected double calculatePriceFromOrderItems(Order pOrder)
calculates a price from the sum of the order's item prices

Parameters:
pOrder - the order whose item prices will be summed
Returns:
the sum of the input order's item prices

calculateShippingGroupSubtotal

protected double calculateShippingGroupSubtotal(OrderPriceInfo pPriceQuote,
                                                Order pOrder,
                                                ShippingGroup pShippingGroup,
                                                java.util.Map pItemQuantities,
                                                java.util.Map pItemPrices,
                                                java.util.Locale pLocale,
                                                RepositoryItem pProfile,
                                                java.util.Map pExtraParameters)
                                         throws PricingException
This method calculates the subtotal of the shipping group. This method will return the subtotal of the items contained within this shipping group. In addition it will modify the given pPriceQuote (the Order's price info) so the following properties include a new entry for pShippingGroup:
   shippingItemsSubtotalPriceInfos
   taxableShippingItemsSubtotalPriceInfos
   nonTaxableShippingItemsSubtotalPriceInfos
 

Parameters:
pPriceQuote - The price info for the order
pOrder - The order containing the shipping group
pShippingGroup - The shipping group being priced
pItemQuantities - A map mapping a commerce item to a quantity. The incoming quantity will be the total quantity of that item that has been included in the subtotal of other shipping groups. The quantity will be increased by the quantity contained in pShippingGroup
pItemPrices - A map mapping a commerce item to a price. The price is the total price of the item that has been included in the subtotals of other shipping groups. Once the pItemQuantities for a given item is reached this value is used to resolve any potential rounding errors. The pItemPrices for a particular item will be increased by the price of the item that pShippingGroup's subtotal used.
pLocale - The locale in which all pricing operations should be performed
pProfile - The owner of pOrder
pExtraParameters - Any extra processing information. Unused by this method.
Returns:
The subtotal of pShippingGroup (this is the sum of the prices of the items contained within the shipping group)
Throws:
PricingException

doStartService

public void doStartService()
                    throws ServiceException
Overrides GenericService's doStartService method to check for null properties

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if a required property is null.