コード例 #1
0
  protected int checkLegacyAdjustments(
      List<PromotableOrderItem> discreteOrderItems, int appliedItemOffersCount) {
    if (appliedItemOffersCount > 0) {
      for (PromotableOrderItem discreteOrderItem : discreteOrderItems) {
        if (discreteOrderItem.isHasOrderItemAdjustments()) {
          boolean useSaleAdjustments = false;
          int adjustmentsRemoved = 0;

          Money adjustmentPrice;
          if (discreteOrderItem.getDelegate().getIsOnSale()) {
            if (discreteOrderItem
                .getSaleAdjustmentPrice()
                .lessThanOrEqual(discreteOrderItem.getRetailAdjustmentPrice())) {
              adjustmentPrice = discreteOrderItem.getSaleAdjustmentPrice();
              useSaleAdjustments = true;
            } else {
              adjustmentPrice = discreteOrderItem.getRetailAdjustmentPrice();
            }

            if (!adjustmentPrice.lessThanOrEqual(discreteOrderItem.getSalePrice())) {
              adjustmentsRemoved = adjustmentsRemoved + discreteOrderItem.removeAllAdjustments();
            }
          } else {
            if (!discreteOrderItem
                .getRetailAdjustmentPrice()
                .lessThanOrEqual(discreteOrderItem.getRetailPrice())) {
              adjustmentsRemoved = adjustmentsRemoved + discreteOrderItem.removeAllAdjustments();
            }
          }

          adjustmentsRemoved =
              adjustmentsRemoved + discreteOrderItem.fixAdjustments(useSaleAdjustments);
          appliedItemOffersCount -= adjustmentsRemoved;
        }
      }
    }
    return appliedItemOffersCount;
  }
コード例 #2
0
  protected int checkAdjustments(PromotableOrder order, int appliedItemOffersCount) {
    if (appliedItemOffersCount > 0) {
      List<PromotableOrderItem> allSplitItems = order.getAllSplitItems();
      // compare adjustment price to sales price and remove adjustments if sales price is better
      for (PromotableOrderItem splitItem : allSplitItems) {
        if (splitItem.isHasOrderItemAdjustments()) {
          boolean useSaleAdjustments = false;
          int adjustmentsRemoved = 0;

          Money adjustmentPrice;
          if (splitItem.getDelegate().getIsOnSale()) {
            if (splitItem
                .getSaleAdjustmentPrice()
                .lessThanOrEqual(splitItem.getRetailAdjustmentPrice())) {
              adjustmentPrice = splitItem.getSaleAdjustmentPrice();
              useSaleAdjustments = true;
            } else {
              adjustmentPrice = splitItem.getRetailAdjustmentPrice();
            }

            if (!adjustmentPrice.lessThan(splitItem.getSalePrice())) {
              adjustmentsRemoved = adjustmentsRemoved + splitItem.removeAllAdjustments();
            }
          } else {
            if (!splitItem.getRetailAdjustmentPrice().lessThan(splitItem.getRetailPrice())) {
              adjustmentsRemoved = adjustmentsRemoved + splitItem.removeAllAdjustments();
            }
          }

          adjustmentsRemoved = adjustmentsRemoved + splitItem.fixAdjustments(useSaleAdjustments);
          appliedItemOffersCount -= adjustmentsRemoved;
        }
      }
      mergeSplitItems(order);
    }
    return appliedItemOffersCount;
  }