|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object atg.nucleus.logging.VariableArgumentApplicationLoggingImpl atg.nucleus.GenericService atg.commerce.pricing.DiscountCalculatorService atg.commerce.pricing.OrderDiscountCalculator
public class OrderDiscountCalculator
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).
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 double |
computeGroupSubtotal(long pTimesToDiscount,
int pNumberOfGroups,
double pGroupSubTotal,
double pAdjuster,
java.lang.String pDiscountType,
java.lang.String pId)
Computes a shippinggroup subtotal based on the type of discount given. |
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)
Computes a shippinggroup subtotal based on the type of discount given. |
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 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. |
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 |
boolean |
isSaveDetailsOrderDiscountShare()
If this is true, update itemPriceInfo.orderDiscountShare |
boolean |
isSaveItemsOrderDiscountShare()
If this is true, update itemPriceInfo.orderDiscountShare |
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)
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)
These method will iterate through each of the maps in the OrderPriceInfo that contain shipping group subtotal information. |
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.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 |
---|
public static java.lang.String CLASS_VERSION
Constructor Detail |
---|
public OrderDiscountCalculator()
Method Detail |
---|
public void setPricingTools(PricingTools pPricingTools)
pPricingTools
- new value to setpublic PricingTools getPricingTools()
public void setSaveItemsOrderDiscountShare(boolean pSaveItemsOrderDiscountShare)
public boolean isSaveItemsOrderDiscountShare()
public void setSaveDetailsOrderDiscountShare(boolean pSaveDetailsOrderDiscountShare)
public boolean isSaveDetailsOrderDiscountShare()
public void priceOrder(OrderPriceInfo pPriceQuote, Order pOrder, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters) throws PricingException
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.
priceOrder
in interface OrderPricingCalculator
pPriceQuote
- OrderPriceInfo representing the current price quote for the orderpOrder
- The order to pricepPricingModel
- A RepositoryItems representing a PricingModelpProfile
- The user's profilepExtraParameters
- A Map of extra parameters to be used in the pricing, may be null
PricingException
updateShippingItemsSubtotalMaps(double, double, atg.commerce.pricing.definition.MatchingObject, double, java.lang.String, atg.commerce.pricing.OrderPriceInfo, atg.commerce.order.Order, atg.repository.RepositoryItem, java.util.Map)
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
pTimesToDiscount
- the number of times we should apply the configured discountpNumberOfGroups
- the number of groups in the order, including the one for which
this method is computing a subtotalpGroupSubTotal
- is the subtotal that needs adjustingpAdjuster
- is the amount by which to adjust pGroupSubTotalpDiscountType
- 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 reportingpOldOrderAmount
- the order subtotal before this discount was applied at the order levelpNewOrderAmount
- the order subtotal after this discount was applied at the order levelpPricingModel
- the order promotion that's being appliedpExtraParameters
- the extra parameter map originally passed into the pricing operation.
PricingException
- if there was a problem computing the group subtotalprotected double adjustOrderSubTotal(double pOrderSubTotal, double pAdjuster, java.lang.String pDiscountType, java.lang.String pOrderId, RepositoryItem pPricingModel, java.util.Map pExtraParameters) throws PricingException
pOrderSubTotal
- the order's current subtotalpAdjuster
- the pricing model's adjusterpDiscountType
- the pricing models discount typepOrderId
- the id of the order to which the adjustment is beig madepPricingModel
- the order promotion repository itempExtraParameters
- the original extra parameter map passed to the pricing operation.
PricingException
DiscountCalculatorService.adjust(double, double, String, String)
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
It determines this by calling the QualifierService
pPriceQuote
- pPriceQuotes
- pItems
- pPricingModel
- pProfile
- pLocale
- pOrder
- pExtraParameters
-
PricingException
Qualifier.findQualifyingOrder(List, List, RepositoryItem, RepositoryItem, Locale, Order, OrderPriceInfo, ShippingGroup, ShippingPriceInfo, Map)
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
taxableShippingItemsSubtotalPriceInfos
nonTaxableShippingItemsSubtotalPriceInfos
shippingItemsSubtotalPriceInfos
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
pOrderSubTotal
- The new subtotal of the orderpOldOrderAmount
- The previous subtotal of the orderpQualifier
- The MatchingObject as returned by Qualifier.evaluateQualifierpAdjuster
- The adjuster of the promotionpDiscountType
- The type of discount being givenpPriceQuote
- The order's price infopOrder
- The order that was discountedpPricingModel
- The promotion that changed the price of the orderpExtraParameters
- Any extra parameters
PricingException
protected double computeGroupSubtotal(long pTimesToDiscount, int pNumberOfGroups, double pGroupSubTotal, double pAdjuster, java.lang.String pDiscountType, java.lang.String pId) throws PricingException
pTimesToDiscount
- the number of times we should apply the configured discountpNumberOfGroups
- the number of groups in the order, including the one for which
this method is computing a subtotalpGroupSubTotal
- is the subtotal that needs adjustingpAdjuster
- is the amount by which to adjust pGroupSubTotalpDiscountType
- 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
PricingException
- if there was a problem computing the group subtotalprotected double getTaxableShippingGroupTotal(OrderPriceInfo pOrderPriceInfo)
pOrderPriceInfo
-
protected double getNonTaxableShippingGroupTotal(OrderPriceInfo pOrderPriceInfo)
pOrderPriceInfo
-
protected double getTotalForShippingGroups(java.util.Map pOrderPriceInfos)
pShippingGroupPriceInfos
-
protected double computeGroupSubtotal(long pTimesToDiscount, int pNumberOfGroups, double pGroupSubTotal, double pAdjuster, java.lang.String pDiscountType, java.lang.String pOrderId, double pOldOrderAmount) throws PricingException
PricingException
computeGroupSubtotal(long, int, double, double, String, String, double, double, RepositoryItem, Map)
protected void updateItemsDiscountShare(Order pOrder, double pUnadjustedPrice, double pTotalAdjustment, double pAdjuster, java.lang.String pDiscountType, long pTimesToDiscount) throws PricingException
saveItemsOrderDiscountShare
is true. If saveDetailsOrderDiscountShare
is true, then the
orderDiscountShare property of each DetailedItemPriceInfo is also updated.
pOrder
- the order that was discountedpUnadjustedPrice
- The original pre-discount price of the orderpTotalAdjustment
- This is the total change to the order total, for the current promotionpAdjuster
- The size of the discountpDiscountType
- 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
PricingException
protected double getAmountToDiscount(OrderPriceInfo pPriceQuote, Order pOrder, RepositoryItem pPricingModel, java.util.Locale pLocale, RepositoryItem pProfile, java.util.Map pExtraParameters) throws PricingException
pPriceQuote
- OrderPriceInfo representing the current price quote for the orderpOrder
- 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)
PricingException
protected java.util.List getDetailsToReceiveDiscountShare(ItemPriceInfo pItemPriceInfo)
pItemPriceInfo
- The item price info
DetailedItemPriceTools.getDetailsToReceiveDiscountShare(ItemPriceInfo, Range)
protected java.util.List getItemsToReceiveDiscountShare(Order pOrder)
pOrder
- The order that will be discounted
public void doStartService() throws ServiceException
GenericService
doStartService
in class GenericService
ServiceException
- if the Service had a problem starting up
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |