use of com.salesmanager.core.model.common.Billing in project shopizer by shopizer-ecommerce.
the class OrderFacadeImpl method getShippingQuote.
@Override
public ShippingQuote getShippingQuote(Customer customer, ShoppingCart cart, MerchantStore store, Language language) throws Exception {
Validate.notNull(customer, "Customer cannot be null");
Validate.notNull(cart, "cart cannot be null");
// create shipping products
List<ShippingProduct> shippingProducts = shoppingCartService.createShippingProduct(cart);
if (CollectionUtils.isEmpty(shippingProducts)) {
// products are virtual
return null;
}
Delivery delivery = new Delivery();
Billing billing = new Billing();
// default value
billing.setCountry(store.getCountry());
// adjust shipping and billing
if (customer.getDelivery() == null || StringUtils.isBlank(customer.getDelivery().getPostalCode())) {
if (customer.getBilling() != null) {
billing = customer.getBilling();
}
delivery.setAddress(billing.getAddress());
delivery.setCity(billing.getCity());
delivery.setCompany(billing.getCompany());
delivery.setPostalCode(billing.getPostalCode());
delivery.setState(billing.getState());
delivery.setCountry(billing.getCountry());
delivery.setZone(billing.getZone());
} else {
delivery = customer.getDelivery();
}
ShippingQuote quote = shippingService.getShippingQuote(cart.getId(), store, delivery, shippingProducts, language);
return quote;
}
use of com.salesmanager.core.model.common.Billing in project shopizer by shopizer-ecommerce.
the class OrderFacadeImpl method getShippingQuote.
@Override
public ShippingQuote getShippingQuote(PersistableCustomer persistableCustomer, ShoppingCart cart, ShopOrder order, MerchantStore store, Language language) throws Exception {
// create shipping products
List<ShippingProduct> shippingProducts = shoppingCartService.createShippingProduct(cart);
if (CollectionUtils.isEmpty(shippingProducts)) {
// products are virtual
return null;
}
Customer customer = customerFacade.getCustomerModel(persistableCustomer, store, language);
Delivery delivery = new Delivery();
// adjust shipping and billing
if (order.isShipToBillingAdress() && !order.isShipToDeliveryAddress()) {
Billing billing = customer.getBilling();
String postalCode = billing.getPostalCode();
postalCode = validatePostalCode(postalCode);
delivery.setAddress(billing.getAddress());
delivery.setCompany(billing.getCompany());
delivery.setCity(billing.getCity());
delivery.setPostalCode(billing.getPostalCode());
delivery.setState(billing.getState());
delivery.setCountry(billing.getCountry());
delivery.setZone(billing.getZone());
} else {
delivery = customer.getDelivery();
}
ShippingQuote quote = shippingService.getShippingQuote(cart.getId(), store, delivery, shippingProducts, language);
return quote;
}
use of com.salesmanager.core.model.common.Billing in project shopizer by shopizer-ecommerce.
the class OrderFacadeImpl method convertBilling.
private Billing convertBilling(Address source) throws ServiceException {
Billing target = new Billing();
target.setCity(source.getCity());
target.setCompany(source.getCompany());
target.setFirstName(source.getFirstName());
target.setLastName(source.getLastName());
target.setPostalCode(source.getPostalCode());
target.setTelephone(source.getPhone());
target.setAddress(source.getAddress());
if (source.getCountry() != null) {
target.setCountry(countryService.getByCode(source.getCountry()));
}
if (source.getZone() != null) {
target.setZone(zoneService.getByCode(source.getZone()));
}
target.setState(source.getBilstateOther());
return target;
}
use of com.salesmanager.core.model.common.Billing in project shopizer by shopizer-ecommerce.
the class OrderFacadeImpl method initEmptyCustomer.
@Override
public Customer initEmptyCustomer(MerchantStore store) {
Customer customer = new Customer();
Billing billing = new Billing();
billing.setCountry(store.getCountry());
billing.setZone(store.getZone());
billing.setState(store.getStorestateprovince());
/**
* empty postal code for initial quote *
*/
// billing.setPostalCode(store.getStorepostalcode());
customer.setBilling(billing);
Delivery delivery = new Delivery();
delivery.setCountry(store.getCountry());
delivery.setZone(store.getZone());
delivery.setState(store.getStorestateprovince());
/**
* empty postal code for initial quote *
*/
// delivery.setPostalCode(store.getStorepostalcode());
customer.setDelivery(delivery);
return customer;
}
use of com.salesmanager.core.model.common.Billing in project shopizer by shopizer-ecommerce.
the class OrderFacadeImpl method getShippingQuote.
@Override
public ShippingQuote getShippingQuote(Customer customer, ShoppingCart cart, com.salesmanager.shop.model.order.v0.PersistableOrder order, MerchantStore store, Language language) throws Exception {
// create shipping products
List<ShippingProduct> shippingProducts = shoppingCartService.createShippingProduct(cart);
if (CollectionUtils.isEmpty(shippingProducts)) {
// products are virtual
return null;
}
Delivery delivery = new Delivery();
// adjust shipping and billing
if (order.isShipToBillingAdress()) {
Billing billing = customer.getBilling();
delivery.setAddress(billing.getAddress());
delivery.setCity(billing.getCity());
delivery.setCompany(billing.getCompany());
delivery.setPostalCode(billing.getPostalCode());
delivery.setState(billing.getState());
delivery.setCountry(billing.getCountry());
delivery.setZone(billing.getZone());
} else {
delivery = customer.getDelivery();
}
ShippingQuote quote = shippingService.getShippingQuote(cart.getId(), store, delivery, shippingProducts, language);
return quote;
}
Aggregations