public static BigDecimal convert(int C_UOM_From_ID,int C_UOM_To_ID,BigDecimal qty,boolean StdPrecision){
  if (qty == null || qty.compareTo(Env.ZERO) == 0 || C_UOM_From_ID == C_UOM_To_ID)   return qty;
  BigDecimal retValue=null;
  int precision=2;
  String sql="SELECT c.MultiplyRate, uomTo.StdPrecision, uomTo.CostingPrecision " + "FROM	C_UOM_Conversion c" + " INNER JOIN C_UOM uomTo ON (c.C_UOM_TO_ID=uomTo.C_UOM_ID) "+ "WHERE c.IsActive='Y' AND c.C_UOM_ID=? AND c.C_UOM_TO_ID=? "+ " AND c.M_Product_ID IS NULL"+ " ORDER BY c.AD_Client_ID DESC, c.AD_Org_ID DESC";
  PreparedStatement pstmt=null;
  ResultSet rs=null;
  try {
    pstmt=DB.prepareStatement(sql,null);
    pstmt.setInt(1,C_UOM_From_ID);
    pstmt.setInt(2,C_UOM_To_ID);
    rs=pstmt.executeQuery();
    if (rs.next()) {
      retValue=rs.getBigDecimal(1);
      precision=rs.getInt(StdPrecision ? 2 : 3);
    }
  }
 catch (  SQLException e) {
    throw new DBException(e,sql);
  }
 finally {
    DB.close(rs,pstmt);
    rs=null;
    pstmt=null;
  }
  if (retValue == null) {
    s_log.info("NOT found - FromUOM=" + C_UOM_From_ID + ", ToUOM="+ C_UOM_To_ID);
    return null;
  }
  if (GETRATE.equals(qty))   return retValue;
  retValue=retValue.multiply(qty);
  if (retValue.scale() > precision)   retValue=retValue.setScale(precision,BigDecimal.ROUND_HALF_UP);
  return retValue;
}

public static BigDecimal convert ( int C_UOM_From_ID , int C_UOM_To_ID , BigDecimal qty , boolean StdPrecision ) { if ( qty == null || qty . compareTo ( Env . ZERO ) == 0 || C_UOM_From_ID == C_UOM_To_ID ) return qty ; BigDecimal retValue = null ; int precision = 2 ; String sql = "SELECT c.MultiplyRate, uomTo.StdPrecision, uomTo.CostingPrecision " + "FROM	C_UOM_Conversion c" + " INNER JOIN C_UOM uomTo ON (c.C_UOM_TO_ID=uomTo.C_UOM_ID) " + "WHERE c.IsActive='Y' AND c.C_UOM_ID=? AND c.C_UOM_TO_ID=? " + " AND c.M_Product_ID IS NULL" + " ORDER BY c.AD_Client_ID DESC, c.AD_Org_ID DESC" ; PreparedStatement pstmt = null ; ResultSet rs = null ; try { pstmt = DB . prepareStatement ( sql , null ) ; pstmt . setInt ( 1 , C_UOM_From_ID ) ; pstmt . setInt ( 2 , C_UOM_To_ID ) ; rs = pstmt . executeQuery ( ) ; if ( rs . next ( ) ) { retValue = rs . getBigDecimal ( 1 ) ; precision = rs . getInt ( StdPrecision ? 2 : 3 ) ; } } catch ( SQLException e ) { throw new DBException ( e , sql ) ; } finally { DB . close ( rs , pstmt ) ; rs = null ; pstmt = null ; } if ( retValue == null ) { s_log . info ( "NOT found - FromUOM=" + C_UOM_From_ID + ", ToUOM=" + C_UOM_To_ID ) ; return null ; } if ( GETRATE . equals ( qty ) ) return retValue ; retValue = retValue . multiply ( qty ) ; if ( retValue . scale ( ) > precision ) retValue = retValue . setScale ( precision , BigDecimal . ROUND_HALF_UP ) ; return retValue ; }
get converted qty from server ( no cache )
