public class DefaultSubOrderStrategy<P extends Product,U extends IGenericEcomUser,O extends SubOrder<O,I>,I extends OrderItem> extends DefaultOrderStrategy<P,U,O,I>
DefaultOrderStrategy
to support additional SubOrder
specific common cases.blockOrders, contextProviderStrategy, discountStrategy, orderService, packagingStrategy, promotionStrategy, saleStrategy, shippingStrategy
taxStrategy
productService, scanHierarchy
Constructor and Description |
---|
DefaultSubOrderStrategy() |
Modifier and Type | Method and Description |
---|---|
void |
autoCalcPartialAmountForNextSubOrder(O nextNew)
If
SubOrder.getPartialAmount() is null for the new Sub Order, then ensure sequence is valid using #sequenceSubOrderTransformer and then initialize it by auto
Calculate the SubOrder.setPartialAmount(Amount) for the next SubOrder and set it in the same object. |
double |
calculateCumulativeDiscount(O order)
Formule:
Cum.
|
Amount |
calculateCumulativePartialAmountsSoFar(O order,
boolean considerOnlyRealizedOrders,
boolean validateRelations)
Sum all
SubOrder.getPartialAmount() . |
double |
calculateCurrentTotal(O order)
Calculate current net value of the Order.
The word "current" is used, to imply that depending on the application, future SubOrder s with discounts maybe created, in that case this value will change. |
double |
calculatePayableTotal(O order) |
double |
calculateRemainder(O order)
For a
SubOrder calculate remainder amount based on SubOrder Amount.getTotal() - calculateCumulativePartialAmountsSoFar(SubOrder, boolean, boolean) .The calculateCumulativePartialAmountsSoFar method is given (order, true, false) as params. |
O |
createAndInitSubOrder(O rootOrPrev)
|
O |
initSubOrder(O newSubOrderBasedonRoot,
O rootOrPrev)
Convenience method that Initializes an instance
with calculations like remainder payable, sequencing
SubOrder for a given root if not already sequenced.Persists the created order also. |
calculate, createOrder, createOrder, createOrderItem, getContextProviderStrategy, getDiscountStrategy, getOrderInstance, getOrderService, getPackagingStrategy, getPromotionStrategy, getSaleStrategy, getShippingStrategy, getStrategiesVerson, isBlockOrders, onOrderComplete, processOrderItem, setBlockOrders, setContextProviderStrategy, setDiscountStrategy, setOrderService, setPackagingStrategy, setPromotionStrategy, setSaleStrategy, setShippingStrategy, validateOrder
applyTax, calculate, getTaxStrategy, getVersion, setTaxStrategy
getProductService, getRepresentativeProduct, isScanHierarchy, setProductService, setScanHierarchy
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getVersion
@Transactional(readOnly=false) public O initSubOrder(O newSubOrderBasedonRoot, O rootOrPrev)
SubOrder
for a given root if not already sequenced.newSubOrderBasedonRoot
- as O SubOrder
type. This is typically created using a Constructor method of SubOrder
using root as a param.rootOrPrev
- as O SubOrder
type as Root or Previous SubOrder
typeSubOrder
type, as updated and persisted version of newSubOrderBasedonRootpublic double calculatePayableTotal(O order)
SubOrder.getPayableTotal()
public Amount calculateCumulativePartialAmountsSoFar(O order, boolean considerOnlyRealizedOrders, boolean validateRelations)
SubOrder.getPartialAmount()
. RelatedOrder.getRoot()
is only considered if it is also a SubOrder
type.Amount
not available for a SubOrder
then it will assume full amount for that SubOrder
#getPrevious()
are available for the order hat is input to this function.
order
- as SubOrder
typeconsiderOnlyRealizedOrders
- as boolean. If true will consider only orders that are realizedvalidateRelations
- as boolean. If true will execute SubOrder.validateRelations()
on each relation it iterates overpublic double calculateCumulativeDiscount(O order)
BaseOrderItem.getAmount()
.discount + All cumulative discounts for ALL related SubOrder.getPartialAmount()
s
calculateCumulativePartialAmountsSoFar(SubOrder, boolean, boolean)
public double calculateRemainder(O order)
SubOrder
calculate remainder amount based on SubOrder
Amount.getTotal()
- calculateCumulativePartialAmountsSoFar(SubOrder, boolean, boolean)
.Order.getRealized()
=true are considered for payments made so far.
SubOrder.getPartialAmount()
s) - (All cumulative discounts for ALL related SubOrder.getPartialAmount()
s)
SubOrder.getPartialAmount()
.
order
- as SubOrder
typecalculateCumulativePartialAmountsSoFar(SubOrder, boolean, boolean)
public double calculateCurrentTotal(O order)
SubOrder
s with discounts maybe created, in that case this value will change.
SubOrder.getPartialAmount()
s)
SubOrder.getPartialAmount()
.
order
- as SubOrder
typeOrder.amount.total
,
calculateCumulativePartialAmountsSoFar.discount For realized orders
public void autoCalcPartialAmountForNextSubOrder(O nextNew)
SubOrder.getPartialAmount()
is null for the new Sub Order, then ensure sequence is valid using #sequenceSubOrderTransformer
and then initialize it by auto
Calculate the SubOrder.setPartialAmount(Amount)
for the next SubOrder
and set it in the same object.
Order.getRealized()
=true are considered for payments made so far.nextNew
- as O of type SubOrder
Copyright © 2018. All rights reserved.