@PostConstruct
 public void populate() {
   orderList.clear();
   list.clear();
   employeeId = 0;
   orderList =
       em.createNamedQuery("EOrder.findByType&Status")
           .setParameter("orderType", "Purchase")
           .setParameter("status", "QC_Waiting")
           .getResultList();
   for (int i = 0; i < orderList.size(); i++) {
     String prodCode = orderList.get(i).getEIntent().getProductCode();
     int prodCatId = Integer.parseInt(prodCode.substring(0, prodCode.indexOf(".")));
     int prodId = Integer.parseInt(prodCode.substring(prodCode.indexOf(".") + 1));
     orderListClass = new OrderListClass();
     orderListClass.setSiteId(orderList.get(i).getEIntent().getESites().getId());
     orderListClass.setSiteName(eSitesFacade.find(orderListClass.getSiteId()).getName());
     orderListClass.setProductCategoryId(prodCatId);
     orderListClass.setProductCategoryName(eProductCategoryFacade.find(prodCatId).getName());
     orderListClass.setProductId(prodId);
     orderListClass.setProductName(eProductFacade.find(prodId).getName());
     orderListClass.setOrderId(orderList.get(i).getId());
     orderListClass.setOrderDate(dateFormat.format(orderList.get(i).getDate()));
     orderListClass.setOrderQuantity(orderList.get(i).getProdQuantity());
     orderListClass.setQuotationId(orderList.get(i).getSelectQuotationId());
     orderListClass.setUnitPrice(
         eQuotationFacade.find(orderListClass.getQuotationId()).getUnitPrice());
     orderListClass.setVendorId(
         eQuotationFacade.find(orderListClass.getQuotationId()).getEVendors().getId());
     orderListClass.setVendorName(eVendorsFacade.find(orderListClass.getVendorId()).getVenName());
     list.add(orderListClass);
   }
 }
  public void setTransaction() throws IOException {
    Query query = em.createNamedQuery("EOrderQc.findByMaxId");
    int eOrderId = (Integer) query.getResultList().get(0);
    long currentStock = 0;

    System.out.println("orderQcId++++++++ " + eOrderId);
    EOrderQc eOrderNew = eOrderQcFacade.find(eOrderId);
    transactionList = eTransactionFacade.findAll();
    for (int k = 0; k < transactionList.size(); k++) {
      if ((transactionList.get(k).getEProduct().getId() == requestorder.getProductId())
          && (transactionList.get(k).getESites().getId() == requestorder.getSiteId())) {
        currentStock = currentStock + transactionList.get(k).getStockDelta();
      }
    }
    long updateStock = currentStock + eOrderNew.getQcQuantityAccepted();
    long delta = updateStock - currentStock;

    ETransaction eTransaction = new ETransaction();
    eTransaction.setReasonOfUpdate(eOrderNew.getEOrder().getOrderType());
    eTransaction.setDateOfUpdate(eOrderNew.getDate());
    eTransaction.setESites(eSitesFacade.find(requestorder.getSiteId()));
    eTransaction.setEProduct(eProductFacade.find(requestorder.getProductId()));
    eTransaction.setStockDelta(delta);
    eTransaction.setEOrder(eOrderNew.getEOrder());
    eTransactionFacade.create(eTransaction);

    EOrder eOrder = new EOrder();
    eOrder = eOrderNew.getEOrder();
    eOrder.setStatus("QC_Respond");
    eOrderFacade.edit(eOrder);
    // populate();

  }