com.konakart.bl.modules.ordertotal.productdiscount
Class ProductDiscount

java.lang.Object
  extended by com.konakart.bl.modules.BaseModule
      extended by com.konakart.bl.modules.ordertotal.BaseOrderTotalModule
          extended by com.konakart.bl.modules.ordertotal.productdiscount.ProductDiscount
All Implemented Interfaces:
OrderTotalInterface

public class ProductDiscount
extends BaseOrderTotalModule
implements OrderTotalInterface

Module that creates an OrderTotal object for applying a percentage discount or an amount discount on a single product normally because of a certain quantity is being purchased. The discount may be applied on prices before or after tax. The promotion may be activated on a product only if:

There may be multiple valid promotions applicable for an order. If this is the case, the logic applied is the following: All cumulative promotions are summed into one order total object. Then we loop through the order total objects and choose the one that offers the largest discount.


Nested Class Summary
protected  class ProductDiscount.StaticData
          Used to store the static data of this module
 
Field Summary
 
Fields inherited from class com.konakart.bl.modules.ordertotal.BaseOrderTotalModule
log, orderTotalList
 
Fields inherited from class com.konakart.bl.modules.BaseModule
basePackage
 
Constructor Summary
ProductDiscount(KKEngIf eng)
          Constructor
 
Method Summary
 java.lang.String getCode()
           
 OrderTotal getOrderTotal(Order order, boolean dispPriceWithTax, java.util.Locale locale)
          Create and return an OrderTotal object for the discount amount.
 PromotionResult getPromotionResult(Product product, Promotion promotion)
          Returns an object containing the promotion discount.
 int getSortOrder()
           
 boolean isAvailable()
          Returns true or false
 void setStaticVariables()
          Sets some static variables during setup
 
Methods inherited from class com.konakart.bl.modules.ordertotal.BaseOrderTotalModule
getCustomBigDecimal, getCustomBoolean, getCustomInt, getCustomString, getDiscountOrderTotalFromList, getOrderTotalList, setOrderTotalList
 
Methods inherited from class com.konakart.bl.modules.BaseModule
getBasketMgr, getCatMgr, getConfigMgr, getCurrMgr, getCustMgr, getEmailMgr, getEng, getLangMgr, getMultiStoreMgr, getOrderMgr, getOrderTotalMgr, getPaymentMgr, getProdMgr, getPromMgr, getResourceBundle, getRewardPointMgr, getSecMgr, getShippingMgr, getSolrMgr, getStoreId, getTaxMgr, init, isAvailable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.konakart.bl.modules.ordertotal.OrderTotalInterface
getOrderTotalList, setOrderTotalList
 

Constructor Detail

ProductDiscount

public ProductDiscount(KKEngIf eng)
                throws org.apache.torque.TorqueException,
                       KKException,
                       com.workingdogs.village.DataSetException
Constructor

Parameters:
eng -
Throws:
com.workingdogs.village.DataSetException
KKException
org.apache.torque.TorqueException
Method Detail

setStaticVariables

public void setStaticVariables()
                        throws KKException
Sets some static variables during setup

Specified by:
setStaticVariables in interface OrderTotalInterface
Throws:
KKException

isAvailable

public boolean isAvailable()
                    throws KKException
Returns true or false

Specified by:
isAvailable in interface OrderTotalInterface
Returns:
True or False
Throws:
KKException

getOrderTotal

public OrderTotal getOrderTotal(Order order,
                                boolean dispPriceWithTax,
                                java.util.Locale locale)
                         throws java.lang.Exception
Create and return an OrderTotal object for the discount amount. *

Custom field usage:

If the promotion applies to multiple products, we create an array of order total objects and attach the array to the order total that we return (ot.setOrderTotals(otArray)). The reason for doing this is to get a line item of the order for each discounted product. We still need to populate the order total that we return with the total discount amount because this will be used to compare this promotion with other promotions in order to decide which one to use.

Specified by:
getOrderTotal in interface OrderTotalInterface
Parameters:
order -
dispPriceWithTax -
locale -
Returns:
Returns an OrderTotal object for this module
Throws:
java.lang.Exception

getPromotionResult

public PromotionResult getPromotionResult(Product product,
                                          Promotion promotion)
                                   throws java.lang.Exception
Returns an object containing the promotion discount. This method is used to apply the promotion to a single product.

Specified by:
getPromotionResult in interface OrderTotalInterface
Overrides:
getPromotionResult in class BaseOrderTotalModule
Parameters:
product -
promotion -
Returns:
Returns a PromotionResult object
Throws:
java.lang.Exception

getSortOrder

public int getSortOrder()
Specified by:
getSortOrder in interface OrderTotalInterface
Returns:
Return the order in which the module gets called and displayed

getCode

public java.lang.String getCode()
Specified by:
getCode in interface OrderTotalInterface
Returns:
Returns the code for the module


Copyright © 2011 DS Data Systems UK Ltd.