Synch versions for [ 2081237 ] PaymentAvailable Oracle-XE function wrong

This commit is contained in:
Carlos Ruiz 2008-11-01 01:09:50 +00:00
parent d3d10cc058
commit ab54e5b240
4 changed files with 20 additions and 9 deletions

View File

@ -42,7 +42,7 @@ BEGIN
FROM C_Payment FROM C_Payment
WHERE C_Payment_ID=p_C_Payment_ID AND C_Charge_ID > 0; WHERE C_Payment_ID=p_C_Payment_ID AND C_Charge_ID > 0;
IF (v_PayAmt IS NOT NULL) THEN IF (v_PayAmt IS NOT NULL) THEN
RETURN 0; RETURN v_PayAmt;
END IF; END IF;
-- Calculate Allocated Amount -- Calculate Allocated Amount

View File

@ -39,7 +39,7 @@ BEGIN
WHERE C_Payment_ID=p_C_Payment_ID AND C_Charge_ID > 0; WHERE C_Payment_ID=p_C_Payment_ID AND C_Charge_ID > 0;
IF (v_PayAmt IS NOT NULL) THEN IF (v_PayAmt IS NOT NULL) THEN
RETURN 0; RETURN v_PayAmt;
END IF; END IF;
-- Calculate Allocated Amount -- Calculate Allocated Amount

View File

@ -31,7 +31,7 @@ BEGIN
FROM C_Payment FROM C_Payment
WHERE C_Payment_ID=p_C_Payment_ID AND C_Charge_ID > 0; WHERE C_Payment_ID=p_C_Payment_ID AND C_Charge_ID > 0;
IF (v_Amt IS NOT NULL) THEN IF (v_Amt IS NOT NULL) THEN
RETURN v_Amt; RETURN 0;
END IF; END IF;
-- Get Currency -- Get Currency
@ -63,4 +63,3 @@ BEGIN
END; END;
$body$ LANGUAGE plpgsql; $body$ LANGUAGE plpgsql;

View File

@ -39,13 +39,25 @@ public class Payment
public static BigDecimal allocated (int p_C_Payment_ID, int p_C_Currency_ID) public static BigDecimal allocated (int p_C_Payment_ID, int p_C_Currency_ID)
throws SQLException throws SQLException
{ {
// Charge - nothing available BigDecimal PayAmt = null;
String sql = "SELECT C_Charge_ID " int C_Charge_ID = 0;
+ "FROM C_Payment " //
String sql = "SELECT PayAmt, C_Charge_ID "
+ "FROM C_Payment_v " // corrected for AP/AR
+ "WHERE C_Payment_ID=?"; + "WHERE C_Payment_ID=?";
int C_Charge_ID = Adempiere.getSQLValue(sql, p_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) if (C_Charge_ID > 0)
return Adempiere.ZERO; return PayAmt;
int C_ConversionType_ID = 0; int C_ConversionType_ID = 0;