public static BigDecimal allocated(int p_C_Payment_ID,int p_C_Currency_ID) throws SQLException {
  BigDecimal PayAmt=null;
  int C_Charge_ID=0;
  String sql="SELECT PayAmt, C_Charge_ID " + "FROM C_Payment_v " + "WHERE C_Payment_ID=?";
  PreparedStatement pstmt=Adempiere.prepareStatement(sql);
  pstmt.setInt(1,p_C_Payment_ID);
  ResultSet rs=pstmt.executeQuery();
  if (rs.next()) {
    PayAmt=rs.getBigDecimal(1);
    C_Charge_ID=rs.getInt(2);
  }
  rs.close();
  pstmt.close();
  if (C_Charge_ID > 0)   return PayAmt;
  int C_ConversionType_ID=0;
  BigDecimal allocatedAmt=getAllocatedAmt(p_C_Payment_ID,p_C_Currency_ID,C_ConversionType_ID);
  return Currency.round(allocatedAmt,p_C_Currency_ID,null);
}

public static BigDecimal allocated ( int p_C_Payment_ID , int p_C_Currency_ID ) throws SQLException { BigDecimal PayAmt = null ; int C_Charge_ID = 0 ; String sql = "SELECT PayAmt, C_Charge_ID " + "FROM C_Payment_v " + "WHERE C_Payment_ID=?" ; PreparedStatement pstmt = Adempiere . prepareStatement ( sql ) ; pstmt . setInt ( 1 , p_C_Payment_ID ) ; ResultSet rs = pstmt . executeQuery ( ) ; if ( rs . next ( ) ) { PayAmt = rs . getBigDecimal ( 1 ) ; C_Charge_ID = rs . getInt ( 2 ) ; } rs . close ( ) ; pstmt . close ( ) ; if ( C_Charge_ID > 0 ) return PayAmt ; int C_ConversionType_ID = 0 ; BigDecimal allocatedAmt = getAllocatedAmt ( p_C_Payment_ID , p_C_Currency_ID , C_ConversionType_ID ) ; return Currency . round ( allocatedAmt , p_C_Currency_ID , null ) ; }
get allocated payment amount . - paymentallocated
