Package com.jada.content

Examples of com.jada.content.Formatter


          break;
        }
      }
    }
    siteDomainParamBean = SiteDomainDAO.getSiteDomainParamBean(siteDomain.getSiteDomainLanguage(), siteDomainLanguage);
    formatter = new Formatter(siteProfile, siteCurrency);
    currencyConverter = new CurrencyConverter(siteCurrency);
    if (ContentLookupDispatchAction.isCustomerSession(request)) {
      custId = ContentLookupDispatchAction.getCustId(request);
    }
    dataApi = DataApi.getInstance();
View Full Code Here


          siteDomainLanguage = language;
        }
      }
    }
    siteDomainParamBean = SiteDomainDAO.getSiteDomainParamBean(siteDomain.getSiteDomainLanguage(), siteDomainLanguage);
    formatter = new Formatter(contentBean.getContentSessionBean().getSiteProfile(),
                  contentBean.getContentSessionBean().getSiteCurrency());
    currencyConverter = new CurrencyConverter(contentBean.getContentSessionBean().getSiteCurrency());
    if (ContentLookupDispatchAction.isCustomerSession(request)) {
      custId = ContentLookupDispatchAction.getCustId(request);
    }
View Full Code Here

    OrderHeader header = new OrderHeader();
    header = OrderHeaderDAO.load(site.getSiteId(), Format.getLong(orderHeaderId));
    OrderEngine orderEngine = new OrderEngine(header, null);
    SiteProfile siteProfile = getContentBean(request).getContentSessionBean().getSiteProfile();
    SiteCurrency siteCurrency = header.getSiteCurrency();
    Formatter numberFormatter = new Formatter(siteProfile, siteCurrency);
    ContentBean contentBean = getContentBean(request);

    MessageResources resources = this.getResources(request);
    form.setOrderNum(header.getOrderNum());
   
    OrderAddress address = header.getCustAddress();
    String name = Format.formatCustomerName("", address.getCustFirstName(), address.getCustMiddleName(), address.getCustLastName(), "");
    form.setCustName(name);
    form.setCustEmail(header.getCustEmail());
    form.setCustPrefix(address.getCustPrefix());
    form.setCustFirstName(address.getCustFirstName());
    form.setCustMiddleName(address.getCustMiddleName());
    form.setCustLastName(address.getCustLastName());
    form.setCustSuffix(address.getCustSuffix());
    form.setCustAddressLine1(address.getCustAddressLine1());
    form.setCustAddressLine2(address.getCustAddressLine2());
    form.setCustCityName(address.getCustCityName());
    form.setCustStateName(address.getCustStateName());
    form.setCustStateCode(address.getCustStateCode());
    form.setCustCountryName(address.getCustCountryName());
    form.setCustCountryCode(address.getCustCountryCode());
    form.setCustZipCode(address.getCustZipCode());
    form.setCustPhoneNum(address.getCustPhoneNum());
    form.setCustFaxNum(address.getCustFaxNum());

    address = header.getBillingAddress();
    form.setBillingCustUseAddress(address.getCustUseAddress());
    if (address.getCustUseAddress().equals(Constants.CUST_ADDRESS_USE_OWN)) {
      name = Format.formatCustomerName("", address.getCustFirstName(), address.getCustMiddleName(), address.getCustLastName(), "");
      form.setBillingCustName(name);
      form.setBillingCustPrefix(address.getCustPrefix());
      form.setBillingCustFirstName(address.getCustFirstName());
      form.setBillingCustMiddleName(address.getCustMiddleName());
      form.setBillingCustLastName(address.getCustLastName());
      form.setBillingCustSuffix(address.getCustSuffix());
      form.setBillingCustAddressLine1(address.getCustAddressLine1());
      form.setBillingCustAddressLine2(address.getCustAddressLine2());
      form.setBillingCustCityName(address.getCustCityName());
      form.setBillingCustStateName(address.getCustStateName());
      form.setBillingCustStateCode(address.getCustStateCode());
      form.setBillingCustCountryName(address.getCustCountryName());
      form.setBillingCustCountryCode(address.getCustCountryCode());
      form.setBillingCustZipCode(address.getCustZipCode());
      form.setBillingCustPhoneNum(address.getCustPhoneNum());
      form.setBillingCustFaxNum(address.getCustFaxNum());
    }
   
    address = header.getShippingAddress();
    form.setShippingCustUseAddress(address.getCustUseAddress());
    if (address.getCustUseAddress().equals(Constants.CUST_ADDRESS_USE_OWN)) {
      name = Format.formatCustomerName("", address.getCustFirstName(), address.getCustMiddleName(), address.getCustLastName(), "");
      form.setShippingCustName(name);
      form.setShippingCustPrefix(address.getCustPrefix());
      form.setShippingCustFirstName(address.getCustFirstName());
      form.setShippingCustMiddleName(address.getCustMiddleName());
      form.setShippingCustLastName(address.getCustLastName());
      form.setShippingCustSuffix(address.getCustSuffix());
      form.setShippingCustAddressLine1(address.getCustAddressLine1());
      form.setShippingCustAddressLine2(address.getCustAddressLine2());
      form.setShippingCustCityName(address.getCustCityName());
      form.setShippingCustStateName(address.getCustStateName());
      form.setShippingCustStateCode(address.getCustStateCode());
      form.setShippingCustCountryName(address.getCustCountryName());
      form.setShippingCustCountryCode(address.getCustCountryCode());
      form.setShippingCustZipCode(address.getCustZipCode());
      form.setShippingCustPhoneNum(address.getCustPhoneNum());
      form.setShippingCustFaxNum(address.getCustFaxNum());
    }
   
    form.setPriceTotal(numberFormatter.formatCurrency(orderEngine.getOrderSubTotal()));
    form.setShippingTotal(numberFormatter.formatCurrency(orderEngine.getOrderShippingTotal()));
    form.setTaxTotal(numberFormatter.formatCurrency(orderEngine.getOrderTaxTotal()));
    form.setOrderTotal(numberFormatter.formatCurrency(header.getOrderTotal()));
    if (header.getPaymentGatewayProvider() != null) {
      form.setPaymentGateway(header.getPaymentGatewayProvider());
      if (header.getPaymentGatewayProvider().equals(PayPalEngine.class.getSimpleName())) {
        form.setPayPal(true);
      }
    }
   
    form.setCreditCardDesc(header.getCreditCardDesc());
    if (header.getCustCreditCardNum() != null) {
      String custCreditCardNum = AESEncoder.getInstance().decode(header.getCustCreditCardNum());
      custCreditCardNum = Utility.maskCreditCardNumber(custCreditCardNum);
      form.setCustCreditCardNum(custCreditCardNum);
    }
    form.setShippingMethodName(header.getShippingMethodName());
   
    Date shipDate = null;
    for (ShipHeader shipHeader : header.getShipHeaders()) {
      if (shipDate == null || shipDate.before(shipHeader.getShipDate())) {
        shipDate = shipHeader.getShipDate();
      }
    }
    if (shipDate != null) {
      form.setShipDate(numberFormatter.formatDate(shipDate));
    }
    form.setOrderStatus(header.getOrderStatus());
    form.setOrderStatusDesc(resources.getMessage("order.status." + header.getOrderStatus()));
    form.setOrderDatetime(numberFormatter.formatDate(header.getOrderDate()));
   
    PaymentTran paymentTran = header.getPaymentTran();
    if (paymentTran != null) {
      form.setAuthCode(paymentTran.getAuthCode());
      form.setPaymentReference1(paymentTran.getPaymentReference1());
    }
   
    Iterator<?> iterator = orderEngine.getOrderTaxes().iterator();
    Vector<OrderTaxForm> orderTaxes = new Vector<OrderTaxForm>();
    while (iterator.hasNext()) {
      OrderDetailTax orderDetailTax = (OrderDetailTax) iterator.next();
      OrderTaxForm orderTaxForm = new OrderTaxForm();
      orderTaxForm.setTaxName(orderDetailTax.getTaxName());
      orderTaxForm.setTaxAmount(numberFormatter.formatCurrency(orderDetailTax.getTaxAmount()));
      orderTaxes.add(orderTaxForm);
    }
    form.setOrderTaxes(orderTaxes);
   
   
    iterator = header.getOrderItemDetails().iterator();
    Vector<OrderDetailDisplayForm> details = new Vector<OrderDetailDisplayForm>();
    while (iterator.hasNext()) {
      OrderItemDetail detail = (OrderItemDetail) iterator.next();
      OrderDetailDisplayForm dform = new OrderDetailDisplayForm();
      dform.setItemShortDesc(detail.getItemShortDesc());
     
      Item item = detail.getItem();
      if (item != null) {
        Item master = detail.getItem();
        if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_SKU)) {
          master = item.getItemSkuParent();
        }
         
        ItemImage itemImage = master.getItemLanguage().getImage();
        if (itemImage != null) {
          dform.setImageId(itemImage.getImageId().toString());
        }
        dform.setItemShortDesc(master.getItemLanguage().getItemShortDesc());
        if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
          for (ItemLanguage itemLanguage : master.getItemLanguages()) {
            if (itemLanguage.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
              if (itemLanguage.getImage() != null) {
                itemImage = itemLanguage.getImage();
              }
              if (itemLanguage.getItemShortDesc() != null) {
                dform.setItemShortDesc(itemLanguage.getItemShortDesc());
              }
              break;
            }
          }
        }
      }
     
      dform.setItemNum(detail.getItemNum());
      dform.setItemUpcCd(detail.getItemUpcCd());
      dform.setItemTierQty(numberFormatter.formatNumber(detail.getItemTierQty()));
      dform.setItemTierPrice(numberFormatter.formatCurrency(detail.getItemTierPrice()));

      String priceDisplay = numberFormatter.formatCurrency(detail.getItemTierPrice());
      if (detail.getItemTierQty() > 1) {
        priceDisplay = numberFormatter.formatNumber(detail.getItemTierQty()) + " / " + numberFormatter.formatCurrency(detail.getItemTierPrice());
      }
      dform.setPriceDisplay(priceDisplay);
     
      dform.setItemOrderQty(numberFormatter.formatNumber(detail.getItemOrderQty()));
      dform.setItemSubTotal(numberFormatter.formatCurrency(detail.getItemDetailAmount()));
     
      int itemInvoiceQty = 0;
      for (InvoiceDetail invoiceDetail : detail.getInvoiceDetails()) {
        itemInvoiceQty += invoiceDetail.getItemInvoiceQty();
      }
      dform.setItemInvoiceQty(numberFormatter.formatNumber(itemInvoiceQty));
      int itemCreditQty = 0;
      for (CreditDetail creditDetail : detail.getCreditDetails()) {
        itemCreditQty += creditDetail.getItemCreditQty();
      }
      dform.setItemCreditQty(numberFormatter.formatNumber(itemCreditQty));
     
      Vector<OrderItemAttributeBean> orderItemAttributes = new Vector<OrderItemAttributeBean>();
        if (item != null && item.getItemTypeCd().equals(Constants.ITEM_TYPE_SKU)) {
          for (ItemAttributeDetail itemAttributeDetail : item.getItemAttributeDetails()) {
            CustomAttribute customAttribute = itemAttributeDetail.getCustomAttributeDetail().getCustomAttribute();
            if (customAttribute.getCustomAttribTypeCode() != Constants.CUSTOM_ATTRIBUTE_TYPE_SKU_MAKEUP) {
              continue;
            }
            OrderItemAttributeBean orderItemAttributeBean = new OrderItemAttributeBean();
           
            orderItemAttributeBean.setCustomAttribDesc(customAttribute.getCustomAttributeLanguage().getCustomAttribDesc());
              if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
                for (CustomAttributeLanguage language : customAttribute.getCustomAttributeLanguages()) {
                  if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                    if (language.getCustomAttribDesc() != null) {
                      orderItemAttributeBean.setCustomAttribDesc(language.getCustomAttribDesc());
                    }
                    break;
                  }
                }
              }

              CustomAttributeOption customAttributeOption = itemAttributeDetail.getCustomAttributeOption();
              orderItemAttributeBean.setCustomAttribValue(customAttributeOption.getCustomAttributeOptionLanguage().getCustomAttribValue());
              if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
                for (CustomAttributeOptionLanguage language : customAttributeOption.getCustomAttributeOptionLanguages()) {
                  if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                    if (language.getCustomAttribValue() != null) {
                      orderItemAttributeBean.setCustomAttribValue(language.getCustomAttribValue());
                    }
                    break;
                  }
                }
              }
              orderItemAttributes.add(orderItemAttributeBean);
          }
        }
       
        for (OrderAttributeDetail orderAttributeDetail : detail.getOrderAttributeDetails()) {
          OrderItemAttributeBean orderItemAttributeBean = new OrderItemAttributeBean();
          CustomAttribute customAttribute = orderAttributeDetail.getCustomAttributeDetail().getCustomAttribute();
          orderItemAttributeBean.setCustomAttribDesc(customAttribute.getCustomAttributeLanguage().getCustomAttribDesc());
            if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
              for (CustomAttributeLanguage language : customAttribute.getCustomAttributeLanguages()) {
                if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                  if (language.getCustomAttribDesc() != null) {
                    orderItemAttributeBean.setCustomAttribDesc(language.getCustomAttribDesc());
                  }
                  break;
                }
              }
            }
           
            if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_CUST_INPUT) {
              orderItemAttributeBean.setCustomAttribValue(orderAttributeDetail.getOrderAttribValue());
            }
            else {
              CustomAttributeOption customAttributeOption = orderAttributeDetail.getCustomAttributeOption();
              orderItemAttributeBean.setCustomAttribValue(customAttributeOption.getCustomAttributeOptionLanguage().getCustomAttribValue());
              if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
                for (CustomAttributeOptionLanguage language : customAttributeOption.getCustomAttributeOptionLanguages()) {
                  if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                    if (language.getCustomAttribValue() != null) {
                      orderItemAttributeBean.setCustomAttribValue(language.getCustomAttribValue());
                    }
                    break;
                  }
                }
              }
            }
            orderItemAttributes.add(orderItemAttributeBean);
        }
        dform.setOrderItemAttributes(orderItemAttributes);
     
      details.add(dform);
    }
    form.setOrderDetails(details);
   
      Vector<OrderDetailDisplayForm> otherVector = new Vector<OrderDetailDisplayForm>();
      iterator = header.getOrderOtherDetails().iterator();
       while (iterator.hasNext()) {
        OrderOtherDetail orderOtherDetail = (OrderOtherDetail) iterator.next();
        Coupon coupon = orderOtherDetail.getCoupon();
        OrderDetailDisplayForm bean = new OrderDetailDisplayForm();
        bean.setItemShortDesc(coupon.getCouponCode() + " " + coupon.getCouponLanguage().getCouponName());
        if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
          for (CouponLanguage language : coupon.getCouponLanguages()) {
            if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
              if (language.getCouponName() != null) {
                bean.setItemShortDesc(coupon.getCouponCode() + " " + language.getCouponName());
              }
              break;
            }
          }
        }
        bean.setItemSubTotal(Format.getFloat(orderOtherDetail.getOrderOtherDetailAmount()));
        otherVector.add(bean);
      }
      form.setOrderOtherDetails(otherVector);
   
    Vector<TrackingDisplayForm> vector = new Vector<TrackingDisplayForm>();
    iterator = header.getOrderTrackings().iterator();
    while (iterator.hasNext()) {
      OrderTracking orderTracking = (OrderTracking) iterator.next();
      TrackingDisplayForm displayForm = new TrackingDisplayForm();
      displayForm.setOrderTrackingId(Format.getLong(orderTracking.getOrderTrackingId()));
      displayForm.setOrderTrackingCode(resources.getMessage("order.tracking." + orderTracking.getOrderTrackingCode()));
      displayForm.setOrderTrackingMessage(orderTracking.getOrderTrackingMessage());
      displayForm.setOrderTrackingDatetime(numberFormatter.formatDate(orderTracking.getRecUpdateDatetime()));
      displayForm.setOrderTrackingInternal(orderTracking.getOrderTrackingInternal());
      vector.add(displayForm);
    }
    TrackingDisplayForm orderTrackings[] = new TrackingDisplayForm[vector.size()];
    vector.copyInto(orderTrackings);
    form.setOrderTrackings(orderTrackings);
   
    Vector<CreditDetailDisplayForm> creditVector = new Vector<CreditDetailDisplayForm>();
    iterator = header.getCreditHeaders().iterator();
    while (iterator.hasNext()) {
      CreditHeader creditHeader = (CreditHeader) iterator.next();
      CreditDetailDisplayForm creditDisplayForm = new CreditDetailDisplayForm();
      creditDisplayForm.setCreditNum(creditHeader.getCreditNum());
      creditDisplayForm.setCreditTotal(numberFormatter.formatCurrency(creditHeader.getCreditTotal()));
      creditDisplayForm.setCreditStatusDesc(resources.getMessage("order.status." + creditHeader.getCreditStatus()));
      creditDisplayForm.setCreditDatetime(numberFormatter.formatDate(creditHeader.getCreditDate()));
      creditVector.add(creditDisplayForm);
    }
    form.setCreditDetails(creditVector);
   
    createEmptySecureTemplateInfo(request);
View Full Code Here

    }
   
    protected void initCartInfo(ShoppingCartActionForm form, Site site, ShoppingCart shoppingCart, HttpServletRequest request, ActionMessages messages) throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      ContentBean contentBean = getContentBean(request);
      Formatter formatter = contentBean.getFormatter();
      Long siteProfileClassId = contentBean.getContentSessionKey().getSiteProfileClassId();
     
      form.setCustomerSignin(isCustomerSession(request));
      form.setShippingQuoteLock(shoppingCart.isShippingQuoteLock());

      form.setCurrencyCode(contentBean.getContentSessionBean().getSiteCurrency().getSiteCurrencyClass().getCurrency().getCurrencyCode());
      if (shoppingCart.getShippingMethod() != null) {
        form.setShippingMethodId(shoppingCart.getShippingMethod().getShippingMethodId().toString());
      }
      Vector<ShoppingCartItemBean> vector = new Vector<ShoppingCartItemBean>();
      Iterator<?> iterator = shoppingCart.getShoppingCartItems().iterator();
      while (iterator.hasNext()) {
        ShoppingCartItem shoppingCartItem = (ShoppingCartItem) iterator.next();
        ShoppingCartItemBean bean = new ShoppingCartItemBean();
        Item item = shoppingCartItem.getItem();
        Item master = item;
        if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_SKU)) {
          master = item.getItemSkuParent();
        }
       
        bean.setItemId(item.getItemId().toString());
        bean.setItemNum(item.getItemNum());
        bean.setItemNaturalKey(item.getItemNaturalKey());
        bean.setItemQty(Format.getInt(shoppingCartItem.getItemQty()));
        int tierQty = shoppingCartItem.getTierPrice().getItemTierQty();
        float tierPrice = shoppingCartItem.getTierPrice().getItemTierPrice();
        bean.setItemPrice(formatItemPrice(contentBean, tierQty, tierPrice));
        bean.setItemSubTotal(formatter.formatCurrency(shoppingCartItem.getItemPriceTotal()));
        bean.setItemQtyError("");
       
       
        bean.setItemShortDesc(master.getItemLanguage().getItemShortDesc());
        ItemImage itemImage = master.getItemLanguage().getImage();
        if (itemImage != null) {
          bean.setImageId(itemImage.getImageId().toString());
        }
            if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()){
              for (ItemLanguage itemLanguage : master.getItemLanguages()) {
                if (itemLanguage.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
                  if (itemLanguage.getItemShortDesc() != null) {
                    bean.setItemShortDesc(itemLanguage.getItemShortDesc());
                  }
                  if (itemLanguage.getItemImageOverride().equals(String.valueOf(Constants.VALUE_YES))) {
                    bean.setImageId(itemLanguage.getImage().getImageId().toString());
                  }
                  break;
                }
              }
            }
           
            Vector<ShoppingCartItemAttributeBean> shoppingCartItemAttributes = new Vector<ShoppingCartItemAttributeBean>();
            Iterator<?> itemAttributeInfoIterator = shoppingCartItem.getItemAttributeInfos().iterator();
            while (itemAttributeInfoIterator.hasNext()) {
              ItemAttributeInfo itemAttributeInfo = (ItemAttributeInfo) itemAttributeInfoIterator.next();
              ShoppingCartItemAttributeBean attributeBean = new ShoppingCartItemAttributeBean();
             
              ItemAttributeDetail itemAttributeDetail = (ItemAttributeDetail) em.find(ItemAttributeDetail.class, itemAttributeInfo.getItemAttribDetailId());
              CustomAttribute customAttribute = itemAttributeDetail.getCustomAttributeDetail().getCustomAttribute();
              if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_USER_INPUT) {
                continue;
              }
              if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_USER_SELECT_DROPDOWN) {
                continue;
              }
             
              attributeBean.setCustomAttribDesc(customAttribute.getCustomAttributeLanguage().getCustomAttribDesc());
              if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
                for (CustomAttributeLanguage language : customAttribute.getCustomAttributeLanguages()) {
                  if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
                    if (language.getCustomAttribDesc() != null) {
                      attributeBean.setCustomAttribDesc(language.getCustomAttribDesc());
                    }
                      break;
                  }
                }
              }
             
              if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_CUST_INPUT) {
                attributeBean.setCustomAttribValue(itemAttributeInfo.getItemAttribDetailValue());
              }
              else {
                CustomAttributeOption customAttribOption = CustomAttributeOptionDAO.load(site.getSiteId(), itemAttributeInfo.getCustomAttribOptionId());
                attributeBean.setCustomAttribValue(customAttribOption.getCustomAttributeOptionLanguage().getCustomAttribValue());
                if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
                  for (CustomAttributeOptionLanguage language : customAttribOption.getCustomAttributeOptionLanguages()) {
                    if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
                      if (language.getCustomAttribValue() != null) {
                        attributeBean.setCustomAttribValue(language.getCustomAttribValue());
                      }
                      break;
                    }
                  }
                }
              }
              shoppingCartItemAttributes.add(attributeBean);
            }
            bean.setShoppingCartItemAttributes(shoppingCartItemAttributes);
        vector.add(bean);
      }
      form.setShoppingCartItemInfos(vector);
     
      Vector<ShoppingCartCouponBean> couponVector = new Vector<ShoppingCartCouponBean>();
      iterator = shoppingCart.getShoppingCartCoupons().iterator();
      while (iterator.hasNext()) {
        ShoppingCartCoupon shoppingCartCoupon = (ShoppingCartCoupon) iterator.next();
        Coupon coupon = shoppingCartCoupon.getCoupon();
        ShoppingCartCouponBean bean = new ShoppingCartCouponBean();
        bean.setCouponId(Format.getLong(coupon.getCouponId()));
        bean.setCouponCode(coupon.getCouponCode());
        bean.setCouponName(coupon.getCouponLanguage().getCouponName());
        if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
          for (CouponLanguage language : coupon.getCouponLanguages()) {
            if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
              if (language.getCouponName() != null) {
                bean.setCouponName(language.getCouponName());
              }
              break;
            }
          }
        }
        bean.setCouponAmount(formatter.formatCurrency(shoppingCartCoupon.getCouponAmount()));
        couponVector.add(bean);
      }
      form.setShoppingCartCouponInfos(couponVector);
     
      ItemTax taxes[] = shoppingCart.getTaxes();
       Vector<ShoppingCartTaxInfo> taxVector = new Vector<ShoppingCartTaxInfo>();
      if (taxes != null) {
        for (int i = 0; i < taxes.length; i++) {
          ShoppingCartTaxInfo taxInfo = new ShoppingCartTaxInfo();
          Tax tax = taxes[i].getTax();
          taxInfo.setTaxName(tax.getTaxLanguage().getTaxName());
          if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
            for (TaxLanguage language : tax.getTaxLanguages()) {
              if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                if (language.getTaxName() != null) {
                  taxInfo.setTaxName(language.getTaxName());
                }
                break;
              }
            }
          }
          taxInfo.setTaxAmount(formatter.formatCurrency(taxes[i].getTaxAmount()));
          taxVector.add(taxInfo);
        }
      }
      Collections.sort(taxVector);
      form.setShoppingCartTaxInfos(taxVector);
     
      form.setPriceTotal(formatter.formatCurrency(shoppingCart.getShoppingCartSubTotal()));
      form.setTaxTotal(formatter.formatCurrency(shoppingCart.getTaxTotal()));
      form.setShippingTotal(formatter.formatCurrency(shoppingCart.getShippingTotal()));
      form.setShippingDiscountTotal(formatter.formatCurrency(shoppingCart.getShippingDiscountTotal()));
      form.setShippingOrderTotal(formatter.formatCurrency(shoppingCart.getShippingOrderTotal()));
      form.setOrderTotal(formatter.formatCurrency(shoppingCart.getOrderTotal()));
     
      Vector<?> shippingMethodVector = shoppingCart.getShippingMethods();
      Vector<LabelValueBean> smVector = new Vector<LabelValueBean>();
      iterator = shippingMethodVector.iterator();
      while (iterator.hasNext()) {
View Full Code Here

   
    protected void initFromOrder(String orderNum, ShoppingCartActionForm form, Site site, HttpServletRequest request, ActionMessages messages) throws Exception {
      EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
      Long custId = ContentLookupDispatchAction.getCustId(request);
    ContentBean contentBean = getContentBean(request);
    Formatter formatter = contentBean.getFormatter();
    OrderHeader orderHeader = null;
    String sql = "select  orderHeader " +
                 "from    OrderHeader orderHeader " +
                 "where   orderHeader.siteDomain.site.siteId = :siteId " +
                 "and     orderHeader.orderNum = :orderNum ";
        Query query = em.createQuery(sql);
        query.setParameter("siteId", site.getSiteId());
        query.setParameter("orderNum", orderNum);
        List<?> list = query.getResultList();
        if (list.size() > 0) {
          orderHeader = (OrderHeader) list.get(0);
        }
        if (!orderHeader.getCustomer().getCustId().equals(custId)) {
          throw new SecurityException("Customer should not have access to other's customer order");
        }
        OrderEngine orderEngine = new OrderEngine(orderHeader, null);
       
        Iterator<?> iterator = orderHeader.getOrderItemDetails().iterator();
      Vector<ShoppingCartItemBean> vector = new Vector<ShoppingCartItemBean>();
        while (iterator.hasNext()) {
          OrderItemDetail orderItemDetail = (OrderItemDetail) iterator.next();
          ShoppingCartItemBean bean = new ShoppingCartItemBean();
          Item item = orderItemDetail.getItem();
          Item master = item;
          if (item != null) {
            if (item.getItemTypeCd().equals(Constants.ITEM_TYPE_SKU)) {
              master = item.getItemSkuParent();
            }
          }
         
          bean.setItemId("");
          if (item != null) {
            bean.setItemId(item.getItemId().toString());
          }
         
        bean.setItemNum(orderItemDetail.getItemNum());
        bean.setItemShortDesc(orderItemDetail.getItemShortDesc());
        bean.setItemQty(formatter.formatNumber(orderItemDetail.getItemOrderQty()));
        bean.setItemPrice(formatItemPrice(contentBean, orderItemDetail.getItemTierQty(), orderItemDetail.getItemTierPrice()));
        bean.setItemSubTotal(formatter.formatCurrency(orderItemDetail.getItemDetailAmount()));
        bean.setItemQtyError("");
      bean.setImageId(null);
      bean.setItemShortDesc(orderItemDetail.getItemShortDesc());
        if (item != null) {
          ItemImage itemImage = orderItemDetail.getItem().getItemLanguage().getImage();
          if (itemImage != null) {
            bean.setImageId(itemImage.getImageId().toString());
          }
          if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
            for (ItemLanguage language : master.getItemLanguages()) {
              if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                if (language.getItemImageOverride().equals(String.valueOf(Constants.VALUE_YES))) {
                  bean.setImageId("");
                  if (language.getImage() != null) {
                    bean.setImageId(language.getImage().getImageId().toString());
                  }
                }
                if (language.getItemShortDesc() != null) {
                  bean.setItemShortDesc(language.getItemShortDesc());
                }
                break;
              }
            }
          }
        }
       
        Vector<ShoppingCartItemAttributeBean> shoppingCartItemAttributes = new Vector<ShoppingCartItemAttributeBean>();
        if (item != null && item.getItemTypeCd().equals(Constants.ITEM_TYPE_SKU)) {
          for (ItemAttributeDetail itemAttributeDetail : item.getItemAttributeDetails()) {
            CustomAttribute customAttribute = itemAttributeDetail.getCustomAttributeDetail().getCustomAttribute();
            if (customAttribute.getCustomAttribTypeCode() != Constants.CUSTOM_ATTRIBUTE_TYPE_SKU_MAKEUP) {
              continue;
            }
            ShoppingCartItemAttributeBean shoppingCartItemAttributeBean = new ShoppingCartItemAttributeBean();
           
            shoppingCartItemAttributeBean.setCustomAttribDesc(customAttribute.getCustomAttributeLanguage().getCustomAttribDesc());
              if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
                for (CustomAttributeLanguage language : customAttribute.getCustomAttributeLanguages()) {
                  if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                    if (language.getCustomAttribDesc() != null) {
                      shoppingCartItemAttributeBean.setCustomAttribDesc(language.getCustomAttribDesc());
                    }
                    break;
                  }
                }
              }

              CustomAttributeOption customAttributeOption = itemAttributeDetail.getCustomAttributeOption();
              shoppingCartItemAttributeBean.setCustomAttribValue(customAttributeOption.getCustomAttributeOptionLanguage().getCustomAttribValue());
              if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
                for (CustomAttributeOptionLanguage language : customAttributeOption.getCustomAttributeOptionLanguages()) {
                  if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                    if (language.getCustomAttribValue() != null) {
                      shoppingCartItemAttributeBean.setCustomAttribValue(language.getCustomAttribValue());
                    }
                    break;
                  }
                }
              }
              shoppingCartItemAttributes.add(shoppingCartItemAttributeBean);
          }
        }
       
        for (OrderAttributeDetail orderAttributeDetail : orderItemDetail.getOrderAttributeDetails()) {
          ShoppingCartItemAttributeBean shoppingCartItemAttributeBean = new ShoppingCartItemAttributeBean();
          CustomAttribute customAttribute = orderAttributeDetail.getCustomAttributeDetail().getCustomAttribute();
          shoppingCartItemAttributeBean.setCustomAttribDesc(customAttribute.getCustomAttributeLanguage().getCustomAttribDesc());
            if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
              for (CustomAttributeLanguage language : customAttribute.getCustomAttributeLanguages()) {
                if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                  if (language.getCustomAttribDesc() != null) {
                    shoppingCartItemAttributeBean.setCustomAttribDesc(language.getCustomAttribDesc());
                  }
                  break;
                }
              }
            }
           
            if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_CUST_INPUT) {
              shoppingCartItemAttributeBean.setCustomAttribValue(orderAttributeDetail.getOrderAttribValue());
            }
            else {
              CustomAttributeOption customAttributeOption = orderAttributeDetail.getCustomAttributeOption();
              shoppingCartItemAttributeBean.setCustomAttribValue(customAttributeOption.getCustomAttributeOptionLanguage().getCustomAttribValue());
              if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
                for (CustomAttributeOptionLanguage language : customAttributeOption.getCustomAttributeOptionLanguages()) {
                  if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
                    if (language.getCustomAttribValue() != null) {
                      shoppingCartItemAttributeBean.setCustomAttribValue(language.getCustomAttribValue());
                    }
                    break;
                  }
                }
              }
            }
            shoppingCartItemAttributes.add(shoppingCartItemAttributeBean);
        }
       
        bean.setShoppingCartItemAttributes(shoppingCartItemAttributes);
        vector.add(bean);
        }
        form.setShoppingCartItemInfos(vector);
       
      Vector<ShoppingCartCouponBean> couponVector = new Vector<ShoppingCartCouponBean>();
      iterator = orderHeader.getOrderOtherDetails().iterator();
       while (iterator.hasNext()) {
        OrderOtherDetail orderOtherDetail = (OrderOtherDetail) iterator.next();
        Coupon coupon = orderOtherDetail.getCoupon();
        ShoppingCartCouponBean bean = new ShoppingCartCouponBean();
        bean.setCouponCode(coupon.getCouponCode());
        bean.setCouponName(coupon.getCouponLanguage().getCouponName());
        if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
          for (CouponLanguage language : coupon.getCouponLanguages()) {
            if (language.getSiteProfileClass().getSiteProfileClassId().equals(contentBean.getContentSessionKey().getSiteProfileClassId())) {
              if (language.getCouponName() != null) {
                bean.setCouponName(language.getCouponName());
              }
              break;
            }
          }
        }
        bean.setCouponAmount(Format.getFloat(orderOtherDetail.getOrderOtherDetailAmount()));
        couponVector.add(bean);
      }
      form.setShoppingCartCouponInfos(couponVector);

        sql = "select  orderDetailTax.taxName, sum(orderDetailTax.taxAmount) " +
              "from    OrderDetailTax orderDetailTax " +
              "left    join orderDetailTax.orderHeader orderHeader " +
              "where   orderHeader.orderHeaderId = :orderHeaderId " +
              "group   by orderDetailTax.taxName " +
              "order   by orderDetailTax.taxName ";
        query = em.createQuery(sql);
        query.setParameter("orderHeaderId", orderHeader.getOrderHeaderId());
        iterator = query.getResultList().iterator();
      Vector<ShoppingCartTaxInfo> taxVector = new Vector<ShoppingCartTaxInfo>();
      while (iterator.hasNext()) {
        Object object[] = (Object[]) iterator.next();
        String taxName = (String) object[0];
        Double taxAmount = (Double) object[1];
        ShoppingCartTaxInfo taxInfo = new ShoppingCartTaxInfo();
        taxInfo.setTaxName(taxName);
        taxInfo.setTaxAmount(formatter.formatCurrency(taxAmount.floatValue()));
        taxVector.add(taxInfo);
      }
      form.setShoppingCartTaxInfos(taxVector);
       
      form.setPriceTotal(formatter.formatCurrency(orderEngine.getOrderSubTotal()));
      form.setTaxTotal(formatter.formatCurrency(orderEngine.getOrderTaxTotal()));
      form.setShippingTotal(formatter.formatCurrency(orderHeader.getShippingTotal()));
      form.setShippingDiscountTotal(formatter.formatCurrency(orderHeader.getShippingDiscountTotal()));
      form.setShippingOrderTotal(formatter.formatCurrency(orderHeader.getShippingTotal() - orderHeader.getShippingDiscountTotal()));
      form.setOrderTotal(formatter.formatCurrency(orderHeader.getOrderTotal()));
     
      OrderAddress custAddress = orderHeader.getCustAddress();
      if (custAddress != null) {
        ShoppingCartAddressActionForm custAddressForm = new ShoppingCartAddressActionForm();
        custAddressForm.setCustUseAddress(custAddress.getCustUseAddress());
        custAddressForm.setCustPrefix(custAddress.getCustPrefix());
        custAddressForm.setCustFirstName(custAddress.getCustFirstName());
        custAddressForm.setCustMiddleName(custAddress.getCustMiddleName());
        custAddressForm.setCustLastName(custAddress.getCustLastName());
        custAddressForm.setCustSuffix(custAddress.getCustSuffix());
        custAddressForm.setCustAddressLine1(custAddress.getCustAddressLine1());
        custAddressForm.setCustAddressLine2(custAddress.getCustAddressLine2());
        custAddressForm.setCustCityName(custAddress.getCustCityName());
        custAddressForm.setCustStateName(custAddress.getCustStateName());
        custAddressForm.setCustStateCode(custAddress.getCustStateCode());
        custAddressForm.setCustZipCode(custAddress.getCustZipCode());
        custAddressForm.setCustCountryName(custAddress.getCustCountryName());
        custAddressForm.setCustCountryCode(custAddress.getCustCountryCode());
        custAddressForm.setCustPhoneNum(custAddress.getCustPhoneNum());
        custAddressForm.setCustFaxNum(custAddress.getCustFaxNum());
        form.setCustAddress(custAddressForm);
      }
     
      OrderAddress billingAddress = orderHeader.getBillingAddress();
      OrderAddress shippingAddress = orderHeader.getShippingAddress();
    if (billingAddress != null) {
        ShoppingCartAddressActionForm billingAddressForm = new ShoppingCartAddressActionForm();
        billingAddressForm.setCustUseAddress(billingAddress.getCustUseAddress());
        billingAddressForm.setCustPrefix(billingAddress.getCustPrefix());
        billingAddressForm.setCustFirstName(billingAddress.getCustFirstName());
        billingAddressForm.setCustMiddleName(billingAddress.getCustMiddleName());
        billingAddressForm.setCustLastName(billingAddress.getCustLastName());
        billingAddressForm.setCustSuffix(billingAddress.getCustSuffix());
        billingAddressForm.setCustAddressLine1(billingAddress.getCustAddressLine1());
        billingAddressForm.setCustAddressLine2(billingAddress.getCustAddressLine2());
        billingAddressForm.setCustCityName(billingAddress.getCustCityName());
        billingAddressForm.setCustStateName(billingAddress.getCustStateName());
        billingAddressForm.setCustStateCode(billingAddress.getCustStateCode());
        billingAddressForm.setCustZipCode(billingAddress.getCustZipCode());
        billingAddressForm.setCustCountryName(billingAddress.getCustCountryName());
        billingAddressForm.setCustCountryCode(billingAddress.getCustCountryCode());
        billingAddressForm.setCustPhoneNum(billingAddress.getCustPhoneNum());
        billingAddressForm.setCustFaxNum(billingAddress.getCustFaxNum());
        form.setBillingAddress(billingAddressForm);
    }
    if (shippingAddress != null) {
        ShoppingCartAddressActionForm shippingAddressForm = new ShoppingCartAddressActionForm();
        shippingAddressForm.setCustUseAddress(shippingAddress.getCustUseAddress());
        shippingAddressForm.setCustPrefix(shippingAddress.getCustPrefix());
        shippingAddressForm.setCustFirstName(shippingAddress.getCustFirstName());
        shippingAddressForm.setCustMiddleName(shippingAddress.getCustMiddleName());
        shippingAddressForm.setCustLastName(shippingAddress.getCustLastName());
        shippingAddressForm.setCustSuffix(shippingAddress.getCustSuffix());
        shippingAddressForm.setCustAddressLine1(shippingAddress.getCustAddressLine1());
        shippingAddressForm.setCustAddressLine2(shippingAddress.getCustAddressLine2());
        shippingAddressForm.setCustCityName(shippingAddress.getCustCityName());
        shippingAddressForm.setCustStateName(shippingAddress.getCustStateName());
        shippingAddressForm.setCustStateCode(shippingAddress.getCustStateCode());
        shippingAddressForm.setCustZipCode(shippingAddress.getCustZipCode());
        shippingAddressForm.setCustCountryName(shippingAddress.getCustCountryName());
        shippingAddressForm.setCustCountryCode(shippingAddress.getCustCountryCode());
        shippingAddressForm.setCustPhoneNum(shippingAddress.getCustPhoneNum());
        shippingAddressForm.setCustFaxNum(shippingAddress.getCustFaxNum());
        form.setShippingAddress(shippingAddressForm);
    }
      form.setCustEmail(orderHeader.getCustEmail());
      form.setShippingMethodName(orderHeader.getShippingMethodName());
      PaymentTran payment = orderHeader.getPaymentTran();
      if (payment == null) {
        for (InvoiceHeader invoiceHeader : orderHeader.getInvoiceHeaders()) {
          payment = invoiceHeader.getPaymentTran();
        }
      }
      if (payment != null) {
        form.setPaymentGatewayProvider(orderHeader.getPaymentGatewayProvider());
        if (orderHeader.getPaymentGatewayProvider().equals(PayPalEngine.class.getSimpleName())) {
            form.setPayPal(true);
            form.setAuthCode(payment.getAuthCode());
        }
        else {
          form.setPayPal(false);
          form.setCreditCardDesc(orderHeader.getCreditCardDesc());
          String custCreditCardNum = AESEncoder.getInstance().decode(orderHeader.getCustCreditCardNum());
          custCreditCardNum = Utility.maskCreditCardNumber(custCreditCardNum);
          form.setCustCreditCardNum(custCreditCardNum);
          form.setAuthCode(payment.getAuthCode());
        }
      }
      else {
        form.setCashPaymentOrder(true);
      }
      form.setOrderNum(orderNum);
      form.setOrderDatetime(formatter.formatFullDate(orderHeader.getOrderDate()));
      PaymentGateway paymentGateway = null;
      if (paymentGateway != null) {
        if (orderHeader.getPaymentGatewayProvider().equals(PayPalEngine.class.getSimpleName())) {
          form.setPayPal(true);
        }
View Full Code Here

      form.setShoppingCartMessage(siteDomainParamBean.getCheckoutShoppingCartMessage());
      form.setCurrencyCode(orderHeader.getSiteCurrency().getSiteCurrencyClass().getCurrency().getCurrencyCode());
    }
   
    protected String formatItemPrice(ContentBean contentBean, int qty, float price) {
      Formatter formatter = contentBean.getFormatter();
      String result = "";
      if (qty > 1) {
        result = formatter.formatNumber(qty) + " / " +
             formatter.formatCurrency(price);
      }
      else {
        result = formatter.formatCurrency(price);
      }
      return result;
    }
View Full Code Here

TOP

Related Classes of com.jada.content.Formatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.