Search in sources :

Example 1 with FulfillmentGroupItemRequest

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;
}
Also used : FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) FulfillmentGroupItemRequest(org.broadleafcommerce.core.order.service.call.FulfillmentGroupItemRequest)

Example 2 with FulfillmentGroupItemRequest

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);
}
Also used : FulfillmentGroupItemRequest(org.broadleafcommerce.core.order.service.call.FulfillmentGroupItemRequest)

Example 3 with FulfillmentGroupItemRequest

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();
}
Also used : FulfillmentGroupItem(org.broadleafcommerce.core.order.domain.FulfillmentGroupItem) Sku(org.broadleafcommerce.core.catalog.domain.Sku) FulfillmentGroupItemRequest(org.broadleafcommerce.core.order.service.call.FulfillmentGroupItemRequest) Test(org.testng.annotations.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with FulfillmentGroupItemRequest

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;
}
Also used : FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) FulfillmentGroupItemRequest(org.broadleafcommerce.core.order.service.call.FulfillmentGroupItemRequest) Transactional(org.springframework.transaction.annotation.Transactional)

Example 5 with FulfillmentGroupItemRequest

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;
        }
    };
}
Also used : IAnswer(org.easymock.IAnswer) FulfillmentGroupItem(org.broadleafcommerce.core.order.domain.FulfillmentGroupItem) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) FulfillmentGroupItemRequest(org.broadleafcommerce.core.order.service.call.FulfillmentGroupItemRequest) FulfillmentGroupItemImpl(org.broadleafcommerce.core.order.domain.FulfillmentGroupItemImpl)

Aggregations

FulfillmentGroupItemRequest (org.broadleafcommerce.core.order.service.call.FulfillmentGroupItemRequest)5 FulfillmentGroup (org.broadleafcommerce.core.order.domain.FulfillmentGroup)3 FulfillmentGroupItem (org.broadleafcommerce.core.order.domain.FulfillmentGroupItem)2 Transactional (org.springframework.transaction.annotation.Transactional)2 Sku (org.broadleafcommerce.core.catalog.domain.Sku)1 FulfillmentGroupItemImpl (org.broadleafcommerce.core.order.domain.FulfillmentGroupItemImpl)1 IAnswer (org.easymock.IAnswer)1 Rollback (org.springframework.test.annotation.Rollback)1 Test (org.testng.annotations.Test)1