コード例 #1
0
 private void createStorageLocationSelectItemList() {
   SelectItem selectItem;
   storageLocationSelectItemList.clear();
   storageLocationSelectItemList.add(new SelectItem("-1", "àÅ×͡ʶҹ·Õè¨Ñ´à¡çº"));
   for (StorageLocation stLocation : StorageLocation.warehouse(warehouseCode)) {
     selectItem = new SelectItem();
     selectItem.setValue(stLocation.getID());
     selectItem.setLabel(stLocation.getValue());
     storageLocationSelectItemList.add(selectItem);
   }
 }
コード例 #2
0
  public void saveGRItem() {
    try {
      /*editGRItem.setMaterial(selectedMaterial);
      if (selectedMaterial != null ){
      	editGRItem.setReceiveUnit(selectedMaterial.getOrderUnit());
      	editGRItem.setUnitPrice(selectedMaterial.getOrderUnitPrice());
      }*/
      if (editGRItem.getBudgetItem() == null) {
        throw new ControllerException("¡ÃسÒàÅ×Í¡ËÁÇ´§º»ÃÐÁÒ³");
      }
      if (selectedGRType.equalsIgnoreCase(GRType.PO.getID())) {
        if (editGRItem.getReceivedQty().compareTo(editGRItem.getOrderQty()) == 1) {
          editGRItem.setReceivedQty(editGRItem.getOrderQty());
          throw new ControllerException("äÁèÊÒÁÒöÃѺ¢Í§à¡Ô¹¨Ó¹Ç¹·ÕèÊÑ觫×éÍä´é");
        }
        if (!editGRItem.getOrderUnitPrice().equals(zero)) {
          if (editGRItem.getUnitPrice().compareTo(editGRItem.getOrderUnitPrice()) == 1) {
            editGRItem.setUnitPrice(editGRItem.getOrderUnitPrice());
            throw new ControllerException("äÁèÊÒÁÒöãÊèÃÒ¤ÒµèÍ˹èÇÂà¡Ô¹ÃÒ¤Ò·ÕèÊÑ觫×éÍä´é");
          }
        }
      }
      // µÃǨÊͺÇèÒÁÕ¡ÒÃàÅ×Í¡ material ËÃ×Í ãÊè other material ËÃ×ÍäÁè
      if (editGRItem.getMaterial() == null
          && (editGRItem.getOtherMaterial() == null
              || editGRItem.getOtherMaterial().trim().equals(""))) {
        throw new ControllerException("¡ÃسÒàÅ×Í¡ÇÑÊ´Ø·Õèµéͧ¡ÒÃÃѺ");
      }
      // äÁèãËéãÊè·Ñé§ material áÅÐ othermaterial
      if (editGRItem.getMaterial() != null
          && (editGRItem.getOtherMaterial() != null
              && !editGRItem.getOtherMaterial().trim().equals(""))) {
        throw new ControllerException("¡ÃسÒàÅ×Í¡ÇÑÊ´Ø ËÃ×Í ÇÑÊ´ØÍ×è¹æÍÂèÒ§ã´ÍÂèҧ˹Öè§à·èÒ¹Ñé¹");
      }
      // µÃǨÊͺÇèÒÁÕÃÒ¡ÒëéÓËÃ×ÍäÁè
      for (GoodsReceiptItem grItem : grItemList) {
        System.out.println("editPrITem otherMaterial" + editGRItem.getOtherMaterial());
        System.out.println("prITem otherMaterial" + editGRItem.getOtherMaterial());
        if (editGRItem.getItemNumber() != grItem.getItemNumber()) {
          if (editGRItem.getMaterial() != null
              && grItem.getMaterial() != null
              && editGRItem.getMaterial().getId().equals(grItem.getMaterial().getId())) {
            System.out.println("Same material");
            throw new ControllerException(
                "ÇÑÊ´Ø " + editGRItem.getMaterial() + " ÁÕÍÂÙèáÅéÇäÁèÊÒÁÒôÓà¹Ô¹¡ÒõèÍä´é");
          } else if (editGRItem.getOtherMaterial() != null
              && grItem.getOtherMaterial() != null
              && !editGRItem.getOtherMaterial().trim().equals("")
              && !editGRItem.getOtherMaterial().trim().equals("")
              && editGRItem.getOtherMaterial().equals(grItem.getOtherMaterial())) {
            System.out.println("Same othermaterial");
            throw new ControllerException(
                "ÇÑÊ´Ø " + editGRItem.getOtherMaterial() + " ÁÕÍÂÙèáÅéÇäÁèÊÒÁÒôÓà¹Ô¹¡ÒõèÍä´é");
          }
        }
      }
      /*if (storageLocation.equals("-1")){
      	throw new ControllerException("¡ÃسÒàÅ×͡ʶҹ·Õè¨Ñ´à¡çº");
      }*/
      editGRItem.setStorageLocation(StorageLocation.find(storageLocation));
      editGRItem.setTotalprice(editGRItem.getReceivedQty().multiply(editGRItem.getUnitPrice()));

      if (editGRItem.getDiscountAmount().compareTo(zero) != 0) {
        editGRItem.setNetPrice(editGRItem.getTotalprice().subtract(editGRItem.getDiscountAmount()));
        editGRItem.setAvgPrice(
            editGRItem.getNetPrice().divide(editGRItem.getReceivedQty(), 2, RoundingMode.HALF_UP));
      } else {
        editGRItem.setNetPrice(editGRItem.getTotalprice());
        editGRItem.setAvgPrice(editGRItem.getUnitPrice());
      }
      if (isNewGrItem) {
        grItemList.add(editGRItem);
      }
      if ((editGRItem.getOrderQty().compareTo(editGRItem.getReceivedQty()) != 0)
          || (editGRItem.getOrderUnitPrice().compareTo(editGRItem.getUnitPrice()) != 0)) {
        isItemAmountOrPriceChanged = true;
        System.out.println("true");
      } else {
        isItemAmountOrPriceChanged = false;
        System.out.println("false");
      }
      newGRItem();
    } catch (ControllerException e) {
      e.printStackTrace();
      FacesUtils.reportError(FacesContext.getCurrentInstance(), e.getMessage(), e.getMessage(), e);
    }
    /*if (isNewGrItem) {
    	grItemList.add(editGRItem);
    }*/
  }