use of org.broadleafcommerce.profile.core.domain.Address in project BroadleafCommerce by BroadleafCommerce.
the class PaymentResponseDTOToEntityServiceImpl method populateShippingInfo.
@Override
public void populateShippingInfo(PaymentResponseDTO responseDTO, Order order) {
FulfillmentGroup shippableFulfillmentGroup = fulfillmentGroupService.getFirstShippableFulfillmentGroup(order);
if (responseDTO.getShipTo() != null && responseDTO.getShipTo().addressPopulated() && shippableFulfillmentGroup != null) {
Address shippingAddress = addressService.create();
AddressDTO<PaymentResponseDTO> shipToDTO = responseDTO.getShipTo();
populateAddressInfo(shipToDTO, shippingAddress);
shippableFulfillmentGroup = fulfillmentGroupService.findFulfillmentGroupById(shippableFulfillmentGroup.getId());
if (shippableFulfillmentGroup != null) {
shippableFulfillmentGroup.setAddress(shippingAddress);
fulfillmentGroupService.save(shippableFulfillmentGroup);
}
}
}
use of org.broadleafcommerce.profile.core.domain.Address in project BroadleafCommerce by BroadleafCommerce.
the class OfferTest method createFulfillmentGroups.
private List<FulfillmentGroup> createFulfillmentGroups(FulfillmentOption option, Double shippingPrice, Order order) {
List<FulfillmentGroup> groups = new ArrayList<FulfillmentGroup>();
FulfillmentGroup group = new FulfillmentGroupImpl();
group.setFulfillmentOption(option);
groups.add(group);
group.setRetailShippingPrice(new Money(shippingPrice));
group.setOrder(order);
Address address = new AddressImpl();
address.setAddressLine1("123 Test Rd");
address.setCity("Dallas");
address.setFirstName("Jeff");
address.setLastName("Fischer");
address.setPostalCode("75240");
address.setPrimaryPhone("972-978-9067");
Country country = new CountryImpl();
country.setAbbreviation("US");
country.setName("United States");
countryService.save(country);
ISOCountry isoCountry = new ISOCountryImpl();
isoCountry.setAlpha2("US");
isoCountry.setName("UNITED STATES");
isoService.save(isoCountry);
State state = new StateImpl();
state.setAbbreviation("TX");
state.setName("Texas");
state.setCountry(country);
stateService.save(state);
address.setState(state);
address.setCountry(country);
address.setIsoCountrySubdivision("US-TX");
address.setIsoCountryAlpha2(isoCountry);
for (OrderItem orderItem : order.getOrderItems()) {
FulfillmentGroupItem fgItem = new FulfillmentGroupItemImpl();
fgItem.setFulfillmentGroup(group);
fgItem.setOrderItem(orderItem);
fgItem.setQuantity(orderItem.getQuantity());
group.addFulfillmentGroupItem(fgItem);
}
group.setAddress(address);
return groups;
}
use of org.broadleafcommerce.profile.core.domain.Address 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.profile.core.domain.Address 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.profile.core.domain.Address 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;
}
Aggregations