Package org.broadleafcommerce.core.offer.service.discount

Examples of org.broadleafcommerce.core.offer.service.discount.PromotionQualifier


        // for this promotion
        assertTrue(quantity==2);
       
        priceDetail1.getPromotionDiscounts().clear();
       
        PromotionQualifier qualifier = new PromotionQualifier();
        qualifier.setPromotion(offer);
        qualifier.setQuantity(1);
        priceDetail1.getPromotionQualifiers().add(qualifier);
       
        quantity = priceDetail1.getQuantityAvailableToBeUsedAsQualifier(candidateOffer);
        //items that have already qualified for this promotion cannot qualify again
        assertTrue(quantity==1);
       
        qualifier.setPromotion(testOffer);
       
        quantity = priceDetail1.getQuantityAvailableToBeUsedAsQualifier(candidateOffer);
        //this item qualified for a different promotion, but the restriction rule is NONE, so this item cannot be a qualifier for this promotion
        assertTrue(quantity==1);
       
View Full Code Here


        priceDetail1.getPromotionDiscounts().clear();
        // rest candidate offer
        candidateOffer.getOffer().setOfferItemTargetRuleType(OfferItemRestrictionRuleType.NONE);
       
        PromotionQualifier qualifier = new PromotionQualifier();
        qualifier.setPromotion(offer);
        qualifier.setQuantity(1);
        priceDetail1.getPromotionQualifiers().add(qualifier);
       
        quantity = priceDetail1.getQuantityAvailableToBeUsedAsTarget(candidateOffer);
        //items that have already qualified for this promotion cannot qualify again
        assertTrue(quantity==1);
       
        qualifier.setPromotion(tempOffer);
       
        quantity = priceDetail1.getQuantityAvailableToBeUsedAsTarget(candidateOffer);
        //this item qualified for a different promotion, but the restriction rule is NONE,
        // so this item cannot be a qualifier for this promotion
        assertTrue(quantity==1);
View Full Code Here

                }

                List<OrderItemQualifier> oiqs = poid.getPromotableOrderItem().getOrderItem().getOrderItemQualifiers();
                if (CollectionUtils.isNotEmpty(oiqs)) {
                    for (OrderItemQualifier oiq : oiqs) {
                        PromotionQualifier pq = new PromotionQualifier();
                        pq.setPromotion(oiq.getOffer());
                        pq.setQuantity(oiq.getQuantity().intValue());
                        pq.setFinalizedQuantity(oiq.getQuantity().intValue());
                        poid.getPromotionQualifiers().add(pq);
                    }
                }
            }
        } else {
View Full Code Here

            if (pq.getPromotion().equals(promotion)) {
                return pq;
            }
        }

        PromotionQualifier pq = new PromotionQualifier();
        pq.setPromotion(promotion);
        promotionQualifiers.add(pq);
        return pq;
    }
View Full Code Here

        return pd;
    }

    @Override
    public PromotionQualifier addPromotionQualifier(PromotableCandidateItemOffer itemOffer, OfferItemCriteria itemCriteria, int qtyToMarkAsQualifier) {
        PromotionQualifier pq = lookupOrCreatePromotionQualifier(itemOffer);
        pq.incrementQuantity(qtyToMarkAsQualifier);
        pq.setItemCriteria(itemCriteria);
        return pq;
    }
View Full Code Here

    @Override
    public void clearAllNonFinalizedQuantities() {
        Iterator<PromotionQualifier> promotionQualifierIterator = promotionQualifiers.iterator();
        while (promotionQualifierIterator.hasNext()) {
            PromotionQualifier promotionQualifier = promotionQualifierIterator.next();
            if (promotionQualifier.getFinalizedQuantity() == 0) {
                // If there are no quantities of this item that are finalized, then remove the item.
                promotionQualifierIterator.remove();
            } else {
                // Otherwise, set the quantity to the number of finalized items.
                promotionQualifier.setQuantity(promotionQualifier.getFinalizedQuantity());
            }
        }

        Iterator<PromotionDiscount> promotionDiscountIterator = promotionDiscounts.iterator();
        while (promotionDiscountIterator.hasNext()) {
View Full Code Here

            }
        }

        for (PromotionQualifier existingQualifier : promotionQualifiers) {
            if (existingQualifier.isFinalized()) {
                PromotionQualifier newQualifier = existingQualifier.copy();
                copyDetail.getPromotionQualifiers().add(newQualifier);
            }
        }

        for (PromotableOrderItemPriceDetailAdjustment existingAdjustment : promotableOrderItemPriceDetailAdjustments) {
View Full Code Here

        }

        if (hasQualifiers) {
            Iterator<PromotionQualifier> qualifiers = promotionQualifiers.iterator();
            while (qualifiers.hasNext()) {
                PromotionQualifier currentQualifier = qualifiers.next();
                Long qualifierOfferId = currentQualifier.getPromotion().getId();
                if (qualifierOfferId.equals(offerId) && currentQualifier.getQuantity() <= splitItemQty) {
                    // Remove this one from the original detail
                    qualifiers.remove();
                    newDetail.getPromotionQualifiers().add(currentQualifier);
                } else {
                    PromotionQualifier newQualifier = currentQualifier.split(splitItemQty);
                    newDetail.getPromotionQualifiers().add(newQualifier);
                }
            }
        }
View Full Code Here

    protected void synchronizeItemQualifiers(OrderItem orderItem, PromotableOrderItem promotableOrderItem) {
        Map<Long, PromotionQualifier> qualifiersMap = buildPromotableQualifiersMap(promotableOrderItem);
        Map<Long, OrderItemQualifier> unmatchedQualifiersMap = new HashMap<Long, OrderItemQualifier>();

        for (OrderItemQualifier orderItemQualifier : orderItem.getOrderItemQualifiers()) {
            PromotionQualifier promotableQualifier = qualifiersMap.remove(orderItemQualifier.getOffer().getId());
            if (promotableQualifier != null) {
                // Offer was used as a qualifier on previous run.   Update quantity if needed.
                if (orderItemQualifier.getQuantity() != promotableQualifier.getQuantity()) {
                    orderItemQualifier.setQuantity(new Long(promotableQualifier.getQuantity()));
                }
            } else {
                unmatchedQualifiersMap.put(orderItemQualifier.getId(), orderItemQualifier);
            }
        }
View Full Code Here

    protected Map<Long, PromotionQualifier> buildPromotableQualifiersMap(PromotableOrderItem item) {
        Map<Long, PromotionQualifier> qualifiersMap = new HashMap<Long, PromotionQualifier>();
        for (PromotableOrderItemPriceDetail detail : item.getPromotableOrderItemPriceDetails()) {
            for (PromotionQualifier qualifier : detail.getPromotionQualifiers()) {
                PromotionQualifier existingQualifier = qualifiersMap.get(qualifier.getPromotion().getId());
                if (existingQualifier != null) {
                    existingQualifier.setQuantity(existingQualifier.getQuantity() + qualifier.getQuantity());
                } else {
                    qualifiersMap.put(qualifier.getPromotion().getId(), qualifier);
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.broadleafcommerce.core.offer.service.discount.PromotionQualifier

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.