Search in sources :

Example 11 with PromotionDiscount

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;
}
Also used : PromotionQualifier(org.broadleafcommerce.core.offer.service.discount.PromotionQualifier) PromotionDiscount(org.broadleafcommerce.core.offer.service.discount.PromotionDiscount)

Example 12 with PromotionDiscount

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;
            }
        }
    }
}
Also used : PromotableOrderItem(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItem) DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) OrderItem(org.broadleafcommerce.core.order.domain.OrderItem) PromotionDiscount(org.broadleafcommerce.core.offer.service.discount.PromotionDiscount) PromotableOrderItemPriceDetail(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItemPriceDetail)

Aggregations

PromotionDiscount (org.broadleafcommerce.core.offer.service.discount.PromotionDiscount)12 Offer (org.broadleafcommerce.core.offer.domain.Offer)7 PromotionQualifier (org.broadleafcommerce.core.offer.service.discount.PromotionQualifier)7 PromotableCandidateItemOffer (org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateItemOffer)3 OfferImpl (org.broadleafcommerce.core.offer.domain.OfferImpl)2 PromotableCandidateItemOfferImpl (org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateItemOfferImpl)2 PromotableOrderItem (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItem)2 PromotableOrderItemPriceDetail (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItemPriceDetail)2 BigDecimal (java.math.BigDecimal)1 Money (org.broadleafcommerce.common.money.Money)1 PromotableCandidateOrderOffer (org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateOrderOffer)1 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)1 OrderItem (org.broadleafcommerce.core.order.domain.OrderItem)1