use of org.broadleafcommerce.core.offer.domain.OrderAdjustment in project BroadleafCommerce by BroadleafCommerce.
the class FulfillmentItemPricingActivityTest method testRoundingRequired.
public void testRoundingRequired() throws Exception {
Order order = dataProvider.createBasicOrder();
Money subTotal = new Money(order.getCurrency());
for (OrderItem orderItem : order.getOrderItems()) {
orderItem.getOrderItemPriceDetails().clear();
orderItem.setQuantity(2);
orderItem.setSalePrice(new Money(10D));
subTotal = subTotal.add(orderItem.getTotalPrice());
}
order.setSubTotal(subTotal);
OrderAdjustment adjustment = new OrderAdjustmentImpl();
adjustment.setValue(new Money(new BigDecimal(".05"), order.getCurrency()));
adjustment.setOrder(order);
order.getOrderAdjustments().add(adjustment);
ProcessContext<Order> context = new DefaultProcessContextImpl<Order>();
context.setSeedData(order);
fulfillmentItemPricingActivity.execute(context);
assertTrue(sumProratedOfferAdjustments(order).equals(new Money(new BigDecimal(".05"), order.getCurrency())));
}
use of org.broadleafcommerce.core.offer.domain.OrderAdjustment in project BroadleafCommerce by BroadleafCommerce.
the class FulfillmentItemPricingActivityTest method testDistributeOneDollarAcrossFiveItems.
public void testDistributeOneDollarAcrossFiveItems() throws Exception {
Order order = dataProvider.createBasicOrder();
OrderAdjustment adjustment = new OrderAdjustmentImpl();
adjustment.setValue(new Money(new BigDecimal("1"), order.getCurrency()));
adjustment.setOrder(order);
order.getOrderAdjustments().add(adjustment);
ProcessContext<Order> context = new DefaultProcessContextImpl<Order>();
context.setSeedData(order);
fulfillmentItemPricingActivity.execute(context);
Money adj1 = new Money(".31");
Money adj2 = new Money(".69");
for (FulfillmentGroup fulfillmentGroup : order.getFulfillmentGroups()) {
for (FulfillmentGroupItem fulfillmentGroupItem : fulfillmentGroup.getFulfillmentGroupItems()) {
if (fulfillmentGroupItem.getSalePrice().equals(new Money("19.99"))) {
assertTrue(fulfillmentGroupItem.getProratedOrderAdjustmentAmount().equals(adj1));
} else {
assertTrue(fulfillmentGroupItem.getProratedOrderAdjustmentAmount().equals(adj2));
}
}
}
}
Aggregations