Search in sources :

Example 6 with Billing

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;
}
Also used : ShippingQuote(com.salesmanager.core.model.shipping.ShippingQuote) Billing(com.salesmanager.core.model.common.Billing) ShippingProduct(com.salesmanager.core.model.shipping.ShippingProduct) Delivery(com.salesmanager.core.model.common.Delivery)

Example 7 with Billing

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;
}
Also used : ShippingQuote(com.salesmanager.core.model.shipping.ShippingQuote) ReadableCustomer(com.salesmanager.shop.model.customer.ReadableCustomer) Customer(com.salesmanager.core.model.customer.Customer) PersistableCustomer(com.salesmanager.shop.model.customer.PersistableCustomer) Billing(com.salesmanager.core.model.common.Billing) ShippingProduct(com.salesmanager.core.model.shipping.ShippingProduct) Delivery(com.salesmanager.core.model.common.Delivery)

Example 8 with Billing

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;
}
Also used : Billing(com.salesmanager.core.model.common.Billing)

Example 9 with Billing

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;
}
Also used : ReadableCustomer(com.salesmanager.shop.model.customer.ReadableCustomer) Customer(com.salesmanager.core.model.customer.Customer) PersistableCustomer(com.salesmanager.shop.model.customer.PersistableCustomer) Billing(com.salesmanager.core.model.common.Billing) Delivery(com.salesmanager.core.model.common.Delivery)

Example 10 with Billing

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;
}
Also used : ShippingQuote(com.salesmanager.core.model.shipping.ShippingQuote) Billing(com.salesmanager.core.model.common.Billing) ShippingProduct(com.salesmanager.core.model.shipping.ShippingProduct) Delivery(com.salesmanager.core.model.common.Delivery)

Aggregations

Billing (com.salesmanager.core.model.common.Billing)12 Delivery (com.salesmanager.core.model.common.Delivery)10 Customer (com.salesmanager.core.model.customer.Customer)7 Country (com.salesmanager.core.model.reference.country.Country)6 Zone (com.salesmanager.core.model.reference.zone.Zone)6 Language (com.salesmanager.core.model.reference.language.Language)5 ShippingQuote (com.salesmanager.core.model.shipping.ShippingQuote)5 BigDecimal (java.math.BigDecimal)5 MerchantStore (com.salesmanager.core.model.merchant.MerchantStore)4 ShippingProduct (com.salesmanager.core.model.shipping.ShippingProduct)4 PersistableCustomer (com.salesmanager.shop.model.customer.PersistableCustomer)4 Product (com.salesmanager.core.model.catalog.product.Product)3 Date (java.util.Date)3 HashSet (java.util.HashSet)3 ConversionException (com.salesmanager.core.business.exception.ConversionException)2 ProductAvailability (com.salesmanager.core.model.catalog.product.availability.ProductAvailability)2 ProductDescription (com.salesmanager.core.model.catalog.product.description.ProductDescription)2 FinalPrice (com.salesmanager.core.model.catalog.product.price.FinalPrice)2 ProductPrice (com.salesmanager.core.model.catalog.product.price.ProductPrice)2 ProductPriceDescription (com.salesmanager.core.model.catalog.product.price.ProductPriceDescription)2