P - as productU - as userpublic class DefaultDiscountStrategy<P extends Product,U extends User> extends AbstractChargeStrategy<P,U>
Amount.getDiscount() should be a positive value, and the same amount should be negative in Amount.getTotal()
so that Amount.add(Amount) of discount value results in proper calculation. You are ADDING a DISCOUNT not DEDUCTING (Important to consider conventions)
DefaultDiscountStrategy and PromotionStrategy is that this is applicable @ a product level only;
while PromotionStrategy is applicable @ the cart level and also supports product level.taxStrategyproductService, scanHierarchy| Constructor and Description |
|---|
DefaultDiscountStrategy() |
| Modifier and Type | Method and Description |
|---|---|
<CONTEXT> Amount |
calculate(P product,
Number quantity,
U user,
String currency,
List<PromotionForUser> promotions,
CONTEXT context)
Calculate raw amount for a product and any user making purchase
|
applyTax, calculate, getTaxStrategy, getVersion, setTaxStrategygetProductService, getRepresentativeProduct, isScanHierarchy, setProductService, setScanHierarchypublic <CONTEXT> Amount calculate(P product, Number quantity, U user, String currency, List<PromotionForUser> promotions, CONTEXT context)
ChargeStrategyproduct - as Pquantity - as Numberuser - as U @NUllable truecurrency - as String @nullable true. A null implies default currencyCopyright © 2018. All rights reserved.