Package com.jada.jpa.entity

Examples of com.jada.jpa.entity.OrderHeader


    paymentReference3 = result.getOrderID();
    paymentType = result.getPaymentType();
  }

  public void creditPayment(CreditHeader creditHeader) throws AuthorizationException, PaymentException, Exception {
    OrderHeader orderHeader = creditHeader.getOrderHeader();
 
    Order order = new Order();
    order.setStoreID(storeId);
    order.setPassphrase(passphrase);
    order.setBname(bname);
    PaymentTran payment = orderHeader.getPaymentTran();
    if (payment == null) {
      for (InvoiceHeader invoiceHeader : orderHeader.getInvoiceHeaders()) {
        payment = invoiceHeader.getPaymentTran();
      }
    }
    order.setOrderID(payment.getPaymentReference3());
    order.setPaymentType(PAYMENT_TYPE);
View Full Code Here


  public void authorizePayment(OrderHeader orderHeader, HttpServletRequest request) throws AuthorizationException, PaymentException, Exception {
    makePayment(orderHeader, "Authorization", request);
  }
 
  public void authorizeAndCapturePayment(InvoiceHeader invoiceHeader, HttpServletRequest request) throws AuthorizationException, PaymentException, Exception {
    OrderHeader orderHeader = invoiceHeader.getOrderHeader();
    makePayment(orderHeader, "Sale", request);
  }
View Full Code Here

       form.setStates(states);
      
       iterator = customer.getOrderHeaders().iterator();
       Vector<OrderDisplayForm> orderVector = new Vector<OrderDisplayForm>();
       while (iterator.hasNext()) {
         OrderHeader orderHeader = (OrderHeader) iterator.next();
         OrderDisplayForm orderForm = new OrderDisplayForm();
         OrderEngine orderEngine = new OrderEngine(orderHeader, null);
         orderForm.setOrderHeaderId(Format.getLong(orderHeader.getOrderHeaderId()));
         orderForm.setOrderDate(Format.getFullDatetime(orderHeader.getOrderDate()));
         orderForm.setOrderNum(orderHeader.getOrderNum());
         orderForm.setOrderStatusDesc(resources.getMessage("order.status." + orderHeader.getOrderStatus()));
         orderForm.setShippingTotal(Format.getDouble(orderHeader.getShippingTotal()));
         orderForm.setOrderTaxTotal(Format.getDouble(orderEngine.getOrderTaxTotal()));
         orderForm.setOrderSubTotal(Format.getDouble(orderEngine.getOrderSubTotal()));
        orderForm.setOrderTotal(Format.getDouble(orderHeader.getOrderTotal()));
        orderVector.add(orderForm);
       }
       OrderDisplayForm orders[] = new OrderDisplayForm[orderVector.size()];
       orderVector.copyInto(orders);
       form.setOrders(orders);
View Full Code Here

        calcPage(form, list, pageNo);
        Vector<OrderDisplayForm> vector = new Vector<OrderDisplayForm>();
        int startRecord = (pageNo - 1) * Constants.MYACCOUNT_LISTING_PAGE_SIZE;
        int endRecord = startRecord + Constants.MYACCOUNT_LISTING_PAGE_SIZE;
        for (int i = startRecord; i < list.size() && i < endRecord; i++) {
          OrderHeader orderHeader = (OrderHeader) list.get(i);
          OrderDisplayForm orderDisplay = new OrderDisplayForm();
          orderDisplay.setOrderHeaderId(Format.getLong(orderHeader.getOrderHeaderId()));
          orderDisplay.setOrderNum(orderHeader.getOrderNum());
          orderDisplay.setCustFirstName(orderHeader.getCustomer().getCustAddress().getCustFirstName());
          orderDisplay.setCustLastName(orderHeader.getCustomer().getCustAddress().getCustLastName());
          orderDisplay.setCustEmail(orderHeader.getCustEmail());
          orderDisplay.setCustCityName("");
          orderDisplay.setCustStateCode("");
          orderDisplay.setCustCountryCode("");
          orderDisplay.setPriceTotal("");
          orderDisplay.setShippingTotal(Format.getFloatObj(orderHeader.getShippingTotal()));
          orderDisplay.setTaxTotal("");
          orderDisplay.setOrderTotal(contentBean.getFormatter().formatCurrency(orderHeader.getOrderTotal()));
          String orderStatus = Languages.getLangTranValue(contentBean.getContentSessionKey().getLangId(), "content.text.order.status." + orderHeader.getOrderStatus());
          orderDisplay.setOrderStatus(orderStatus);
          orderDisplay.setOrderDatetime(Format.getDate(orderHeader.getOrderDate()));
          PaymentTran payment = orderHeader.getPaymentTran();
          if (payment != null) {
            orderDisplay.setPaymentReference1(payment.getPaymentReference1());
          }
          for (ShipHeader shipHeader : orderHeader.getShipHeaders()) {
            orderDisplay.setShipDatetime(Format.getDate(shipHeader.getShipDate()));
          }
            vector.add(orderDisplay);
        }
        form.setOrders(vector);
View Full Code Here

        calcPage(adminBean, form, list, pageNo);
        Vector<OrderListingDisplayForm> vector = new Vector<OrderListingDisplayForm>();
        int startRecord = (pageNo - 1) * adminBean.getListingPageSize();
        int endRecord = startRecord + adminBean.getListingPageSize();
        for (int i = startRecord; i < list.size() && i < endRecord; i++) {
          OrderHeader orderHeader = (OrderHeader) list.get(i);
          OrderAddress orderAddress = orderHeader.getCustAddress();
          OrderListingDisplayForm orderDisplay = new OrderListingDisplayForm();
          orderDisplay.setOrderHeaderId(Format.getLong(orderHeader.getOrderHeaderId()));
          orderDisplay.setOrderNum(orderHeader.getOrderNum());
          orderDisplay.setCustFirstName(orderAddress.getCustFirstName());
          orderDisplay.setCustLastName(orderAddress.getCustLastName());
          orderDisplay.setCustEmail(orderHeader.getCustEmail());
          orderDisplay.setCustCityName(orderAddress.getCustCityName());
          orderDisplay.setCustStateCode(orderAddress.getCustStateCode());
          orderDisplay.setCustCountryCode(orderAddress.getCustCountryCode());
          orderDisplay.setOrderTotal(Format.getFloatObj(orderHeader.getOrderTotal()));
          orderDisplay.setOrderStatus(orderHeader.getOrderStatus());
          orderDisplay.setOrderDate(Format.getFullDatetime(orderHeader.getOrderDate()));
            vector.add(orderDisplay);
        }
        form.setOrders(vector);
    }
View Full Code Here

        OrderListingActionForm form = (OrderListingActionForm) actionForm;
        String orderHeaderIds[] = form.getOrderHeaderIds();
       
        if (orderHeaderIds != null) {
          for (int i = 0; i < orderHeaderIds.length; i++) {
              OrderHeader orderHeader = OrderHeaderDAO.load(site.getSiteId(), Format.getLong(orderHeaderIds[i]));
              em.remove(orderHeader);
          }
        }

        ActionForward forward = new ActionForward();
View Full Code Here

      PayPalEngine payPalEngine = new PayPalEngine(contentBean.getContentSessionBean().getSiteDomain().getSite(), paymentGateway.getPaymentGatewayId());
      payPalEngine.setSiteDomain(contentBean.getContentSessionBean().getSiteDomain());
      shoppingCart.setPaymentEngine(payPalEngine);
     
    OrderEngine orderEngine = new OrderEngine(shoppingCart, null);
    OrderHeader orderHeader = orderEngine.getOrderHeader();
    payPalEngine.payPalAuthorizePayment(orderHeader, request);
    String token = payPalEngine.getToken();

    ActionForward templateForward = null;
     
View Full Code Here

    return itemComparePageInfo;
  }
 
  public OrderInfo getOrder(Long orderHeaderId) throws Exception {
    EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
    OrderHeader orderHeader = em.find(OrderHeader.class, orderHeaderId);
    OrderEngine orderEngine = new OrderEngine(orderHeader, null);
    Long siteProfileClassId = siteProfile.getSiteProfileClass().getSiteProfileClassId();
   
    OrderInfo header = new OrderInfo();
    header.setOrderNum(orderHeader.getOrderNum());
    header.setOrderDatetime(formatter.formatFullDate(orderHeader.getOrderDate()));
    header.setCustEmail(orderHeader.getCustEmail());
    header.setCurrencyCode(orderHeader.getSiteCurrency().getSiteCurrencyClass().getCurrency().getCurrencyCode());
   
    OrderAddress custAddress = orderHeader.getCustAddress();
    header.setCustUseAddress(custAddress.getCustUseAddress());
    header.setCustPrefix(custAddress.getCustPrefix());
    header.setCustFirstName(custAddress.getCustFirstName());
    header.setCustMiddleName(custAddress.getCustMiddleName());
    header.setCustLastName(custAddress.getCustLastName());
    header.setCustSuffix(custAddress.getCustSuffix());
    header.setCustAddressLine1(custAddress.getCustAddressLine1());
    header.setCustAddressLine2(custAddress.getCustAddressLine2());
    header.setCustCityName(custAddress.getCustCityName());
    header.setCustStateName(custAddress.getCustStateName());
    header.setCustCountryName(custAddress.getCustCountryName());
    header.setCustZipCode(custAddress.getCustZipCode());
    header.setCustPhoneNum(custAddress.getCustPhoneNum());
    header.setCustFaxNum(custAddress.getCustFaxNum());

    OrderAddress billingAddress = orderHeader.getBillingAddress();
    header.setBillingCustUseAddress(billingAddress.getCustUseAddress());
    header.setBillingCustPrefix(billingAddress.getCustPrefix());
    header.setBillingCustFirstName(billingAddress.getCustFirstName());
    header.setBillingCustMiddleName(billingAddress.getCustMiddleName());
    header.setBillingCustLastName(billingAddress.getCustLastName());
    header.setBillingCustSuffix(billingAddress.getCustSuffix());
    header.setBillingCustAddressLine1(billingAddress.getCustAddressLine1());
    header.setBillingCustAddressLine2(billingAddress.getCustAddressLine2());
    header.setBillingCustCityName(billingAddress.getCustCityName());
    header.setBillingCustStateName(billingAddress.getCustStateName());
    header.setBillingCustCountryName(billingAddress.getCustCountryName());
    header.setBillingCustZipCode(billingAddress.getCustZipCode());
    header.setBillingCustPhoneNum(billingAddress.getCustPhoneNum());
    header.setBillingCustFaxNum(billingAddress.getCustFaxNum());

    OrderAddress shippingAddress = orderHeader.getShippingAddress();
    header.setShippingCustUseAddress(shippingAddress.getCustUseAddress());
    header.setShippingCustPrefix(shippingAddress.getCustPrefix());
    header.setShippingCustFirstName(shippingAddress.getCustFirstName());
    header.setShippingCustMiddleName(shippingAddress.getCustMiddleName());
    header.setShippingCustLastName(shippingAddress.getCustLastName());
    header.setShippingCustSuffix(shippingAddress.getCustSuffix());
    header.setShippingCustAddressLine1(shippingAddress.getCustAddressLine1());
    header.setShippingCustAddressLine2(shippingAddress.getCustAddressLine2());
    header.setShippingCustCityName(shippingAddress.getCustCityName());
    header.setShippingCustStateName(shippingAddress.getCustStateName());
    header.setShippingCustCountryName(shippingAddress.getCustCountryName());
    header.setShippingCustZipCode(shippingAddress.getCustZipCode());
    header.setShippingCustPhoneNum(shippingAddress.getCustPhoneNum());
    header.setShippingCustFaxNum(shippingAddress.getCustFaxNum());

    header.setSubTotal(formatter.formatCurrency(orderEngine.getOrderSubTotal()));
    header.setShippingTotal(formatter.formatCurrency(orderHeader.getShippingTotal().floatValue() - orderHeader.getShippingDiscountTotal().floatValue()));
    header.setTaxTotal(formatter.formatCurrency(orderEngine.getOrderTaxTotal()));
    header.setOrderTotal(formatter.formatCurrency(orderHeader.getOrderTotal().floatValue()));
    header.setPaymentGatewayProvider(orderHeader.getPaymentGatewayProvider());
    header.setCreditCardDesc(orderHeader.getCreditCardDesc());
    header.setShippingMethodName(orderHeader.getShippingMethodName());
   
    Vector<ItemDetailInfo> vector = new Vector<ItemDetailInfo>();
    Iterator<?> iterator = orderHeader.getOrderItemDetails().iterator();
    while (iterator.hasNext()) {
      OrderItemDetail orderItemDetail = (OrderItemDetail) iterator.next();
      ItemDetailInfo detail = new ItemDetailInfo();
      detail.setItemNum(orderItemDetail.getItemNum());
      detail.setItemUpcCd(orderItemDetail.getItemUpcCd());
      detail.setItemShortDesc(orderItemDetail.getItemShortDesc());
      detail.setItemQty(orderItemDetail.getItemOrderQty().toString());
      String result = "";
        if (orderItemDetail.getItemTierQty() > 1) {
          result = formatter.formatNumber(orderItemDetail.getItemTierQty()) + " / " +
               formatter.formatCurrency(orderItemDetail.getItemTierPrice());
        }
        else {
          result = formatter.formatCurrency(orderItemDetail.getItemTierPrice());
        }
        detail.setItemPrice(result);
        detail.setItemSubTotal(formatter.formatCurrency(orderItemDetail.getItemDetailAmount()));
       
        Item item = orderItemDetail.getItem();
        Vector<com.jada.content.data.ItemAttributeInfo> v = new Vector<com.jada.content.data.ItemAttributeInfo>();
        if (item != null) {
          ItemImage itemImage = item.getItemLanguage().getImage();
          if (itemImage != null) {
            detail.setImageId(itemImage.getImageId().toString());
          }
              if (!siteProfileClassDefault){
                for (ItemLanguage itemLanguage : item.getItemLanguages()) {
                  if (itemLanguage.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
                    if (itemLanguage.getItemImageOverride().equals(String.valueOf(Constants.VALUE_YES))) {
                      detail.setImageId(itemLanguage.getImage().getImageId().toString());
                    }
                    break;
                  }
                }
              }
          if (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;
              }
              com.jada.content.data.ItemAttributeInfo itemAttributeInfo = new com.jada.content.data.ItemAttributeInfo();
             
              itemAttributeInfo.setCustomAttribDesc(customAttribute.getCustomAttributeLanguage().getCustomAttribDesc());
                if (!siteProfileClassDefault) {
                  for (CustomAttributeLanguage language : customAttribute.getCustomAttributeLanguages()) {
                    if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfile.getSiteProfileClass().getSiteProfileClassId())) {
                      if (language.getCustomAttribDesc() != null) {
                        itemAttributeInfo.setCustomAttribDesc(language.getCustomAttribDesc());
                      }
                      break;
                    }
                  }
                }
 
                CustomAttributeOption customAttributeOption = itemAttributeDetail.getCustomAttributeOption();
                itemAttributeInfo.setCustomAttribValue(customAttributeOption.getCustomAttributeOptionLanguage().getCustomAttribValue());
                if (!siteProfileClassDefault) {
                  for (CustomAttributeOptionLanguage language : customAttributeOption.getCustomAttributeOptionLanguages()) {
                    if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfile.getSiteProfileClass().getSiteProfileClassId())) {
                      if (language.getCustomAttribValue() != null) {
                        itemAttributeInfo.setCustomAttribValue(language.getCustomAttribValue());
                      }
                      break;
                    }
                  }
                }
                v.add(itemAttributeInfo);
            }
          }
        }
       
        for (OrderAttributeDetail orderAttributeDetail : orderItemDetail.getOrderAttributeDetails()) {
          com.jada.content.data.ItemAttributeInfo itemAttributeInfo = new com.jada.content.data.ItemAttributeInfo();
          CustomAttribute customAttribute = orderAttributeDetail.getCustomAttributeDetail().getCustomAttribute();
          itemAttributeInfo.setCustomAttribDesc(customAttribute.getCustomAttributeLanguage().getCustomAttribDesc());
              if (!siteProfileClassDefault) {
                for (CustomAttributeLanguage language : customAttribute.getCustomAttributeLanguages()) {
                  if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
                    if (language.getCustomAttribDesc() != null) {
                      itemAttributeInfo.setCustomAttribDesc(language.getCustomAttribDesc());
                    }
                      break;
                  }
                }
              }
              if (customAttribute.getCustomAttribTypeCode() == Constants.CUSTOM_ATTRIBUTE_TYPE_CUST_INPUT) {
                itemAttributeInfo.setCustomAttribValue(orderAttributeDetail.getOrderAttribValue());
              }
              else {
            CustomAttributeOption customAttributeOption = orderAttributeDetail.getCustomAttributeOption();
            itemAttributeInfo.setCustomAttribValue(customAttributeOption.getCustomAttributeOptionLanguage().getCustomAttribValue());
            if (!contentBean.getContentSessionBean().isSiteProfileClassDefault()) {
                  for (CustomAttributeOptionLanguage language : customAttributeOption.getCustomAttributeOptionLanguages()) {
                    if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
                      if (language.getCustomAttribValue() != null) {
                        itemAttributeInfo.setCustomAttribValue(language.getCustomAttribValue());
                      }
                      break;
                    }
                  }
                }
              }
              v.add(itemAttributeInfo);
        }
        com.jada.content.data.ItemAttributeInfo itemAttributeInfos[] = new com.jada.content.data.ItemAttributeInfo[v.size()];
        v.copyInto(itemAttributeInfos);
        detail.setItemAttributes(itemAttributeInfos);
      vector.add(detail);
    }
    ItemDetailInfo orderDetails[] = new ItemDetailInfo[vector.size()];
    vector.copyInto(orderDetails);
    header.setItemDetails(orderDetails);
   
    Vector<CouponDetailInfo> couponVector = new Vector<CouponDetailInfo>();
    Iterator<?> couponIterator = orderHeader.getOrderOtherDetails().iterator();
    while (couponIterator.hasNext()) {
      OrderOtherDetail orderOtherDetail = (OrderOtherDetail) couponIterator.next();
      CouponDetailInfo detail = new CouponDetailInfo();
      detail.setCouponCode(orderOtherDetail.getOrderOtherDetailNum());
      detail.setCouponName(orderOtherDetail.getOrderOtherDetailDesc());
View Full Code Here

            orderEngine.authorizeOrder(shoppingCart.getPaymentEngine(), request);
            orderEngine.processOrder();
            orderEngine.saveOrder();
          }
          else {
            OrderHeader orderHeader = orderEngine.getOrderHeader();
            InvoiceEngine invoiceEngine = new InvoiceEngine(orderHeader, null);
            invoiceEngine.invoiceAll();
            invoiceEngine.setCreditCardInfo(orderEngine.getCreditCardInfo());
            invoiceEngine.payOrder(shoppingCart.getPaymentEngine(), request);
            orderEngine.processOrder();
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);
        }
        PaymentTran paymentTran = orderHeader.getPaymentTran();
        if (paymentTran == null) {
          Iterator<?> invoiceIterator = orderHeader.getInvoiceHeaders().iterator();
          if (invoiceIterator.hasNext()) {
            InvoiceHeader invoiceHeader = (InvoiceHeader) invoiceIterator.next();
            paymentTran = invoiceHeader.getPaymentTran();
          }
        }
      if (paymentTran != null) {
        form.setAuthCode(paymentTran.getAuthCode());
      }
      }
     
      Long siteProfileId = contentBean.getContentSessionBean().getSiteProfile().getSiteProfileId();
      SiteDomainLanguage siteDomainLanguage = contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguage();
      if (!contentBean.getContentSessionKey().isSiteProfileClassDefault()) {
        for (SiteDomainLanguage language : contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguages()) {
          if (language.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileId)) {
            siteDomainLanguage = language;
          }
        }
      }
      SiteDomainParamBean siteDomainParamBean = SiteDomainDAO.getSiteDomainParamBean(contentBean.getContentSessionBean().getSiteDomain().getSiteDomainLanguage(), siteDomainLanguage);
      form.setShoppingCartMessage(siteDomainParamBean.getCheckoutShoppingCartMessage());
      form.setCurrencyCode(orderHeader.getSiteCurrency().getSiteCurrencyClass().getCurrency().getCurrencyCode());
    }
View Full Code Here

TOP

Related Classes of com.jada.jpa.entity.OrderHeader

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.