use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class OfferTest method testPercentOffOfferWithItemMinPriceSecondEvaluation.
@Test(groups = { "testPercentageOffOffer" }, dependsOnGroups = { "offerCreateSku1" })
@Transactional
public void testPercentOffOfferWithItemMinPriceSecondEvaluation() throws Exception {
Order order = orderService.createNewCartForCustomer(createCustomer());
order.addOrderItem(createDiscreteOrderItem(sku1, 10D, null, true, 1, order));
order.addOfferCode(createOfferUtility.createOfferCode("75 Percent Off Items Over $5.00", OfferType.ORDER_ITEM, OfferDiscountType.PERCENT_OFF, 75, "orderItem.?price.getAmount()>5.00", true, true, 10));
List<Offer> offers = offerService.buildOfferListForOrder(order);
offerService.applyAndSaveOffersToOrder(offers, order);
// Evaluate the subtotal again to ensure that the second calculation
// is based on the pre-offer price, not the reduced price
offerService.applyAndSaveOffersToOrder(offers, order);
assert (order.getSubTotal().equals(new Money(2.50D)));
}
use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class OfferTest method createFulfillmentGroups.
private List<FulfillmentGroup> createFulfillmentGroups(FulfillmentOption option, Double shippingPrice, Order order) {
List<FulfillmentGroup> groups = new ArrayList<FulfillmentGroup>();
FulfillmentGroup group = new FulfillmentGroupImpl();
group.setFulfillmentOption(option);
groups.add(group);
group.setRetailShippingPrice(new Money(shippingPrice));
group.setOrder(order);
Address address = new AddressImpl();
address.setAddressLine1("123 Test Rd");
address.setCity("Dallas");
address.setFirstName("Jeff");
address.setLastName("Fischer");
address.setPostalCode("75240");
address.setPrimaryPhone("972-978-9067");
Country country = new CountryImpl();
country.setAbbreviation("US");
country.setName("United States");
countryService.save(country);
ISOCountry isoCountry = new ISOCountryImpl();
isoCountry.setAlpha2("US");
isoCountry.setName("UNITED STATES");
isoService.save(isoCountry);
State state = new StateImpl();
state.setAbbreviation("TX");
state.setName("Texas");
state.setCountry(country);
stateService.save(state);
address.setState(state);
address.setCountry(country);
address.setIsoCountrySubdivision("US-TX");
address.setIsoCountryAlpha2(isoCountry);
for (OrderItem orderItem : order.getOrderItems()) {
FulfillmentGroupItem fgItem = new FulfillmentGroupItemImpl();
fgItem.setFulfillmentGroup(group);
fgItem.setOrderItem(orderItem);
fgItem.setQuantity(orderItem.getQuantity());
group.addFulfillmentGroupItem(fgItem);
}
group.setAddress(address);
return groups;
}
use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class FulfillmentGroupDataProvider method provideBasicSalesFulfillmentGroup.
@DataProvider(name = "basicFulfillmentGroup")
public static Object[][] provideBasicSalesFulfillmentGroup() {
FulfillmentGroupImpl sos = new FulfillmentGroupImpl();
sos.setReferenceNumber("123456789");
FixedPriceFulfillmentOption option = new FixedPriceFulfillmentOptionImpl();
option.setPrice(new Money(0));
sos.setFulfillmentOption(option);
return new Object[][] { { sos } };
}
use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class OrderDataProvider method provideBasicSalesOrder.
@DataProvider(name = "basicOrder")
public static Object[][] provideBasicSalesOrder() {
OrderImpl so = new OrderImpl();
so.setStatus(OrderStatus.IN_PROCESS);
so.setTotal(new Money(BigDecimal.valueOf(1000)));
return new Object[][] { { so } };
}
use of org.broadleafcommerce.common.money.Money in project BroadleafCommerce by BroadleafCommerce.
the class OrderItemDataProvider method provideBasicDiscreteSalesOrderItem.
@DataProvider(name = "basicDiscreteOrderItem")
public static Object[][] provideBasicDiscreteSalesOrderItem() {
OrderItemImpl soi = new DiscreteOrderItemImpl();
soi.setRetailPrice(new Money(BigDecimal.valueOf(10.25)));
soi.setQuantity(3);
return new Object[][] { { soi } };
}
Aggregations