diff --git a/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java b/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java index 5fda15ccb3..bad7405b79 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java @@ -243,13 +243,13 @@ public class PaySelect + " INNER JOIN C_PaymentTerm p ON (i.C_PaymentTerm_ID=p.C_PaymentTerm_ID)", // WHERE "i.IsSOTrx=? AND IsPaid='N'" - + " AND invoiceOpen(i.C_Invoice_ID, i.C_InvoicePaySchedule_ID) != 0" //Check that AmountDue <> 0 + + " AND invoiceOpenToDate(i.C_Invoice_ID, i.C_InvoicePaySchedule_ID, SysDate) != 0" //Check that AmountDue <> 0 // Different Payment Selection - + " AND NOT EXISTS (SELECT * FROM C_PaySelectionLine psl" + + " AND (i.C_InvoicePaySchedule_ID > 0 OR NOT EXISTS (SELECT * FROM C_PaySelectionLine psl" + " INNER JOIN C_PaySelectionCheck psc ON (psl.C_PaySelectionCheck_ID=psc.C_PaySelectionCheck_ID)" + " LEFT OUTER JOIN C_Payment pmt ON (pmt.C_Payment_ID=psc.C_Payment_ID)" + " WHERE i.C_Invoice_ID=psl.C_Invoice_ID AND psl.IsActive='Y'" - + " AND (pmt.DocStatus IS NULL OR pmt.DocStatus NOT IN ('VO','RE')) )" + + " AND (pmt.DocStatus IS NULL OR pmt.DocStatus NOT IN ('VO','RE')) ))" + " AND i.DocStatus IN ('CO','CL')" + " AND i.AD_Client_ID=?", // additional where & order in loadTableInfo() true, "i");