use of org.broadleafcommerce.core.offer.service.discount.PromotionDiscount in project BroadleafCommerce by BroadleafCommerce.
the class PromotableOrderItemPriceDetailImpl method copyWithFinalizedData.
@Override
public PromotableOrderItemPriceDetail copyWithFinalizedData() {
PromotableOrderItemPriceDetail copyDetail = promotableOrderItem.createNewDetail(quantity);
for (PromotionDiscount existingDiscount : promotionDiscounts) {
if (existingDiscount.isFinalized()) {
PromotionDiscount newDiscount = existingDiscount.copy();
copyDetail.getPromotionDiscounts().add(newDiscount);
}
}
for (PromotionQualifier existingQualifier : promotionQualifiers) {
if (existingQualifier.isFinalized()) {
PromotionQualifier newQualifier = existingQualifier.copy();
copyDetail.getPromotionQualifiers().add(newQualifier);
}
}
for (PromotableOrderItemPriceDetailAdjustment existingAdjustment : promotableOrderItemPriceDetailAdjustments) {
PromotableOrderItemPriceDetailAdjustment newAdjustment = existingAdjustment.copy();
copyDetail.addCandidateItemPriceDetailAdjustment(newAdjustment);
}
return copyDetail;
}
use of org.broadleafcommerce.core.offer.service.discount.PromotionDiscount in project BroadleafCommerce by BroadleafCommerce.
the class OfferServiceUtilitiesImpl method applyAdjustmentsForItemPriceDetails.
@Override
public void applyAdjustmentsForItemPriceDetails(PromotableCandidateItemOffer itemOffer, List<PromotableOrderItemPriceDetail> itemPriceDetails) {
for (PromotableOrderItemPriceDetail itemPriceDetail : itemPriceDetails) {
for (PromotionDiscount discount : itemPriceDetail.getPromotionDiscounts()) {
if (discount.getPromotion().equals(itemOffer.getOffer())) {
if (itemOffer.getOffer().isTotalitarianOffer() || !itemOffer.getOffer().isCombinableWithOtherOffers()) {
// the value of the item
if (adjustmentIsNotGoodEnoughToBeApplied(itemOffer, itemPriceDetail)) {
break;
}
}
OrderItem orderItem = itemPriceDetail.getPromotableOrderItem().getOrderItem();
Boolean offerCanApplyToChildOrderItems = itemOffer.getOffer().getApplyToChildItems();
if (isAddOnOrderItem(orderItem) && !offerCanApplyToChildOrderItems) {
break;
}
applyOrderItemAdjustment(itemOffer, itemPriceDetail);
break;
}
}
}
}
Aggregations