Search in sources :

Example 1 with OfferQualifyingCriteriaXref

use of org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref in project BroadleafCommerce by BroadleafCommerce.

the class OfferDataItemProvider method createItemBasedOfferWithItemCriteria.

public List<Offer> createItemBasedOfferWithItemCriteria(String orderRule, OfferDiscountType discountType, String qualRule, String targetRule) {
    List<Offer> offers = createItemBasedOffer(orderRule, targetRule, discountType);
    if (qualRule != null) {
        Offer firstOffer = offers.get(0);
        OfferItemCriteria qualCriteria = new OfferItemCriteriaImpl();
        // qualCriteria.setQualifyingOffer(offers.get(0));
        qualCriteria.setQuantity(1);
        qualCriteria.setMatchRule(qualRule);
        Set<OfferQualifyingCriteriaXref> criterias = new HashSet<OfferQualifyingCriteriaXref>();
        OfferQualifyingCriteriaXref xref = new OfferQualifyingCriteriaXrefImpl();
        xref.setOffer(firstOffer);
        xref.setOfferItemCriteria(qualCriteria);
        criterias.add(xref);
        firstOffer.setQualifyingItemCriteriaXref(criterias);
    }
    return offers;
}
Also used : OfferItemCriteriaImpl(org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl) Offer(org.broadleafcommerce.core.offer.domain.Offer) OfferItemCriteria(org.broadleafcommerce.core.offer.domain.OfferItemCriteria) OfferQualifyingCriteriaXrefImpl(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXrefImpl) OfferQualifyingCriteriaXref(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref) HashSet(java.util.HashSet)

Example 2 with OfferQualifyingCriteriaXref

use of org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref in project BroadleafCommerce by BroadleafCommerce.

the class OfferDataItemProvider method createOrderBasedOfferWithItemCriteria.

public List<Offer> createOrderBasedOfferWithItemCriteria(String orderRule, OfferDiscountType discountType, String orderItemMatchRule) {
    List<Offer> offers = createOrderBasedOffer(orderRule, discountType);
    Offer firstOffer = offers.get(0);
    OfferItemCriteria qualCriteria = new OfferItemCriteriaImpl();
    // qualCriteria.setQualifyingOffer(offers.get(0));
    qualCriteria.setQuantity(1);
    qualCriteria.setMatchRule(orderItemMatchRule);
    Set<OfferQualifyingCriteriaXref> criterias = new HashSet<OfferQualifyingCriteriaXref>();
    OfferQualifyingCriteriaXref xref = new OfferQualifyingCriteriaXrefImpl();
    xref.setOffer(firstOffer);
    xref.setOfferItemCriteria(qualCriteria);
    criterias.add(xref);
    firstOffer.setQualifyingItemCriteriaXref(criterias);
    return offers;
}
Also used : OfferItemCriteriaImpl(org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl) Offer(org.broadleafcommerce.core.offer.domain.Offer) OfferItemCriteria(org.broadleafcommerce.core.offer.domain.OfferItemCriteria) OfferQualifyingCriteriaXrefImpl(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXrefImpl) OfferQualifyingCriteriaXref(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref) HashSet(java.util.HashSet)

Example 3 with OfferQualifyingCriteriaXref

use of org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref in project BroadleafCommerce by BroadleafCommerce.

the class OfferDataItemProvider method createFGBasedOfferWithItemCriteria.

public List<Offer> createFGBasedOfferWithItemCriteria(String orderRule, String fgRule, OfferDiscountType discountType, String orderItemMatchRule) {
    List<Offer> offers = createFGBasedOffer(orderRule, fgRule, discountType);
    Offer firstOffer = offers.get(0);
    OfferItemCriteria qualCriteria = new OfferItemCriteriaImpl();
    qualCriteria.setQuantity(1);
    qualCriteria.setMatchRule(orderItemMatchRule);
    Set<OfferQualifyingCriteriaXref> criterias = new HashSet<OfferQualifyingCriteriaXref>();
    OfferQualifyingCriteriaXref xref = new OfferQualifyingCriteriaXrefImpl();
    xref.setOffer(firstOffer);
    xref.setOfferItemCriteria(qualCriteria);
    criterias.add(xref);
    firstOffer.setQualifyingItemCriteriaXref(criterias);
    return offers;
}
Also used : OfferItemCriteriaImpl(org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl) Offer(org.broadleafcommerce.core.offer.domain.Offer) OfferItemCriteria(org.broadleafcommerce.core.offer.domain.OfferItemCriteria) OfferQualifyingCriteriaXrefImpl(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXrefImpl) OfferQualifyingCriteriaXref(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref) HashSet(java.util.HashSet)

Example 4 with OfferQualifyingCriteriaXref

use of org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref in project BroadleafCommerce by BroadleafCommerce.

the class FulfillmentGroupOfferProcessorTest method testCouldOrderItemMeetOfferRequirement.

public void testCouldOrderItemMeetOfferRequirement() {
    replay();
    PromotableOrder order = dataProvider.createBasicPromotableOrder();
    List<Offer> offers = dataProvider.createFGBasedOfferWithItemCriteria("order.subTotal.getAmount()>20", "fulfillmentGroup.address.postalCode==75244", OfferDiscountType.PERCENT_OFF, "([MVEL.eval(\"toUpperCase()\",\"test1\"), MVEL.eval(\"toUpperCase()\",\"test2\")] contains MVEL.eval(\"toUpperCase()\", discreteOrderItem.category.name))");
    OfferQualifyingCriteriaXref xref = offers.get(0).getQualifyingItemCriteriaXref().iterator().next();
    boolean couldApply = fgProcessor.couldOrderItemMeetOfferRequirement(xref.getOfferItemCriteria(), order.getDiscountableOrderItems().get(0));
    // test that the valid fg offer is included
    assertTrue(couldApply);
    offers = dataProvider.createFGBasedOfferWithItemCriteria("order.subTotal.getAmount()>20", "fulfillmentGroup.address.postalCode==75244", OfferDiscountType.PERCENT_OFF, "([MVEL.eval(\"toUpperCase()\",\"test5\"), MVEL.eval(\"toUpperCase()\",\"test6\")] contains MVEL.eval(\"toUpperCase()\", discreteOrderItem.category.name))");
    xref = offers.get(0).getQualifyingItemCriteriaXref().iterator().next();
    couldApply = fgProcessor.couldOrderItemMeetOfferRequirement(xref.getOfferItemCriteria(), order.getDiscountableOrderItems().get(0));
    // test that the invalid fg offer is excluded
    assertFalse(couldApply);
    verify();
}
Also used : CandidateFulfillmentGroupOffer(org.broadleafcommerce.core.offer.domain.CandidateFulfillmentGroupOffer) PromotableCandidateFulfillmentGroupOffer(org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateFulfillmentGroupOffer) CandidateItemOffer(org.broadleafcommerce.core.offer.domain.CandidateItemOffer) Offer(org.broadleafcommerce.core.offer.domain.Offer) PromotableOrder(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder) OfferQualifyingCriteriaXref(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref)

Example 5 with OfferQualifyingCriteriaXref

use of org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref in project BroadleafCommerce by BroadleafCommerce.

the class OrderOfferProcessorTest method testCouldOrderItemMeetOfferRequirement.

public void testCouldOrderItemMeetOfferRequirement() throws Exception {
    replay();
    PromotableOrder order = dataProvider.createBasicPromotableOrder();
    List<Offer> offers = dataProvider.createOrderBasedOfferWithItemCriteria("order.subTotal.getAmount()>20", OfferDiscountType.PERCENT_OFF, "([MVEL.eval(\"toUpperCase()\",\"test1\"), MVEL.eval(\"toUpperCase()\",\"test2\")] contains MVEL.eval(\"toUpperCase()\", discreteOrderItem.category.name))");
    OfferQualifyingCriteriaXref xref = offers.get(0).getQualifyingItemCriteriaXref().iterator().next();
    boolean couldApply = orderProcessor.couldOrderItemMeetOfferRequirement(xref.getOfferItemCriteria(), order.getDiscountableOrderItems().get(0));
    // test that the valid order offer is included
    assertTrue(couldApply);
    offers = dataProvider.createOrderBasedOfferWithItemCriteria("order.subTotal.getAmount()>20", OfferDiscountType.PERCENT_OFF, "([MVEL.eval(\"toUpperCase()\",\"test5\"), MVEL.eval(\"toUpperCase()\",\"test6\")] contains MVEL.eval(\"toUpperCase()\", discreteOrderItem.category.name))");
    xref = offers.get(0).getQualifyingItemCriteriaXref().iterator().next();
    couldApply = orderProcessor.couldOrderItemMeetOfferRequirement(xref.getOfferItemCriteria(), order.getDiscountableOrderItems().get(0));
    // test that the invalid order offer is excluded
    assertFalse(couldApply);
    verify();
}
Also used : PromotableCandidateOrderOffer(org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateOrderOffer) Offer(org.broadleafcommerce.core.offer.domain.Offer) PromotableOrder(org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder) OfferQualifyingCriteriaXref(org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref)

Aggregations

Offer (org.broadleafcommerce.core.offer.domain.Offer)9 OfferQualifyingCriteriaXref (org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXref)9 OfferItemCriteria (org.broadleafcommerce.core.offer.domain.OfferItemCriteria)5 OfferItemCriteriaImpl (org.broadleafcommerce.core.offer.domain.OfferItemCriteriaImpl)5 OfferQualifyingCriteriaXrefImpl (org.broadleafcommerce.core.offer.domain.OfferQualifyingCriteriaXrefImpl)5 PromotableOrder (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrder)5 HashSet (java.util.HashSet)4 CandidateItemOffer (org.broadleafcommerce.core.offer.domain.CandidateItemOffer)3 ArrayList (java.util.ArrayList)2 OfferTargetCriteriaXref (org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXref)2 PromotableCandidateItemOffer (org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateItemOffer)2 PromotableCandidateOrderOffer (org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateOrderOffer)2 Calendar (java.util.Calendar)1 Money (org.broadleafcommerce.common.money.Money)1 CandidateFulfillmentGroupOffer (org.broadleafcommerce.core.offer.domain.CandidateFulfillmentGroupOffer)1 OfferTargetCriteriaXrefImpl (org.broadleafcommerce.core.offer.domain.OfferTargetCriteriaXrefImpl)1 CandidatePromotionItems (org.broadleafcommerce.core.offer.service.discount.CandidatePromotionItems)1 PromotableCandidateFulfillmentGroupOffer (org.broadleafcommerce.core.offer.service.discount.domain.PromotableCandidateFulfillmentGroupOffer)1 PromotableOrderItem (org.broadleafcommerce.core.offer.service.discount.domain.PromotableOrderItem)1 Order (org.broadleafcommerce.core.order.domain.Order)1