atg.commerce.pricing
Class OrderDiscountCalculator

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.OrderDiscountCalculator
All Implemented Interfaces:
OrderPricingCalculator, 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
Direct Known Subclasses:
BulkOrderDiscountCalculator, ExchangeOrderDiscountCalculator, atg.commerce.pricing.OrderAdjustmentCalculator

public class OrderDiscountCalculator
extends DiscountCalculatorService
implements OrderPricingCalculator

Calculates OrderPriceInfos for Orders which the calculator is given. This calculator can either be passed in a MatchingObject via the extra parameters map with key Constants.MATCHING_OBJECT containing the order that qualified for the promotion or it can consult the Qualifier service, looking for the Order to be priced. It calls Qualifier.findQualifyingOrder for this purpose.

If it obtains an Order that qualified then it can determine the discount either via a DiscountStructure object being passed into the calculator via the extra parameters map with key Constants.DISCOUNT_STRUCTURE or by getting the discountType and adjuster properties of the input PricingModel (RepositoryItem).

See Also:
Qualifier

Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
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
OrderDiscountCalculator()
           
 
Method Summary
protected  double adjustOrderSubTotal(double pOrderSubTotal, double pAdjuster, java.lang.String pDiscountType, java.lang.String pOrderId, RepositoryItem pPricingModel, java.util.Map pExtraParameters)
          Applies the given adjuster to the given order subtotal.
protected  void adjustShippingGroupSubtotalPriceInfos(java.lang.String pDetailSharePropertyName, OrderPriceInfo pPriceQuote, Order pOrder, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters, java.util.Map pTaxableShareOffsets, java.util.Map pNonTaxableShareOffsets)
          Adjusts the shipping group taxable, nontaxable and subtotal OrderPriceInfos based on the share value stored on the item level DetailedItemPriceInfo objects.
protected  double applyAdjustmentToNonTaxablePriceInfo(OrderPriceInfo pNonTaxablePriceIno, double pShareAmount)
          Adjusts the shipping non-taxable total price info based on the given order discount share value.
protected  double applyAdjustmentToSubtotalPriceInfo(OrderPriceInfo pShippingTotalPriceInfo, double pShareAmount)
          Adjusts the shipping group total price info based on the given order discount share value.
protected  double applyAdjustmentToTaxablePriceInfo(OrderPriceInfo pTaxablePriceInfo, double pShareAmount)
          Adjusts the shipping taxable total price info based on the given order discount share value.
protected  double computeGroupSubtotal(long pTimesToDiscount, int pNumberOfGroups, double pGroupSubTotal, double pAdjuster, java.lang.String pDiscountType, java.lang.String pId)
          Deprecated.  
protected  double computeGroupSubtotal(long pTimesToDiscount, int pNumberOfGroups, double pGroupSubTotal, double pAdjuster, java.lang.String pDiscountType, java.lang.String pOrderId, double pOldOrderAmount)
          Deprecated.  
protected  double computeGroupSubtotal(long pTimesToDiscount, int pNumberOfGroups, double pGroupSubTotal, double pAdjuster, java.lang.String pDiscountType, java.lang.String pOrderId, double pOldOrderAmount, double pNewOrderAmount, RepositoryItem pPricingModel, java.util.Map pExtraParameters)
          Deprecated. in favor of adjustShippingGroupSubtotalPriceInfos(String, OrderPriceInfo, Order, Locale, RepositoryItem, Map, Map, Map)
protected  java.util.Map createCurrentShareMap(java.lang.String pDetailSharePropertyName, boolean pTaxable, OrderPriceInfo pPriceQuote, Order pOrder, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Creates a Map containing the shipping group id to its current discount share amount.
 void doStartService()
          This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values.
protected  MatchingObject findMatchingObject(OrderPriceInfo pPriceQuote, java.util.List pPriceQuotes, java.util.List pItems, RepositoryItem pPricingModel, RepositoryItem pProfile, java.util.Locale pLocale, Order pOrder, java.util.Map pExtraParameters)
          This method determines if the order qualifies for the given order promotion.
protected  double getAmountToDiscount(OrderPriceInfo pPriceQuote, Order pOrder, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          This will return the amount that will eventually be discounted.
protected  double getAmountToDiscount(OrderPriceInfo pPriceQuote, Order pOrder, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters, double pNonDiscountableTotal)
          This will return the amount that will eventually be discounted.
protected  java.util.List getDetailsToReceiveDiscountShare(ItemPriceInfo pItemPriceInfo)
          This will return the price details in an item price info that will be marked as receiving a share of the order discount.
protected  java.util.List getItemsToReceiveDiscountShare(Order pOrder)
          This will return the items in an order that will be marked as receiving a share of the order discount.
 double getNonDiscountableTotal(Order pOrder, java.util.Map pExtraParametersMap)
          This method will get the items from the Order, iterate over them checking if the item is discountable or not.
protected  double getNonTaxableShippingGroupTotal(OrderPriceInfo pOrderPriceInfo)
          Returns the total of the NonTaxableShippingItemsSubtotalPriceInfos in the given OrderPriceInfo
 PricingTools getPricingTools()
          pricing tools to help with calculating prices
protected  double getTaxableShippingGroupTotal(OrderPriceInfo pOrderPriceInfo)
          Returns the total of the TaxableShippingItemsSubtotalPriceInfos in the given OrderPriceInfo
protected  double getTotalForShippingGroups(java.util.Map pOrderPriceInfos)
          Returns the total of the OrderPriceInfos in the map
protected  double getTotalShareValueForShippingGroup(ShippingGroup pShippingGroup, boolean pTaxable, java.lang.String pDetailSharePropertyName, OrderPriceInfo pOrderPriceInfo, Order pOrder, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters)
          Returns the total share value for all items in the shipping group by totaling the given share property on the item level DetailedItemPriceInfo objects.
 boolean isSaveDetailsOrderDiscountShare()
          Deprecated. this property configuration is not used. Discount share values are always calculated
 boolean isSaveItemsOrderDiscountShare()
          Deprecated. this property configuration is not used. Discount share values are always calculated
 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 defined by the input parameters.
 void setPricingTools(PricingTools pPricingTools)
          pricing tools to help with calculating prices
 void setSaveDetailsOrderDiscountShare(boolean pSaveDetailsOrderDiscountShare)
           
 void setSaveItemsOrderDiscountShare(boolean pSaveItemsOrderDiscountShare)
           
protected  void updateItemsDiscountShare(Order pOrder, double pUnadjustedPrice, double pTotalAdjustment, double pAdjuster, java.lang.String pDiscountType, long pTimesToDiscount)
          Deprecated.  
protected  void updateItemsDiscountShare(Order pOrder, double pUnadjustedPrice, double pTotalAdjustment, double pAdjuster, java.lang.String pDiscountType, long pTimesToDiscount, java.util.Map pExtraParameters)
          This method will set the orderDiscountShare property of each CommerceItem's priceInfo.
protected  double updateShippingItemsSubtotalMaps(double pOrderSubTotal, double pOldOrderAmount, MatchingObject pQualifier, double pAdjuster, java.lang.String pDiscountType, OrderPriceInfo pPriceQuote, Order pOrder, RepositoryItem pPricingModel, java.util.Map pExtraParameters)
          Deprecated. in favor of {@link #adjustShippingGroupSubtotalPriceInfos(String, OrderPriceInfo, Order, Locale, RepositoryItem, Map, Map, Map)
 
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 java.lang.String CLASS_VERSION
Class version string

Constructor Detail

OrderDiscountCalculator

public OrderDiscountCalculator()
Method Detail

setPricingTools

public void setPricingTools(PricingTools pPricingTools)
pricing tools to help with calculating prices

Parameters:
pPricingTools - new value to set

getPricingTools

public PricingTools getPricingTools()
pricing tools to help with calculating prices

Returns:
property PricingTools

setSaveItemsOrderDiscountShare

public void setSaveItemsOrderDiscountShare(boolean pSaveItemsOrderDiscountShare)

isSaveItemsOrderDiscountShare

public boolean isSaveItemsOrderDiscountShare()
Deprecated. this property configuration is not used. Discount share values are always calculated

If this is true, update itemPriceInfo.orderDiscountShare


setSaveDetailsOrderDiscountShare

public void setSaveDetailsOrderDiscountShare(boolean pSaveDetailsOrderDiscountShare)

isSaveDetailsOrderDiscountShare

public boolean isSaveDetailsOrderDiscountShare()
Deprecated. this property configuration is not used. Discount share values are always calculated

If this is true, update itemPriceInfo.orderDiscountShare


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 defined by the input parameters. The order's price is adjusted as well as the shipping group subtotals.

The order can be passed in within a MatchingObject via the pExtraParameters map with key Constants.MATCHING_OBJECT. If this is not the case then it will call findMatchingObject to try and obtain the MatchingObject from the qualifier service.

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:
updateItemsDiscountShare(Order, double, double, double, String, long), adjustShippingGroupSubtotalPriceInfos(String, OrderPriceInfo, Order, Locale, RepositoryItem, Map, Map, Map)

createCurrentShareMap

protected java.util.Map createCurrentShareMap(java.lang.String pDetailSharePropertyName,
                                              boolean pTaxable,
                                              OrderPriceInfo pPriceQuote,
                                              Order pOrder,
                                              java.util.Locale pLocale,
                                              RepositoryItem pProfile,
                                              java.util.Map pExtraParameters)
                                       throws PricingException
Creates a Map containing the shipping group id to its current discount share amount.

Parameters:
pDetailSharePropertyName - the property name on the DetailedItemPriceInfo containing the share value
pTaxable - true for taxable share total or false for non-taxable share total.
pPriceQuote - the new OrderPriceInfo for the order being priced
pOrder - the order being priced
pLocale - the user's display locale
pProfile - the order's owning profile
pExtraParameters -
Returns:
the share total
Throws:
PricingException

adjustShippingGroupSubtotalPriceInfos

protected void adjustShippingGroupSubtotalPriceInfos(java.lang.String pDetailSharePropertyName,
                                                     OrderPriceInfo pPriceQuote,
                                                     Order pOrder,
                                                     java.util.Locale pLocale,
                                                     RepositoryItem pProfile,
                                                     java.util.Map pExtraParameters,
                                                     java.util.Map pTaxableShareOffsets,
                                                     java.util.Map pNonTaxableShareOffsets)
                                              throws PricingException
Adjusts the shipping group taxable, nontaxable and subtotal OrderPriceInfos based on the share value stored on the item level DetailedItemPriceInfo objects. The item level share value must be previously calculated for proper adjustments to be made.

In addition to adjusting the taxable, nontaxable and subtotal OrderPriceInfo, a PricingAdjustment is added for the adjusted value.

Parameters:
pDetailSharePropertyName - the property name on the DetailedItemPriceInfo where the share value is stored.
pPriceQuote - the price info from the order that is being discounted
pOrder - the order being discounted
pLocale - the user's display locale.
pProfile - the order's owning profile.
pTaxableShareOffsets - Optional. Map containing the taxable share value for each shipping group. This value is used to offset the current taxable share to determine the share value added during this iteration.
pNonTaxableShareOffsets - Optional. Map containing the non-taxable share value for each shipping group. This value is used to offset the current taxable share to determine the share value added during this iteration.
pExtraParameters - the extra parameter Map for the current pricing operation.
Throws:
PricingException
See Also:
getTotalShareValueForShippingGroup(ShippingGroup, boolean, String, OrderPriceInfo, Order, Locale, RepositoryItem, Map), applyAdjustmentToNonTaxablePriceInfo(OrderPriceInfo, double), applyAdjustmentToTaxablePriceInfo(OrderPriceInfo, double), applyAdjustmentToSubtotalPriceInfo(OrderPriceInfo, double)

applyAdjustmentToTaxablePriceInfo

protected double applyAdjustmentToTaxablePriceInfo(OrderPriceInfo pTaxablePriceInfo,
                                                   double pShareAmount)
Adjusts the shipping taxable total price info based on the given order discount share value.

Parameters:
pTaxablePriceInfo -
pShareAmount - total share amount for which to apply the adjustment
Returns:
the new amount for the taxable price info

applyAdjustmentToNonTaxablePriceInfo

protected double applyAdjustmentToNonTaxablePriceInfo(OrderPriceInfo pNonTaxablePriceIno,
                                                      double pShareAmount)
Adjusts the shipping non-taxable total price info based on the given order discount share value.

Parameters:
pNonTaxablePriceIno -
pShareAmount - total share amount for which to apply the adjustment
Returns:
the new amount for the non-taxable price info

applyAdjustmentToSubtotalPriceInfo

protected double applyAdjustmentToSubtotalPriceInfo(OrderPriceInfo pShippingTotalPriceInfo,
                                                    double pShareAmount)
Adjusts the shipping group total price info based on the given order discount share value.

Parameters:
pShippingTotalPriceInfo -
pShareAmount - total share amount for which to apply the adjustment
Returns:
the new amount for the shipping total price info

getTotalShareValueForShippingGroup

protected double getTotalShareValueForShippingGroup(ShippingGroup pShippingGroup,
                                                    boolean pTaxable,
                                                    java.lang.String pDetailSharePropertyName,
                                                    OrderPriceInfo pOrderPriceInfo,
                                                    Order pOrder,
                                                    java.util.Locale pLocale,
                                                    RepositoryItem pProfile,
                                                    java.util.Map pExtraParameters)
                                             throws PricingException
Returns the total share value for all items in the shipping group by totaling the given share property on the item level DetailedItemPriceInfo objects.

Parameters:
pShippingGroup - the shipping group for which to get the total share value.
pTaxable - true to return the taxable share total, false for non-taxable share total.
pDetailSharePropertyName - the property name on the DetailedItemPriceInfo that contains the share amount.
pOrderPriceInfo - OrderPriceInfo representing the current price quote for the order
pOrder - The order being priced
pLocale - the user's display locale
pProfile - The user's profile
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null
Returns:
the total share value.
Throws:
PricingException
See Also:
PricingTools.isTaxable(CommerceItem, ItemPriceInfo, OrderPriceInfo, Order, ShippingPriceInfo, ShippingGroup, Locale, RepositoryItem, Map)

getNonDiscountableTotal

public double getNonDiscountableTotal(Order pOrder,
                                      java.util.Map pExtraParametersMap)
This method will get the items from the Order, iterate over them checking if the item is discountable or not. Based on this value it will update (or not) the non-discountable total.

Parameters:
pOrder - The order that contains the items to iterate over
pExtraParametersMap - A Map of extra parameters
Returns:
The combined total for the non-discountable items

computeGroupSubtotal

protected double computeGroupSubtotal(long pTimesToDiscount,
                                      int pNumberOfGroups,
                                      double pGroupSubTotal,
                                      double pAdjuster,
                                      java.lang.String pDiscountType,
                                      java.lang.String pOrderId,
                                      double pOldOrderAmount,
                                      double pNewOrderAmount,
                                      RepositoryItem pPricingModel,
                                      java.util.Map pExtraParameters)
                               throws PricingException
Deprecated. in favor of adjustShippingGroupSubtotalPriceInfos(String, OrderPriceInfo, Order, Locale, RepositoryItem, Map, Map, Map)

Computes a shippinggroup subtotal based on the type of discount given. The logic is as follows:

If functionality other than that described above, this method can be overridden to do that which is necessary. For example, rather than spreading out amount off discounts across all shippingGroups, some implementations might want the first ShippingGroup to get the full benefit of the discount.

Parameters:
pTimesToDiscount - the number of times we should apply the configured discount
pNumberOfGroups - the number of groups in the order, including the one for which this method is computing a subtotal
pGroupSubTotal - is the subtotal that needs adjusting
pAdjuster - is the amount by which to adjust pGroupSubTotal
pDiscountType - the way in which pAdjuster is applied to pGroupSubTotal. May be one of: "Fixed Price", "Amount Off", or "Percent Off".
pOrderId - an ID to associate with this adjustment for error reporting
pOldOrderAmount - the order subtotal before this discount was applied at the order level
pNewOrderAmount - the order subtotal after this discount was applied at the order level
pPricingModel - the order promotion that's being applied
pExtraParameters - the extra parameter map originally passed into the pricing operation.
Returns:
the adjusted subtotal for the input pGroupSubTotal
Throws:
PricingException - if there was a problem computing the group subtotal

adjustOrderSubTotal

protected double adjustOrderSubTotal(double pOrderSubTotal,
                                     double pAdjuster,
                                     java.lang.String pDiscountType,
                                     java.lang.String pOrderId,
                                     RepositoryItem pPricingModel,
                                     java.util.Map pExtraParameters)
                              throws PricingException
Applies the given adjuster to the given order subtotal.

Parameters:
pOrderSubTotal - the order's current subtotal
pAdjuster - the pricing model's adjuster
pDiscountType - the pricing models discount type
pOrderId - the id of the order to which the adjustment is beig made
pPricingModel - the order promotion repository item
pExtraParameters - the original extra parameter map passed to the pricing operation.
Returns:
the new, calculated order subtotal.
Throws:
PricingException
See Also:
DiscountCalculatorService.adjust(double, double, String, String)

findMatchingObject

protected MatchingObject findMatchingObject(OrderPriceInfo pPriceQuote,
                                            java.util.List pPriceQuotes,
                                            java.util.List pItems,
                                            RepositoryItem pPricingModel,
                                            RepositoryItem pProfile,
                                            java.util.Locale pLocale,
                                            Order pOrder,
                                            java.util.Map pExtraParameters)
                                     throws PricingException
This method determines if the order qualifies for the given order promotion.

It determines this by calling the QualifierService

Parameters:
pPriceQuote -
pPriceQuotes -
pItems -
pPricingModel -
pProfile -
pLocale -
pOrder -
pExtraParameters -
Returns:
Throws:
PricingException
See Also:
Qualifier.findQualifyingOrder(List, List, RepositoryItem, RepositoryItem, Locale, Order, OrderPriceInfo, ShippingGroup, ShippingPriceInfo, Map)

updateShippingItemsSubtotalMaps

protected double updateShippingItemsSubtotalMaps(double pOrderSubTotal,
                                                 double pOldOrderAmount,
                                                 MatchingObject pQualifier,
                                                 double pAdjuster,
                                                 java.lang.String pDiscountType,
                                                 OrderPriceInfo pPriceQuote,
                                                 Order pOrder,
                                                 RepositoryItem pPricingModel,
                                                 java.util.Map pExtraParameters)
                                          throws PricingException
Deprecated. in favor of {@link #adjustShippingGroupSubtotalPriceInfos(String, OrderPriceInfo, Order, Locale, RepositoryItem, Map, Map, Map)

These method will iterate through each of the maps in the OrderPriceInfo that contain shipping group subtotal information. These include: For each of entry in each of these maps, computeGroupSubtotal is called. The amount of the price info in the entry is set to this value, the info is marked discounted, and a new adjustement is added to the info

Parameters:
pOrderSubTotal - The new subtotal of the order
pOldOrderAmount - The previous subtotal of the order
pQualifier - The MatchingObject as returned by Qualifier.evaluateQualifier
pAdjuster - The adjuster of the promotion
pDiscountType - The type of discount being given
pPriceQuote - The order's price info
pOrder - The order that was discounted
pPricingModel - The promotion that changed the price of the order
pExtraParameters - Any extra parameters
Returns:
The new subtotal of the order. This is the sum of the shipping group subtotals and should match pOrderSubTotal
Throws:
PricingException

computeGroupSubtotal

protected double computeGroupSubtotal(long pTimesToDiscount,
                                      int pNumberOfGroups,
                                      double pGroupSubTotal,
                                      double pAdjuster,
                                      java.lang.String pDiscountType,
                                      java.lang.String pId)
                               throws PricingException
Deprecated. 

Computes a shippinggroup subtotal based on the type of discount given. The logic is as follows:

If functionality other than that described above, this method can be overridden to do that which is necessary. For example, rather than spreading out amount off discounts across all shippingGroups, some implementations might want the first ShippingGroup to get the full benefit of the discount.

Parameters:
pTimesToDiscount - the number of times we should apply the configured discount
pNumberOfGroups - the number of groups in the order, including the one for which this method is computing a subtotal
pGroupSubTotal - is the subtotal that needs adjusting
pAdjuster - is the amount by which to adjust pGroupSubTotal
pDiscountType - the way in which pAdjuster is applied to pGroupSubTotal. May be one of: "Fixed Price", "Amount Off", or "Percent Off".
pId - an ID to associate with this adjustment for error reporting
Returns:
the adjusted subtotal for the input pGroupSubTotal
Throws:
PricingException - if there was a problem computing the group subtotal
See Also:
adjustShippingGroupSubtotalPriceInfos(String, OrderPriceInfo, Order, Locale, RepositoryItem, Map, Map, Map)

getTaxableShippingGroupTotal

protected double getTaxableShippingGroupTotal(OrderPriceInfo pOrderPriceInfo)
Returns the total of the TaxableShippingItemsSubtotalPriceInfos in the given OrderPriceInfo

Parameters:
pOrderPriceInfo -
Returns:
total

getNonTaxableShippingGroupTotal

protected double getNonTaxableShippingGroupTotal(OrderPriceInfo pOrderPriceInfo)
Returns the total of the NonTaxableShippingItemsSubtotalPriceInfos in the given OrderPriceInfo

Parameters:
pOrderPriceInfo -
Returns:
total

getTotalForShippingGroups

protected double getTotalForShippingGroups(java.util.Map pOrderPriceInfos)
Returns the total of the OrderPriceInfos in the map

Parameters:
pOrderPriceInfos -
Returns:

computeGroupSubtotal

protected double computeGroupSubtotal(long pTimesToDiscount,
                                      int pNumberOfGroups,
                                      double pGroupSubTotal,
                                      double pAdjuster,
                                      java.lang.String pDiscountType,
                                      java.lang.String pOrderId,
                                      double pOldOrderAmount)
                               throws PricingException
Deprecated. 

Throws:
PricingException
See Also:
computeGroupSubtotal(long, int, double, double, String, String, double, double, RepositoryItem, Map)

updateItemsDiscountShare

protected void updateItemsDiscountShare(Order pOrder,
                                        double pUnadjustedPrice,
                                        double pTotalAdjustment,
                                        double pAdjuster,
                                        java.lang.String pDiscountType,
                                        long pTimesToDiscount)
                                 throws PricingException
Deprecated. 

Throws:
PricingException
See Also:
updateItemsDiscountShare(Order, double, double, double, String, long, Map)

updateItemsDiscountShare

protected void updateItemsDiscountShare(Order pOrder,
                                        double pUnadjustedPrice,
                                        double pTotalAdjustment,
                                        double pAdjuster,
                                        java.lang.String pDiscountType,
                                        long pTimesToDiscount,
                                        java.util.Map pExtraParameters)
                                 throws PricingException
This method will set the orderDiscountShare property of each CommerceItem's priceInfo.

Parameters:
pOrder - the order that was discounted
pUnadjustedPrice - The original pre-discount price of the order
pTotalAdjustment - This is the total change to the order total, for the current promotion
pAdjuster - The size of the discount
pDiscountType - the way in which pAdjuster is applied to pGroupSubTotal. May be one of: "Fixed Price", "Amount Off", or "Percent Off".
pTimesToDiscount - The number of times to apply the given discount
pExtraParameters - Any extra parameters
Throws:
PricingException

getAmountToDiscount

protected double getAmountToDiscount(OrderPriceInfo pPriceQuote,
                                     Order pOrder,
                                     RepositoryItem pPricingModel,
                                     java.util.Locale pLocale,
                                     RepositoryItem pProfile,
                                     java.util.Map pExtraParameters)
                              throws PricingException
This will return the amount that will eventually be discounted. This will be priceQuote.amount by default (and there will usually be no need to change this.)

Parameters:
pPriceQuote - OrderPriceInfo representing the current price quote for the order
pOrder - The order that will be discounted (ignored by default)
pPricingModel - A RepositoryItems representing a PricingModel (ignored by default)
pProfile - The user's profile (ignored by default)
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null (ignored by default)
Returns:
The amount to discount... defaults to pPriceQuote.getAmount()
Throws:
PricingException

getAmountToDiscount

protected double getAmountToDiscount(OrderPriceInfo pPriceQuote,
                                     Order pOrder,
                                     RepositoryItem pPricingModel,
                                     java.util.Locale pLocale,
                                     RepositoryItem pProfile,
                                     java.util.Map pExtraParameters,
                                     double pNonDiscountableTotal)
                              throws PricingException
This will return the amount that will eventually be discounted. This will be priceQuote.amount by default (and there will usually be no need to change this.)

Parameters:
pPriceQuote - OrderPriceInfo representing the current price quote for the order
pOrder - The order that will be discounted (ignored by default)
pPricingModel - A RepositoryItems representing a PricingModel (ignored by default)
pProfile - The user's profile (ignored by default)
pExtraParameters - A Map of extra parameters to be used in the pricing, may be null (ignored by default)
pNonDiscountableTotal - the non discountable total for the order
Returns:
The amount to discount... defaults to pPriceQuote.getAmount()
Throws:
PricingException

getDetailsToReceiveDiscountShare

protected java.util.List getDetailsToReceiveDiscountShare(ItemPriceInfo pItemPriceInfo)
This will return the price details in an item price info that will be marked as receiving a share of the order discount. This will be all price details with a non-zero amount.

Parameters:
pItemPriceInfo - The item price info
Returns:
The list of items to be marked for receiving a share of the order discount
See Also:
DetailedItemPriceTools.getDetailsToReceiveDiscountShare(ItemPriceInfo, Range)

getItemsToReceiveDiscountShare

protected java.util.List getItemsToReceiveDiscountShare(Order pOrder)
This will return the items in an order that will be marked as receiving a share of the order discount. Only items that are discountable and have a non zero price will be returned.

Parameters:
pOrder - The order that will be discounted
Returns:
The list of items to be marked for receiving a share of the order discount

doStartService

public void doStartService()
                    throws ServiceException
Description copied from class: GenericService
This is called after a Service has been created, placed into the naming hierarchy, and initialized with its configured property values. The Service should override this method to start any processes it requires.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up