public interface CumulativeChargeStrategy<P extends Product,U extends User> extends ChargeStrategy<P,U>
| Modifier and Type | Method and Description |
|---|---|
<CONTEXT> Amount |
calculate(Map<P,Number> productQtyMap,
U user,
String currency,
List<PromotionForUser> promotions,
Amount subTotal,
Number quantityTotal,
CONTEXT context)
Calculate raw amount for product(s)
|
calculategetVersion<CONTEXT> Amount calculate(Map<P,Number> productQtyMap, U user, String currency, List<PromotionForUser> promotions, Amount subTotal, Number quantityTotal, CONTEXT context)
productQtyMap - as Map of Product to Number (Quantity)user - as U @NUllable truecurrency - as String @nullable true. A null implies default currency. Note: If not null then this will override subTotal Amount.getCurrency().List - of PromotionForUsers @nullable true - if Promotions do not apply then it can be nullsubTotal - as Amount; many scenarios use the Sub-Total of products to calculate other params. So provide that as a defined context variable. @nullable truequantityTotal - as Number; many scenarios use the quantityTotal of products to calculate other params @nullable truecontext - as additional case driven params that can be supplied @nullable trueAmount.getTotal() should be positive; while Amount.getDiscount() should be negative number.
This is because a Discount is DEDUCTED. So while it makes sense to DEDUCT a positive value from TOTAL; the discount itself should be ADDED
hence = >
Existing Total - (This Discount as Total)
Existing Discount - (-This Discount) = Existing Discount + This DiscountCopyright © 2018. All rights reserved.