public class BaseOrderTotalModule extends BaseModule
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
log
The
Log instance for this application. |
protected java.util.List<OrderTotal> |
orderTotalList
A list of the current order totals so that an order total module can modify an order total
that was previously called.
|
basePackage, debugStackTraceExclusions
Constructor and Description |
---|
BaseOrderTotalModule() |
Modifier and Type | Method and Description |
---|---|
protected java.math.BigDecimal |
addTax(java.math.BigDecimal value,
java.math.BigDecimal taxRate,
int scale)
Utility method to add tax to a value
|
void |
commitOrder(OrderIf order)
Commit the Order transaction.
|
protected java.math.BigDecimal |
getCustomBigDecimal(java.lang.String customAttr,
int customId)
Utility method that gets a BigDecimal from one of the promotion custom attributes
|
protected boolean |
getCustomBoolean(java.lang.String customAttr,
int customId)
Utility method that gets a boolean from one of the promotion custom attributes
|
protected int |
getCustomInt(java.lang.String customAttr,
int customId)
Utility method that gets an int from one of the promotion custom attributes
|
protected java.lang.String |
getCustomString(java.lang.String customAttr,
int customId)
Utility method that gets a String from one of the promotion custom attributes.
|
protected OrderTotal |
getDiscountOrderTotalFromList(Order order,
java.util.List<OrderTotal> orderTotalsList)
This is a helper method for the discount modules.
|
protected OrderTotal |
getDiscountOrderTotalFromList(Order order,
java.util.List<OrderTotal> orderTotalsList,
boolean applyBeforeTax)
This is a helper method for the discount modules.
|
java.util.List<OrderTotal> |
getOrderTotalList()
A list of the current order totals so that an order total module can modify an order total
that was previously called.
|
PromotionResult |
getPromotionResult(Product product,
Promotion promotion)
Returns an object containing the promotion discount
|
java.math.BigDecimal |
getTaxForDiscount(Order order,
java.math.BigDecimal discount,
int scale,
boolean applyBeforeTax)
Method used to calculate the tax portion of a discount based on the average tax rate of the
order which needs to be calculated.
|
java.math.BigDecimal |
getTaxFromTotal(java.math.BigDecimal total,
java.math.BigDecimal taxRate,
int scale)
The total is the total value including tax.
|
protected void |
removeCouponId(Order order,
java.lang.String couponId)
Removes the coupon id from an order if it exists
|
protected void |
removePromotionId(Order order,
java.lang.String promotionId)
Removes the promotion id from an order if it exists
|
protected java.math.BigDecimal |
removeTax(java.math.BigDecimal value,
java.math.BigDecimal taxRate,
int scale)
Utility method to remove tax from a value
|
protected void |
setCouponIds(Order order,
java.lang.String couponIds)
Sets the coupon ids of an order taking care not to overwrite the existing ones
|
void |
setOrderTotalList(java.util.List<OrderTotal> orderTotalList)
A list of the current order totals so that an order total module can modify an order total
that was previously called.
|
protected void |
setPromotionIds(Order order,
java.lang.String promotionIds)
Sets the promotion ids of an order taking care not to overwrite the existing ones
|
protected void |
setRefundValues(Order order,
OrderTotal ot,
boolean applyBeforeTax)
Modifies the refund values on the order total objects based on the promotion.
|
protected void |
setRefundValuesForSingleOrderTotal(Order order,
OrderTotal ot,
boolean applyBeforeTax,
int scale)
Modifies the refund values on a single order total object based on the promotion.
|
getBasketMgr, getCatMgr, getConfigMgr, getConfiguration, getConfigurationValue, getConfigurationValueAsBigDecimalWithDefault, getConfigurationValueAsBool, getConfigurationValueAsIntWithDefault, getCurrMgr, getCustMgr, getCustTagMgr, getDebugStackTraceExclusions, getEmailMgr, getEng, getLangMgr, getModuleClassName, getMultiStoreMgr, getNewCriteria, getOrderMgr, getOrderTotalMgr, getPaymentMgr, getProdMgr, getPromMgr, getRandomText, getRandomText, getResourceBundle, getRewardPointMgr, getSecMgr, getShippingMgr, getSolrMgr, getStoreId, getStoreMgr, getTaxMgr, getZoneCodeForZoneName, init, isAvailable, isAvailable, isMultiStoreShareCustomersOrProducts, setDebugStackTraceExclusions, updateStaticVariablesNow
protected org.apache.commons.logging.Log log
Log
instance for this application.protected java.util.List<OrderTotal> orderTotalList
protected int getCustomInt(java.lang.String customAttr, int customId) throws com.konakart.app.KKException
customAttr
- the customAttrcustomId
- the customIdcom.konakart.app.KKException
- an unexpected exception from the KonaKart engineprotected java.math.BigDecimal getCustomBigDecimal(java.lang.String customAttr, int customId) throws com.konakart.app.KKException
customAttr
- the customAttrcustomId
- the customIdcom.konakart.app.KKException
- an unexpected exception from the KonaKart engineprotected boolean getCustomBoolean(java.lang.String customAttr, int customId) throws com.konakart.app.KKException
customAttr
- the customAttrcustomId
- the customIdcom.konakart.app.KKException
- an unexpected exception from the KonaKart engineprotected java.lang.String getCustomString(java.lang.String customAttr, int customId) throws com.konakart.app.KKException
customAttr
- the customAttrcustomId
- the customIdcom.konakart.app.KKException
- an unexpected exception from the KonaKart engineprotected OrderTotal getDiscountOrderTotalFromList(Order order, java.util.List<OrderTotal> orderTotalsList) throws java.lang.Exception
order
- the orderorderTotalsList
- the orderTotalsListjava.lang.Exception
- an unexpected exceptionprotected OrderTotal getDiscountOrderTotalFromList(Order order, java.util.List<OrderTotal> orderTotalsList, boolean applyBeforeTax) throws java.lang.Exception
order
- the orderorderTotalsList
- the orderTotalsListapplyBeforeTax
- True when the discount is applied to total before tax is calculated. false when
the discount is applied to the total including tax.java.lang.Exception
- an unexpected exceptionprotected void setRefundValues(Order order, OrderTotal ot, boolean applyBeforeTax) throws java.lang.Exception
Note also that the reward point values are not modified.
order
- the orderot
- the otapplyBeforeTax
- the applyBeforeTaxjava.lang.Exception
- an unexpected exceptionprotected void setRefundValuesForSingleOrderTotal(Order order, OrderTotal ot, boolean applyBeforeTax, int scale) throws java.lang.Exception
setRefundValues()
.order
- the orderot
- the otapplyBeforeTax
- the applyBeforeTaxscale
- the scalejava.lang.Exception
- an unexpected exceptionprotected java.math.BigDecimal removeTax(java.math.BigDecimal value, java.math.BigDecimal taxRate, int scale)
value
- the valuetaxRate
- the taxRatescale
- the scaleprotected java.math.BigDecimal addTax(java.math.BigDecimal value, java.math.BigDecimal taxRate, int scale)
value
- the valuetaxRate
- the taxRatescale
- the scaleprotected void setPromotionIds(Order order, java.lang.String promotionIds)
order
- the orderpromotionIds
- the promotionIdsprotected void setCouponIds(Order order, java.lang.String couponIds)
order
- the ordercouponIds
- the couponIdsprotected void removeCouponId(Order order, java.lang.String couponId)
order
- the ordercouponId
- the couponIdprotected void removePromotionId(Order order, java.lang.String promotionId)
order
- the orderpromotionId
- the promotionIdpublic java.util.List<OrderTotal> getOrderTotalList()
public void setOrderTotalList(java.util.List<OrderTotal> orderTotalList)
orderTotalList
- the orderTotalList to setpublic PromotionResult getPromotionResult(Product product, Promotion promotion) throws java.lang.Exception
product
- the productpromotion
- the promotionjava.lang.Exception
- an unexpected exceptionpublic void commitOrder(OrderIf order) throws java.lang.Exception
order
- the orderjava.lang.Exception
- an unexpected exception
if something unexpected happenspublic java.math.BigDecimal getTaxFromTotal(java.math.BigDecimal total, java.math.BigDecimal taxRate, int scale)
If the total = 10 and the tax rate = 0.1 then the method would return 0.9091 because in this case the total of 10 is equivalent to 9.0909 + 0.9091 = 10 .
The value returned is (total x taxRate) / (1 + taxRate)
total
- the totaltaxRate
- the taxRatescale
- the scalepublic java.math.BigDecimal getTaxForDiscount(Order order, java.math.BigDecimal discount, int scale, boolean applyBeforeTax)
order
- the orderdiscount
- the discountscale
- the scaleapplyBeforeTax
- the applyBeforeTaxCopyright © 2018 DS Data Systems UK Ltd.