protected int applyLegacyAdjustments(
     int appliedItemOffersCount,
     PromotableCandidateItemOffer itemOffer,
     int beforeCount,
     PromotableOrderItem orderItem) {
   // legacy promotion
   if (!orderItem.isNotCombinableOfferApplied()) {
     if ((itemOffer.getOffer().isCombinableWithOtherOffers() && itemOffer.getOffer().isStackable())
         || !orderItem.isHasOrderItemAdjustments()) {
       applyOrderItemAdjustment(itemOffer, orderItem);
       appliedItemOffersCount++;
     }
   }
   // check if not combinable offer is better than sale price; if no, remove the not combinable
   // offer so
   // that another offer may be applied to the item
   if (!itemOffer.getOffer().isCombinableWithOtherOffers()
       && appliedItemOffersCount > beforeCount) {
     Money adjustmentTotal = new Money(0D);
     Money saleTotal = new Money(0D);
     adjustmentTotal =
         adjustmentTotal.add(orderItem.getCurrentPrice().multiply(orderItem.getQuantity()));
     saleTotal =
         saleTotal.add(
             orderItem.getPriceBeforeAdjustments(true).multiply(orderItem.getQuantity()));
     if (adjustmentTotal.greaterThanOrEqual(saleTotal)) {
       // adjustment price is not best price, remove adjustments for this item
       orderItem.removeAllAdjustments();
       appliedItemOffersCount--;
     }
   }
   return appliedItemOffersCount;
 }
 protected int applyAdjustments(
     PromotableOrder order,
     int appliedItemOffersCount,
     PromotableCandidateItemOffer itemOffer,
     int beforeCount) {
   boolean notCombinableOfferApplied = false;
   boolean offerApplied = false;
   List<PromotableOrderItem> allSplitItems = order.getAllSplitItems();
   for (PromotableOrderItem targetItem : allSplitItems) {
     notCombinableOfferApplied = targetItem.isNotCombinableOfferApplied();
     if (!offerApplied) {
       offerApplied = targetItem.isHasOrderItemAdjustments();
     }
     if (notCombinableOfferApplied) {
       break;
     }
   }
   if (!notCombinableOfferApplied
       && (((itemOffer.getOffer().isCombinableWithOtherOffers()
               || itemOffer.getOffer().isTotalitarianOffer() == null
               || !itemOffer.getOffer().isTotalitarianOffer())
           // && itemOffer.getOffer().isStackable()
           )
           || !offerApplied)) {
     // At this point, we should not have any official adjustment on the order
     // for this item.
     applyItemQualifiersAndTargets(itemOffer, order);
     allSplitItems = order.getAllSplitItems();
     for (PromotableOrderItem splitItem : allSplitItems) {
       for (PromotionDiscount discount : splitItem.getPromotionDiscounts()) {
         if (discount.getPromotion().equals(itemOffer.getOffer())) {
           applyOrderItemAdjustment(itemOffer, splitItem);
           appliedItemOffersCount++;
           break;
         }
       }
     }
   }
   // check if not combinable offer is better than sale price; if no, remove the not combinable
   // offer so
   // that another offer may be applied to the item
   if ((!itemOffer.getOffer().isCombinableWithOtherOffers()
           || (itemOffer.getOffer().isTotalitarianOffer() != null
               && itemOffer.getOffer().isTotalitarianOffer()))
       && appliedItemOffersCount > beforeCount) {
     Money adjustmentTotal = new Money(0D);
     Money saleTotal = new Money(0D);
     for (PromotableOrderItem splitItem : allSplitItems) {
       adjustmentTotal =
           adjustmentTotal.add(splitItem.getCurrentPrice().multiply(splitItem.getQuantity()));
       saleTotal =
           saleTotal.add(
               splitItem.getPriceBeforeAdjustments(true).multiply(splitItem.getQuantity()));
     }
     if (adjustmentTotal.greaterThanOrEqual(saleTotal)) {
       // adjustment price is not best price, remove adjustments for this item
       for (PromotableOrderItem splitItem : allSplitItems) {
         if (splitItem.isHasOrderItemAdjustments()) {
           appliedItemOffersCount--;
         }
       }
       order.getSplitItems().clear();
     }
   }
   return appliedItemOffersCount;
 }