protected boolean compareAndAdjustFulfillmentGroupOffers( PromotableOrder order, boolean fgOfferApplied) { Money regularOrderDiscountShippingTotal = BroadleafCurrencyUtils.getMoney(BigDecimal.ZERO, order.getOrderCurrency()); regularOrderDiscountShippingTotal = regularOrderDiscountShippingTotal.add(order.calculateSubtotalWithoutAdjustments()); for (PromotableFulfillmentGroup fg : order.getFulfillmentGroups()) { regularOrderDiscountShippingTotal = regularOrderDiscountShippingTotal.add(fg.getFinalizedPriceWithAdjustments()); } Money discountOrderRegularShippingTotal = BroadleafCurrencyUtils.getMoney(BigDecimal.ZERO, order.getOrderCurrency()); discountOrderRegularShippingTotal = discountOrderRegularShippingTotal.add(order.calculateSubtotalWithAdjustments()); for (PromotableFulfillmentGroup fg : order.getFulfillmentGroups()) { discountOrderRegularShippingTotal = discountOrderRegularShippingTotal.add(fg.calculatePriceWithoutAdjustments()); } if (discountOrderRegularShippingTotal.lessThan(regularOrderDiscountShippingTotal)) { // order/item offer is better; remove totalitarian fulfillment group offer and process other // fg offers order.removeAllCandidateFulfillmentOfferAdjustments(); fgOfferApplied = false; } else { // totalitarian fg offer is better; remove all order/item offers order.removeAllCandidateOrderOfferAdjustments(); order.removeAllCandidateItemOfferAdjustments(); order.getOrder().setSubTotal(order.calculateSubtotalWithAdjustments()); } return fgOfferApplied; }
@Override public void calculateFulfillmentGroupTotal(PromotableOrder order) { Money totalFulfillmentCharges = BroadleafCurrencyUtils.getMoney(BigDecimal.ZERO, order.getOrderCurrency()); for (PromotableFulfillmentGroup fulfillmentGroupMember : order.getFulfillmentGroups()) { PromotableFulfillmentGroup fulfillmentGroup = fulfillmentGroupMember; Money fulfillmentCharges = fulfillmentGroup.getFinalizedPriceWithAdjustments(); fulfillmentGroup.getFulfillmentGroup().setFulfillmentPrice(fulfillmentCharges); totalFulfillmentCharges = totalFulfillmentCharges.add(fulfillmentCharges); } order.setTotalFufillmentCharges(totalFulfillmentCharges); }