Search in sources :

Example 6 with Address

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);
        }
    }
}
Also used : Address(org.broadleafcommerce.profile.core.domain.Address) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) PaymentResponseDTO(org.broadleafcommerce.common.payment.dto.PaymentResponseDTO)

Example 7 with Address

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;
}
Also used : FulfillmentGroupImpl(org.broadleafcommerce.core.order.domain.FulfillmentGroupImpl) Address(org.broadleafcommerce.profile.core.domain.Address) ArrayList(java.util.ArrayList) StateImpl(org.broadleafcommerce.profile.core.domain.StateImpl) Money(org.broadleafcommerce.common.money.Money) ISOCountryImpl(org.broadleafcommerce.common.i18n.domain.ISOCountryImpl) CountryImpl(org.broadleafcommerce.profile.core.domain.CountryImpl) State(org.broadleafcommerce.profile.core.domain.State) OrderItem(org.broadleafcommerce.core.order.domain.OrderItem) DiscreteOrderItem(org.broadleafcommerce.core.order.domain.DiscreteOrderItem) FulfillmentGroupItem(org.broadleafcommerce.core.order.domain.FulfillmentGroupItem) AddressImpl(org.broadleafcommerce.profile.core.domain.AddressImpl) Country(org.broadleafcommerce.profile.core.domain.Country) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry) FulfillmentGroup(org.broadleafcommerce.core.order.domain.FulfillmentGroup) ISOCountryImpl(org.broadleafcommerce.common.i18n.domain.ISOCountryImpl) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry) FulfillmentGroupItemImpl(org.broadleafcommerce.core.order.domain.FulfillmentGroupItemImpl)

Example 8 with Address

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();
}
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 9 with Address

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();
}
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 10 with Address

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

Aggregations

Address (org.broadleafcommerce.profile.core.domain.Address)37 FulfillmentGroup (org.broadleafcommerce.core.order.domain.FulfillmentGroup)15 Order (org.broadleafcommerce.core.order.domain.Order)15 Customer (org.broadleafcommerce.profile.core.domain.Customer)14 AddressImpl (org.broadleafcommerce.profile.core.domain.AddressImpl)11 CustomerAddress (org.broadleafcommerce.profile.core.domain.CustomerAddress)11 Transactional (org.springframework.transaction.annotation.Transactional)10 Test (org.testng.annotations.Test)10 FulfillmentGroupItem (org.broadleafcommerce.core.order.domain.FulfillmentGroupItem)9 Money (org.broadleafcommerce.common.money.Money)8 ArrayList (java.util.ArrayList)7 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)7 State (org.broadleafcommerce.profile.core.domain.State)7 StateImpl (org.broadleafcommerce.profile.core.domain.StateImpl)7 ISOCountry (org.broadleafcommerce.common.i18n.domain.ISOCountry)6 ISOCountryImpl (org.broadleafcommerce.common.i18n.domain.ISOCountryImpl)6 FulfillmentGroupImpl (org.broadleafcommerce.core.order.domain.FulfillmentGroupImpl)6 FulfillmentGroupItemImpl (org.broadleafcommerce.core.order.domain.FulfillmentGroupItemImpl)6 Country (org.broadleafcommerce.profile.core.domain.Country)6 CountryImpl (org.broadleafcommerce.profile.core.domain.CountryImpl)6