Examples of PromotionDiscount


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

    public void testGetQuantityAvailableToBeUsedAsQualifier() throws Exception {
        int quantity = priceDetail1.getQuantityAvailableToBeUsedAsQualifier(candidateOffer);
        //no previous qualifiers, so all quantity is available
        assertTrue(quantity == 2);
       
        PromotionDiscount discount = new PromotionDiscount();
        discount.setPromotion(offer);
        discount.setQuantity(1);
        priceDetail1.getPromotionDiscounts().add(discount);
       
        quantity = priceDetail1.getQuantityAvailableToBeUsedAsQualifier(candidateOffer);
        //items that have already received this promotion cannot get it again
        assertTrue(quantity==1);
       
        Offer testOffer = new OfferImpl();
        testOffer.setOfferItemQualifierRuleType(OfferItemRestrictionRuleType.NONE);
        testOffer.setOfferItemTargetRuleType(OfferItemRestrictionRuleType.NONE);
       
        discount.setPromotion(testOffer);
       
        quantity = priceDetail1.getQuantityAvailableToBeUsedAsQualifier(candidateOffer);
        //this item received 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

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

    public void testGetQuantityAvailableToBeUsedAsTarget() throws Exception {
        int quantity = priceDetail1.getQuantityAvailableToBeUsedAsTarget(candidateOffer);
        //no previous qualifiers, so all quantity is available
        assertTrue(quantity == 2);
       
        PromotionDiscount discount = new PromotionDiscount();
        discount.setPromotion(offer);
        discount.setQuantity(1);
        priceDetail1.getPromotionDiscounts().add(discount);
       
        quantity = priceDetail1.getQuantityAvailableToBeUsedAsTarget(candidateOffer);
        //items that have already received this promotion cannot get it again
        assertTrue(quantity==1);
       
        Offer tempOffer = new OfferImpl();
        tempOffer.setCombinableWithOtherOffers(true);
        tempOffer.setOfferItemQualifierRuleType(OfferItemRestrictionRuleType.NONE);
        tempOffer.setOfferItemTargetRuleType(OfferItemRestrictionRuleType.NONE);
       
        discount.setPromotion(tempOffer);
       
        quantity = priceDetail1.getQuantityAvailableToBeUsedAsTarget(candidateOffer);
        //this item received 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

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

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

        PromotionDiscount pd = new PromotionDiscount();
        pd.setPromotion(promotion);

        promotionDiscounts.add(pd);
        return pd;
    }
View Full Code Here

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

        return pq;
    }

    @Override
    public void addPromotionDiscount(PromotableCandidateItemOffer itemOffer, OfferItemCriteria itemCriteria, int qtyToMarkAsTarget) {
        PromotionDiscount pd = lookupOrCreatePromotionDiscount(itemOffer);
        if (pd == null) {
            return;
        }
        pd.incrementQuantity(qtyToMarkAsTarget);
        pd.setItemCriteria(itemCriteria);
        pd.setCandidateItemOffer(itemOffer);
    }
View Full Code Here

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

            }
        }

        Iterator<PromotionDiscount> promotionDiscountIterator = promotionDiscounts.iterator();
        while (promotionDiscountIterator.hasNext()) {
            PromotionDiscount promotionDiscount = promotionDiscountIterator.next();
            if (promotionDiscount.getFinalizedQuantity() == 0) {
                // If there are no quantities of this item that are finalized, then remove the item.
                promotionDiscountIterator.remove();
            } else {
                // Otherwise, set the quantity to the number of finalized items.
                promotionDiscount.setQuantity(promotionDiscount.getFinalizedQuantity());
            }
        }

    }
View Full Code Here

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

    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) {
View Full Code Here

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

        // Create the new item with the correct quantity
        PromotableOrderItemPriceDetail newDetail = promotableOrderItem.createNewDetail(splitItemQty);

        // copy discounts
        for (PromotionDiscount existingDiscount : promotionDiscounts) {
            PromotionDiscount newDiscount = existingDiscount.split(discountQty);
            if (newDiscount != null) {
                newDetail.getPromotionDiscounts().add(newDiscount);
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.