use of org.broadleafcommerce.core.order.service.call.FulfillmentGroupItemRequest in project BroadleafCommerce by BroadleafCommerce.
the class LegacyOrderServiceImpl method addFulfillmentGroupToOrder.
@Override
public FulfillmentGroup addFulfillmentGroupToOrder(FulfillmentGroupRequest fulfillmentGroupRequest, boolean priceOrder) throws PricingException {
FulfillmentGroup fg = fulfillmentGroupDao.create();
fg.setAddress(fulfillmentGroupRequest.getAddress());
fg.setOrder(fulfillmentGroupRequest.getOrder());
fg.setPhone(fulfillmentGroupRequest.getPhone());
fg.setMethod(fulfillmentGroupRequest.getMethod());
fg.setService(fulfillmentGroupRequest.getService());
for (int i = 0; i < fulfillmentGroupRequest.getFulfillmentGroupItemRequests().size(); i++) {
FulfillmentGroupItemRequest request = fulfillmentGroupRequest.getFulfillmentGroupItemRequests().get(i);
boolean shouldPriceOrder = (priceOrder && (i == (fulfillmentGroupRequest.getFulfillmentGroupItemRequests().size() - 1)));
fg = addItemToFulfillmentGroup(request.getOrderItem(), fg, request.getQuantity(), shouldPriceOrder);
}
return fg;
}
use of org.broadleafcommerce.core.order.service.call.FulfillmentGroupItemRequest in project BroadleafCommerce by BroadleafCommerce.
the class FulfillmentGroupItemStrategyImpl method addItemToFulfillmentGroup.
protected FulfillmentGroup addItemToFulfillmentGroup(Order order, OrderItem orderItem, int quantity, FulfillmentGroup fulfillmentGroup) throws PricingException {
FulfillmentGroupItemRequest fulfillmentGroupItemRequest = new FulfillmentGroupItemRequest();
fulfillmentGroupItemRequest.setOrder(order);
fulfillmentGroupItemRequest.setOrderItem(orderItem);
fulfillmentGroupItemRequest.setQuantity(quantity);
fulfillmentGroupItemRequest.setFulfillmentGroup(fulfillmentGroup);
return fulfillmentGroupService.addItemToFulfillmentGroup(fulfillmentGroupItemRequest, false, false);
}
use of org.broadleafcommerce.core.order.service.call.FulfillmentGroupItemRequest in project BroadleafCommerce by BroadleafCommerce.
the class FulfillmentGroupItemDaoTest method createFulfillmentGroupItem.
@Test(groups = { "createFulfillmentGroupItem" }, dataProvider = "basicDiscreteOrderItem", dataProviderClass = OrderItemDataProvider.class, dependsOnGroups = { "createOrder", "createSku", "createItemFulfillmentGroup" })
@Rollback(false)
@Transactional
public void createFulfillmentGroupItem(DiscreteOrderItem orderItem) throws PricingException {
Sku si = skuDao.readFirstSku();
orderItem.setSku(si);
orderItem = (DiscreteOrderItem) orderItemDao.save(orderItem);
orderItem.setOrder(salesOrder);
salesOrder.addOrderItem(orderItem);
orderDao.save(salesOrder);
FulfillmentGroupItemRequest fulfillmentGroupItemRequest = new FulfillmentGroupItemRequest();
fulfillmentGroupItemRequest.setOrderItem(orderItem);
fulfillmentGroupItemRequest.setFulfillmentGroup(fulfillmentGroup);
fulfillmentGroupService.addItemToFulfillmentGroup(fulfillmentGroupItemRequest, true);
FulfillmentGroupItem fgi = fulfillmentGroup.getFulfillmentGroupItems().get(fulfillmentGroup.getFulfillmentGroupItems().size() - 1);
assert fgi.getId() != null;
fulfillmentGroupItemId = fgi.getId();
}
use of org.broadleafcommerce.core.order.service.call.FulfillmentGroupItemRequest in project BroadleafCommerce by BroadleafCommerce.
the class FulfillmentGroupServiceImpl method addFulfillmentGroupToOrder.
@Override
@Transactional("blTransactionManager")
public FulfillmentGroup addFulfillmentGroupToOrder(FulfillmentGroupRequest fulfillmentGroupRequest, boolean priceOrder) throws PricingException {
FulfillmentGroup fg = fulfillmentGroupDao.create();
fg.setAddress(fulfillmentGroupRequest.getAddress());
fg.setOrder(fulfillmentGroupRequest.getOrder());
fg.setPhone(fulfillmentGroupRequest.getPhone());
fg.setFulfillmentOption(fulfillmentGroupRequest.getOption());
fg.setType(fulfillmentGroupRequest.getFulfillmentType());
for (int i = 0; i < fulfillmentGroupRequest.getFulfillmentGroupItemRequests().size(); i++) {
FulfillmentGroupItemRequest request = fulfillmentGroupRequest.getFulfillmentGroupItemRequests().get(i);
request.setFulfillmentGroup(fg);
request.setOrder(fulfillmentGroupRequest.getOrder());
boolean shouldPriceOrder = (priceOrder && (i == (fulfillmentGroupRequest.getFulfillmentGroupItemRequests().size() - 1)));
fg = addItemToFulfillmentGroup(request, shouldPriceOrder);
}
return fg;
}
use of org.broadleafcommerce.core.order.service.call.FulfillmentGroupItemRequest in project BroadleafCommerce by BroadleafCommerce.
the class OfferDataItemProvider method getAddItemToFulfillmentGroupAnswer.
public static IAnswer<FulfillmentGroup> getAddItemToFulfillmentGroupAnswer() {
return new IAnswer<FulfillmentGroup>() {
@Override
public FulfillmentGroup answer() throws Throwable {
FulfillmentGroupItemRequest fgItemRequest = (FulfillmentGroupItemRequest) EasyMock.getCurrentArguments()[0];
FulfillmentGroup fg = fgItemRequest.getFulfillmentGroup();
FulfillmentGroupItem fgItem = new FulfillmentGroupItemImpl();
fgItem.setOrderItem(fgItemRequest.getOrderItem());
fgItem.setQuantity(fgItemRequest.getQuantity());
fg.getFulfillmentGroupItems().add(fgItem);
return fg;
}
};
}
Aggregations