int quantity = promotableCandidateItemOffer.calculateTargetQuantityForTieredOffer();
List<OfferTier> offerTiers = advancedOffer.getOfferTiers();
Collections.sort(offerTiers, new BeanComparator("minQuantity"));
OfferTier maxTier = null;
//assuming that promotableOffer.getOffer()).getOfferTiers() is sorted already
for (OfferTier currentTier : offerTiers) {
if (quantity >= currentTier.getMinQuantity()) {
maxTier = currentTier;
} else {
break;
}
}
if (maxTier != null) {
return maxTier.getAmount();
}
if (OfferDiscountType.FIX_PRICE.equals(offer.getDiscountType())) {
// Choosing an arbitrary large value. The retail / sale price will be less than this,
// so the offer will not get selected.