Ejemplo n.º 1
0
 /**
  * Check availability and insert record
  *
  * @return true if saved/updated
  */
 private boolean cmd_save() {
   log.config("");
   //	Set AssignDateTo
   Calendar date = new GregorianCalendar();
   getDateAndTimeFrom(date);
   Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis());
   BigDecimal qty = fQty.getValue();
   KeyNamePair uom = (KeyNamePair) m_lookup.get(fResource.getSelectedItem());
   int minutes = MUOMConversion.convertToMinutes(Env.getCtx(), uom.getKey(), qty);
   Timestamp assignDateTo = TimeUtil.addMinutess(assignDateFrom, minutes);
   m_mAssignment.setAssignDateTo(assignDateTo);
   //
   //	m_mAssignment.dump();
   return m_mAssignment.save();
 } //	cmdSave
Ejemplo n.º 2
0
  /**
   * Descripción de Método
   *
   * @return
   * @throws Exception
   */
  protected String doIt() throws Exception {
    if ((p_M_Product_ID == 0)
        || (p_M_Product_To_ID == 0)
        || (p_M_Locator_ID == 0)
        || (p_Qty == null)
        || (Env.ZERO.compareTo(p_Qty) == 0)) {
      throw new ErrorUsuarioOXP("Invalid Parameter");
    }

    //

    MProduct product = MProduct.get(getCtx(), p_M_Product_ID);
    MProduct productTo = MProduct.get(getCtx(), p_M_Product_To_ID);

    log.info(
        "Product="
            + product
            + ", ProductTo="
            + productTo
            + ", M_Locator_ID="
            + p_M_Locator_ID
            + ", Qty="
            + p_Qty);

    MUOMConversion[] conversions =
        MUOMConversion.getProductConversions(getCtx(), product.getM_Product_ID());
    MUOMConversion conversion = null;

    for (int i = 0; i < conversions.length; i++) {
      if (conversions[i].getC_UOM_To_ID() == productTo.getC_UOM_ID()) {
        conversion = conversions[i];
      }
    }

    if (conversion == null) {
      throw new ErrorUsuarioOXP("@NotFound@: @C_UOM_Conversion_ID@");
    }

    MUOM uomTo = MUOM.get(getCtx(), productTo.getC_UOM_ID());
    BigDecimal qtyTo =
        p_Qty.divide(conversion.getDivideRate(), uomTo.getStdPrecision(), BigDecimal.ROUND_HALF_UP);
    BigDecimal qtyTo6 = p_Qty.divide(conversion.getDivideRate(), 6, BigDecimal.ROUND_HALF_UP);

    if (qtyTo.compareTo(qtyTo6) != 0) {
      throw new ErrorUsuarioOXP(
          "@StdPrecision@: "
              + qtyTo
              + " <> "
              + qtyTo6
              + " ("
              + p_Qty
              + "/"
              + conversion.getDivideRate()
              + ")");
    }

    log.info(conversion + " -> " + qtyTo);

    // Set to Beta

    return "Not completed yet";
  } // doIt