use of org.broadleafcommerce.core.order.fulfillment.domain.FixedPriceFulfillmentOption in project BroadleafCommerce by BroadleafCommerce.
the class OfferTest method testPercentOffOfferWithScaleGreaterThanTwo.
@Test(groups = { "testPercentageOffOffer" }, dependsOnGroups = { "offerCreateSku1", "offerCreateSku2" })
@Transactional
public void testPercentOffOfferWithScaleGreaterThanTwo() throws Exception {
Order order = orderService.createNewCartForCustomer(createCustomer());
FixedPriceFulfillmentOption option = new FixedPriceFulfillmentOptionImpl();
option.setPrice(new Money(0));
option.setFulfillmentType(FulfillmentType.PHYSICAL_SHIP);
order.setFulfillmentGroups(createFulfillmentGroups(option, 5D, order));
orderService.save(order, false);
order.addOrderItem(createDiscreteOrderItem(sku1, 100D, null, true, 2, order));
order.addOrderItem(createDiscreteOrderItem(sku2, 100D, null, true, 1, order));
order.addOfferCode(createOfferUtility.createOfferCode("20.5 Percent Off Item Offer", OfferType.ORDER_ITEM, OfferDiscountType.PERCENT_OFF, 20.5, null, true, true, 10));
List<Offer> offers = offerService.buildOfferListForOrder(order);
offerService.applyAndSaveOffersToOrder(offers, order);
// 20% results in $240. 20.5% off results in $238.50
assert (order.getSubTotal().equals(new Money(238.50D)));
}
use of org.broadleafcommerce.core.order.fulfillment.domain.FixedPriceFulfillmentOption in project BroadleafCommerce by BroadleafCommerce.
the class FixedPriceFulfillmentTest method testNullFulfillmentOptionInEstimation.
public void testNullFulfillmentOptionInEstimation() throws Exception {
Set<FulfillmentOption> options = new HashSet<FulfillmentOption>();
FixedPriceFulfillmentOption option1 = new FixedPriceFulfillmentOptionImpl();
option1.setPrice(new Money(BigDecimal.ONE));
FixedPriceFulfillmentOption option2 = new FixedPriceFulfillmentOptionImpl();
option2.setPrice(new Money(BigDecimal.TEN));
options.add(option1);
options.add(option2);
FixedPriceFulfillmentPricingProvider provider = new FixedPriceFulfillmentPricingProvider();
FulfillmentGroup fg = new FulfillmentGroupImpl();
FulfillmentEstimationResponse response = provider.estimateCostForFulfillmentGroup(fg, options);
for (Entry<? extends FulfillmentOption, Money> entry : response.getFulfillmentOptionPrices().entrySet()) {
assertEquals(((FixedPriceFulfillmentOption) entry.getKey()).getPrice(), entry.getValue());
}
}
Aggregations