public static BigDecimal rate(int p_C_CurrencyFrom_ID,int p_C_CurrencyTo_ID,Timestamp p_ConversionDate,int p_C_ConversionType_ID,int p_AD_Client_ID,int p_AD_Org_ID) throws SQLException {
  if (p_C_CurrencyFrom_ID == p_C_CurrencyTo_ID)   return Adempiere.ONE;
  Timestamp ConversionDate=p_ConversionDate;
  if (ConversionDate == null)   ConversionDate=new Timestamp(System.currentTimeMillis());
  ConversionDate=Adempiere.trunc(ConversionDate);
  int C_ConversionType_ID=p_C_ConversionType_ID;
  if (C_ConversionType_ID == 0) {
    String sql="SELECT C_ConversionType_ID " + "FROM C_ConversionType " + "WHERE IsDefault='Y'"+ " AND AD_Client_ID IN (0,?) "+ "ORDER BY AD_Client_ID DESC";
    C_ConversionType_ID=Adempiere.getSQLValue(sql,p_AD_Client_ID);
  }
  BigDecimal rate=null;
  String sql="SELECT MultiplyRate " + "FROM C_Conversion_Rate " + "WHERE C_Currency_ID=? AND C_Currency_ID_To=?"+ " AND C_ConversionType_ID=?"+ " AND TRUNC(ValidFrom, 'DD') <= ?"+ " AND TRUNC(ValidTo, 'DD') >= ?"+ " AND AD_Client_ID IN (0,?) AND AD_Org_ID IN (0,?) "+ "ORDER BY AD_Client_ID DESC, AD_Org_ID DESC, ValidFrom DESC";
  PreparedStatement pstmt=Adempiere.prepareStatement(sql);
  pstmt.setInt(1,p_C_CurrencyFrom_ID);
  pstmt.setInt(2,p_C_CurrencyTo_ID);
  pstmt.setInt(3,C_ConversionType_ID);
  pstmt.setTimestamp(4,ConversionDate);
  pstmt.setTimestamp(5,ConversionDate);
  pstmt.setInt(6,p_AD_Client_ID);
  pstmt.setInt(7,p_AD_Org_ID);
  ResultSet rs=pstmt.executeQuery();
  if (rs.next()) {
    rate=rs.getBigDecimal(1);
  }
  rs.close();
  pstmt.close();
  if (rate == null)   return null;
  return rate;
}

public static BigDecimal rate ( int p_C_CurrencyFrom_ID , int p_C_CurrencyTo_ID , Timestamp p_ConversionDate , int p_C_ConversionType_ID , int p_AD_Client_ID , int p_AD_Org_ID ) throws SQLException { if ( p_C_CurrencyFrom_ID == p_C_CurrencyTo_ID ) return Adempiere . ONE ; Timestamp ConversionDate = p_ConversionDate ; if ( ConversionDate == null ) ConversionDate = new Timestamp ( System . currentTimeMillis ( ) ) ; ConversionDate = Adempiere . trunc ( ConversionDate ) ; int C_ConversionType_ID = p_C_ConversionType_ID ; if ( C_ConversionType_ID == 0 ) { String sql = "SELECT C_ConversionType_ID " + "FROM C_ConversionType " + "WHERE IsDefault='Y'" + " AND AD_Client_ID IN (0,?) " + "ORDER BY AD_Client_ID DESC" ; C_ConversionType_ID = Adempiere . getSQLValue ( sql , p_AD_Client_ID ) ; } BigDecimal rate = null ; String sql = "SELECT MultiplyRate " + "FROM C_Conversion_Rate " + "WHERE C_Currency_ID=? AND C_Currency_ID_To=?" + " AND C_ConversionType_ID=?" + " AND TRUNC(ValidFrom, 'DD') <= ?" + " AND TRUNC(ValidTo, 'DD') >= ?" + " AND AD_Client_ID IN (0,?) AND AD_Org_ID IN (0,?) " + "ORDER BY AD_Client_ID DESC, AD_Org_ID DESC, ValidFrom DESC" ; PreparedStatement pstmt = Adempiere . prepareStatement ( sql ) ; pstmt . setInt ( 1 , p_C_CurrencyFrom_ID ) ; pstmt . setInt ( 2 , p_C_CurrencyTo_ID ) ; pstmt . setInt ( 3 , C_ConversionType_ID ) ; pstmt . setTimestamp ( 4 , ConversionDate ) ; pstmt . setTimestamp ( 5 , ConversionDate ) ; pstmt . setInt ( 6 , p_AD_Client_ID ) ; pstmt . setInt ( 7 , p_AD_Org_ID ) ; ResultSet rs = pstmt . executeQuery ( ) ; if ( rs . next ( ) ) { rate = rs . getBigDecimal ( 1 ) ; } rs . close ( ) ; pstmt . close ( ) ; if ( rate == null ) return null ; return rate ; }
get conversion rate . previously : c_currency_rate - now : currencyrate
