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();
}
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);
}
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();
}
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;
}
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);
}
}
}
Aggregations