Search in sources :

Example 11 with FulfillmentGroup

use of org.broadleafcommerce.core.order.domain.FulfillmentGroup in project BroadleafCommerce by BroadleafCommerce.

the class FulfillmentGroupDaoTest method createFulfillmentGroup.

@Test(groups = "createFulfillmentGroup", dataProvider = "basicFulfillmentGroup", dataProviderClass = FulfillmentGroupDataProvider.class)
@Transactional
@Rollback(false)
public void createFulfillmentGroup(FulfillmentGroup fulfillmentGroup) {
    Customer customer = createCustomerWithBasicOrderAndAddresses();
    Address address = (customerAddressDao.readActiveCustomerAddressesByCustomerId(customer.getId())).get(0).getAddress();
    Order salesOrder = orderDao.readOrdersForCustomer(customer.getId()).get(0);
    FulfillmentGroup newFG = fulfillmentGroupDao.create();
    newFG.setAddress(address);
    newFG.setRetailShippingPrice(fulfillmentGroup.getRetailShippingPrice());
    newFG.setMethod(fulfillmentGroup.getMethod());
    newFG.setService(fulfillmentGroup.getService());
    newFG.setReferenceNumber(fulfillmentGroup.getReferenceNumber());
    newFG.setOrder(salesOrder);
    assert newFG.getId() == null;
    fulfillmentGroup = fulfillmentGroupService.save(newFG);
    assert fulfillmentGroup.getId() != null;
    fulfillmentGroupId = fulfillmentGroup.getId();
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Address(org.broadleafcommerce.profile.core.domain.Address) Customer(org.broadleafcommerce.profile.core.domain.Customer) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) CommonSetupBaseTest(org.broadleafcommerce.test.CommonSetupBaseTest) Test(org.testng.annotations.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 12 with FulfillmentGroup

use of org.broadleafcommerce.core.order.domain.FulfillmentGroup in project BroadleafCommerce by BroadleafCommerce.

the class FulfillmentGroupDaoTest method readDefaultFulfillmentGroupForOrder.

@Test(groups = { "readDefaultFulfillmentGroupForOrder" }, dependsOnGroups = { "createDefaultFulfillmentGroup" })
@Transactional
public void readDefaultFulfillmentGroupForOrder() {
    Order order = orderDao.readOrderById(defaultFulfillmentGroupOrderId);
    assert order != null;
    assert order.getId() == defaultFulfillmentGroupOrderId;
    FulfillmentGroup fg = fulfillmentGroupDao.readDefaultFulfillmentGroupForOrder(order);
    assert fg.getId() != null;
    assert fg.getId().equals(defaultFulfillmentGroupId);
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) CommonSetupBaseTest(org.broadleafcommerce.test.CommonSetupBaseTest) Test(org.testng.annotations.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 13 with FulfillmentGroup

use of org.broadleafcommerce.core.order.domain.FulfillmentGroup in project BroadleafCommerce by BroadleafCommerce.

the class FulfillmentGroupDaoTest method createDefaultFulfillmentGroup.

@Test(groups = "createDefaultFulfillmentGroup", dataProvider = "basicFulfillmentGroup", dataProviderClass = FulfillmentGroupDataProvider.class)
@Transactional
@Rollback(false)
public void createDefaultFulfillmentGroup(FulfillmentGroup fulfillmentGroup) {
    Customer customer = createCustomerWithBasicOrderAndAddresses();
    Address address = (customerAddressDao.readActiveCustomerAddressesByCustomerId(customer.getId())).get(0).getAddress();
    Order salesOrder = orderDao.readOrdersForCustomer(customer.getId()).get(0);
    FulfillmentGroup newFG = fulfillmentGroupDao.createDefault();
    newFG.setAddress(address);
    newFG.setRetailShippingPrice(fulfillmentGroup.getRetailShippingPrice());
    newFG.setMethod(fulfillmentGroup.getMethod());
    newFG.setService(fulfillmentGroup.getService());
    newFG.setOrder(salesOrder);
    newFG.setReferenceNumber(fulfillmentGroup.getReferenceNumber());
    assert newFG.getId() == null;
    fulfillmentGroup = fulfillmentGroupService.save(newFG);
    assert fulfillmentGroup.getId() != null;
    defaultFulfillmentGroupOrderId = salesOrder.getId();
    defaultFulfillmentGroupId = fulfillmentGroup.getId();
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Address(org.broadleafcommerce.profile.core.domain.Address) Customer(org.broadleafcommerce.profile.core.domain.Customer) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) CommonSetupBaseTest(org.broadleafcommerce.test.CommonSetupBaseTest) Test(org.testng.annotations.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with FulfillmentGroup

use of org.broadleafcommerce.core.order.domain.FulfillmentGroup in project BroadleafCommerce by BroadleafCommerce.

the class FulfillmentGroupItemDaoTest method createDefaultFulfillmentGroup.

@Test(groups = "createItemFulfillmentGroup", dataProvider = "basicFulfillmentGroup", dataProviderClass = FulfillmentGroupDataProvider.class, dependsOnGroups = { "createOrder", "createCustomerAddress" })
@Rollback(false)
@Transactional
public void createDefaultFulfillmentGroup(FulfillmentGroup fulfillmentGroup) {
    String userName = "customer1";
    Customer customer = customerService.readCustomerByUsername(userName);
    Address address = (customerAddressDao.readActiveCustomerAddressesByCustomerId(customer.getId())).get(0).getAddress();
    salesOrder = orderDao.createNewCartForCustomer(customer);
    FulfillmentGroup newFG = fulfillmentGroupDao.createDefault();
    newFG.setAddress(address);
    newFG.setRetailShippingPrice(fulfillmentGroup.getRetailShippingPrice());
    newFG.setMethod(fulfillmentGroup.getMethod());
    newFG.setService(fulfillmentGroup.getService());
    newFG.setOrder(salesOrder);
    newFG.setReferenceNumber(fulfillmentGroup.getReferenceNumber());
    assert newFG.getId() == null;
    this.fulfillmentGroup = fulfillmentGroupService.save(newFG);
    assert this.fulfillmentGroup.getId() != null;
}
Also used : Address(org.broadleafcommerce.profile.core.domain.Address) Customer(org.broadleafcommerce.profile.core.domain.Customer) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) Test(org.testng.annotations.Test) Rollback(org.springframework.test.annotation.Rollback) Transactional(org.springframework.transaction.annotation.Transactional)

Example 15 with FulfillmentGroup

use of org.broadleafcommerce.core.order.domain.FulfillmentGroup in project BroadleafCommerce by BroadleafCommerce.

the class FulfillmentItemPricingActivityTest method testDistributeOneDollarAcrossFiveEqualItems.

public void testDistributeOneDollarAcrossFiveEqualItems() throws Exception {
    Order order = dataProvider.createBasicOrder();
    Money subTotal = new Money(order.getCurrency());
    for (OrderItem orderItem : order.getOrderItems()) {
        orderItem.setSalePrice(new Money(10D));
        orderItem.getOrderItemPriceDetails().clear();
        subTotal = subTotal.add(orderItem.getTotalPrice());
    }
    OrderAdjustment adjustment = new OrderAdjustmentImpl();
    adjustment.setValue(new Money(new BigDecimal("1"), order.getCurrency()));
    order.getOrderAdjustments().add(adjustment);
    adjustment.setOrder(order);
    order.setSubTotal(subTotal);
    ProcessContext<Order> context = new DefaultProcessContextImpl<Order>();
    context.setSeedData(order);
    fulfillmentItemPricingActivity.execute(context);
    // Each item is equally priced, so the adjustment should be .20 per item.
    Money proratedAdjustment = new Money(".20");
    for (FulfillmentGroup fulfillmentGroup : order.getFulfillmentGroups()) {
        for (FulfillmentGroupItem fulfillmentGroupItem : fulfillmentGroup.getFulfillmentGroupItems()) {
            assertTrue(fulfillmentGroupItem.getProratedOrderAdjustmentAmount().compareTo(proratedAdjustment.multiply(fulfillmentGroupItem.getQuantity())) == 0);
        }
    }
}
Also used : Order(org.broadleafcommerce.core.order.domain.Order) Money(org.broadleafcommerce.common.money.Money) OrderAdjustmentImpl(org.broadleafcommerce.core.offer.domain.OrderAdjustmentImpl) OrderAdjustment(org.broadleafcommerce.core.offer.domain.OrderAdjustment) DefaultProcessContextImpl(org.broadleafcommerce.core.workflow.DefaultProcessContextImpl) OrderItem(org.broadleafcommerce.core.order.domain.OrderItem) BundleOrderItem(org.broadleafcommerce.core.order.domain.BundleOrderItem) FulfillmentGroupItem(org.broadleafcommerce.core.order.domain.FulfillmentGroupItem) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) BigDecimal(java.math.BigDecimal)

Aggregations

FulfillmentGroup (org.broadleafcommerce.core.order.domain.FulfillmentGroup)67 FulfillmentGroupItem (org.broadleafcommerce.core.order.domain.FulfillmentGroupItem)39 Order (org.broadleafcommerce.core.order.domain.Order)32 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)24 Money (org.broadleafcommerce.common.money.Money)22 OrderItem (org.broadleafcommerce.core.order.domain.OrderItem)19 Transactional (org.springframework.transaction.annotation.Transactional)17 ArrayList (java.util.ArrayList)16 BundleOrderItem (org.broadleafcommerce.core.order.domain.BundleOrderItem)15 Address (org.broadleafcommerce.profile.core.domain.Address)15 Test (org.testng.annotations.Test)12 Sku (org.broadleafcommerce.core.catalog.domain.Sku)9 FulfillmentGroupImpl (org.broadleafcommerce.core.order.domain.FulfillmentGroupImpl)9 FulfillmentGroupItemImpl (org.broadleafcommerce.core.order.domain.FulfillmentGroupItemImpl)8 Customer (org.broadleafcommerce.profile.core.domain.Customer)8 HashMap (java.util.HashMap)7 BigDecimal (java.math.BigDecimal)6 SkuImpl (org.broadleafcommerce.core.catalog.domain.SkuImpl)6 DiscreteOrderItemImpl (org.broadleafcommerce.core.order.domain.DiscreteOrderItemImpl)6 ISOCountry (org.broadleafcommerce.common.i18n.domain.ISOCountry)5