Search in sources :

Example 1 with Country

use of org.broadleafcommerce.profile.core.domain.Country in project BroadleafCommerce by BroadleafCommerce.

the class CheckoutTest method buildAddress.

private Address buildAddress() {
    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");
    State state = new StateImpl();
    state.setAbbreviation("ALL");
    state.setName("ALL");
    address.setState(state);
    Country country = new CountryImpl();
    country.setAbbreviation("US");
    country.setName("United States");
    state.setCountry(country);
    address.setCountry(country);
    ISOCountry isoCountry = new ISOCountryImpl();
    isoCountry.setAlpha2("US");
    isoCountry.setName("UNITED STATES");
    address.setIsoCountryAlpha2(isoCountry);
    return address;
}
Also used : Address(org.broadleafcommerce.profile.core.domain.Address) ISOCountryImpl(org.broadleafcommerce.common.i18n.domain.ISOCountryImpl) CountryImpl(org.broadleafcommerce.profile.core.domain.CountryImpl) State(org.broadleafcommerce.profile.core.domain.State) StateImpl(org.broadleafcommerce.profile.core.domain.StateImpl) AddressImpl(org.broadleafcommerce.profile.core.domain.AddressImpl) Country(org.broadleafcommerce.profile.core.domain.Country) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry) ISOCountryImpl(org.broadleafcommerce.common.i18n.domain.ISOCountryImpl) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry)

Example 2 with Country

use of org.broadleafcommerce.profile.core.domain.Country in project BroadleafCommerce by BroadleafCommerce.

the class PaymentResponseDTOToEntityServiceImpl method populateAddressInfo.

@Override
public void populateAddressInfo(AddressDTO<PaymentResponseDTO> dto, Address address) {
    address.setFirstName(dto.getAddressFirstName());
    address.setLastName(dto.getAddressLastName());
    address.setFullName(dto.getAddressFullName());
    address.setAddressLine1(dto.getAddressLine1());
    address.setAddressLine2(dto.getAddressLine2());
    address.setCity(dto.getAddressCityLocality());
    State state = null;
    if (dto.getAddressStateRegion() != null) {
        state = stateService.findStateByAbbreviation(dto.getAddressStateRegion());
    }
    if (state == null) {
        LOG.warn("The given state from the response: " + StringUtil.sanitize(dto.getAddressStateRegion()) + " could not be found" + " as a state abbreviation in BLC_STATE");
    }
    address.setState(state);
    CountrySubdivision isoCountrySub = countrySubdivisionService.findSubdivisionByAbbreviation(dto.getAddressStateRegion());
    if (isoCountrySub != null) {
        address.setIsoCountrySubdivision(isoCountrySub.getAbbreviation());
        address.setStateProvinceRegion(isoCountrySub.getName());
    } else {
        // Integration does not conform to the ISO Code standard - just set the non-referential state province region
        address.setStateProvinceRegion(dto.getAddressStateRegion());
    }
    address.setPostalCode(dto.getAddressPostalCode());
    Country country = null;
    ISOCountry isoCountry = null;
    if (dto.getAddressCountryCode() != null) {
        country = countryService.findCountryByAbbreviation(dto.getAddressCountryCode());
        isoCountry = isoService.findISOCountryByAlpha2Code(dto.getAddressCountryCode());
    }
    if (country == null) {
        LOG.warn("The given country from the response: " + StringUtil.sanitize(dto.getAddressCountryCode()) + " could not be found" + " as a country abbreviation in BLC_COUNTRY");
    } else if (isoCountry == null) {
        LOG.error("The given country from the response: " + StringUtil.sanitize(dto.getAddressCountryCode()) + " could not be found" + " as a country alpha-2 code in BLC_ISO_COUNTRY");
    }
    address.setCountry(country);
    address.setIsoCountryAlpha2(isoCountry);
    if (dto.getAddressPhone() != null) {
        Phone billingPhone = phoneService.create();
        billingPhone.setPhoneNumber(dto.getAddressPhone());
        address.setPhonePrimary(billingPhone);
    }
    if (dto.getAddressEmail() != null) {
        address.setEmailAddress(dto.getAddressEmail());
    }
    if (dto.getAddressCompanyName() != null) {
        address.setCompanyName(dto.getAddressCompanyName());
    }
    addressService.populateAddressISOCountrySub(address);
}
Also used : State(org.broadleafcommerce.profile.core.domain.State) Phone(org.broadleafcommerce.profile.core.domain.Phone) Country(org.broadleafcommerce.profile.core.domain.Country) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry) CountrySubdivision(org.broadleafcommerce.profile.core.domain.CountrySubdivision) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry)

Example 3 with Country

use of org.broadleafcommerce.profile.core.domain.Country 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 4 with Country

use of org.broadleafcommerce.profile.core.domain.Country in project BroadleafCommerce by BroadleafCommerce.

the class CommonSetupBaseTest method createCountry.

public void createCountry() {
    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);
}
Also used : ISOCountryImpl(org.broadleafcommerce.common.i18n.domain.ISOCountryImpl) CountryImpl(org.broadleafcommerce.profile.core.domain.CountryImpl) Country(org.broadleafcommerce.profile.core.domain.Country) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry) ISOCountryImpl(org.broadleafcommerce.common.i18n.domain.ISOCountryImpl) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry)

Example 5 with Country

use of org.broadleafcommerce.profile.core.domain.Country in project BroadleafCommerce by BroadleafCommerce.

the class CommonSetupBaseTest method saveCustomerAddress.

/**
 * Saves a customerAddress with state KY and country US.  Requires that createCountry() and createState() have been called
 * @param customerAddress
 */
public CustomerAddress saveCustomerAddress(CustomerAddress customerAddress) {
    State state = stateService.findStateByAbbreviation("KY");
    customerAddress.getAddress().setState(state);
    Country country = countryService.findCountryByAbbreviation("US");
    customerAddress.getAddress().setCountry(country);
    customerAddress.getAddress().setIsoCountrySubdivision("US-KY");
    ISOCountry isoCountry = isoService.findISOCountryByAlpha2Code("US");
    customerAddress.getAddress().setIsoCountryAlpha2(isoCountry);
    return customerAddressService.saveCustomerAddress(customerAddress);
}
Also used : State(org.broadleafcommerce.profile.core.domain.State) Country(org.broadleafcommerce.profile.core.domain.Country) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry) ISOCountry(org.broadleafcommerce.common.i18n.domain.ISOCountry)

Aggregations

ISOCountry (org.broadleafcommerce.common.i18n.domain.ISOCountry)11 Country (org.broadleafcommerce.profile.core.domain.Country)11 State (org.broadleafcommerce.profile.core.domain.State)10 ISOCountryImpl (org.broadleafcommerce.common.i18n.domain.ISOCountryImpl)7 CountryImpl (org.broadleafcommerce.profile.core.domain.CountryImpl)7 Address (org.broadleafcommerce.profile.core.domain.Address)6 AddressImpl (org.broadleafcommerce.profile.core.domain.AddressImpl)6 StateImpl (org.broadleafcommerce.profile.core.domain.StateImpl)6 Money (org.broadleafcommerce.common.money.Money)5 DiscreteOrderItem (org.broadleafcommerce.core.order.domain.DiscreteOrderItem)5 FulfillmentGroup (org.broadleafcommerce.core.order.domain.FulfillmentGroup)5 FulfillmentGroupImpl (org.broadleafcommerce.core.order.domain.FulfillmentGroupImpl)5 FulfillmentGroupItem (org.broadleafcommerce.core.order.domain.FulfillmentGroupItem)5 FulfillmentGroupItemImpl (org.broadleafcommerce.core.order.domain.FulfillmentGroupItemImpl)5 Sku (org.broadleafcommerce.core.catalog.domain.Sku)4 SkuImpl (org.broadleafcommerce.core.catalog.domain.SkuImpl)4 DiscreteOrderItemImpl (org.broadleafcommerce.core.order.domain.DiscreteOrderItemImpl)4 Order (org.broadleafcommerce.core.order.domain.Order)4 Phone (org.broadleafcommerce.profile.core.domain.Phone)4 ArrayList (java.util.ArrayList)3