1701671 Reversing payment on vend invoice should flag invoice unpaid

https://sourceforge.net/tracker/index.php?func=detail&aid=1701671&group_id=176962&atid=879332
This commit is contained in:
phib 2009-10-07 02:08:32 +00:00
parent d49ee7549c
commit 28f6dd1fa8
2 changed files with 10 additions and 10 deletions

View File

@ -115,10 +115,12 @@ public class PaySelectionCreateFrom extends SvrProcess
+ "FROM C_Invoice i "
+ "WHERE IsSOTrx='N' AND IsPaid='N' AND DocStatus IN ('CO','CL')"
+ " AND AD_Client_ID=?" // ##6
// Existing Payments - Will reselect Invoice if prepared but not paid
+ " AND NOT EXISTS (SELECT * FROM C_PaySelectionLine psl "
+ "WHERE i.C_Invoice_ID=psl.C_Invoice_ID AND psl.IsActive='Y'"
+ " AND psl.C_PaySelectionCheck_ID IS NOT NULL)";
// Existing Payments - Will reselect Invoice if prepared but not paid
+ " AND 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')) )";
// Disputed
if (!p_IncludeInDispute)
sql += " AND i.IsInDispute='N'";

View File

@ -227,12 +227,10 @@ public class PaySelect
"i.IsSOTrx=? AND IsPaid='N'"
// Different Payment Selection
+ " AND NOT EXISTS (SELECT * FROM C_PaySelectionLine psl"
+ " WHERE i.C_Invoice_ID=psl.C_Invoice_ID AND psl.C_PaySelectionCheck_ID IS NOT NULL"
+ " AND psl.C_PaySelectionCheck_ID NOT IN "
+ " (SELECT psc.C_PaySelectionCheck_ID FROM C_PaySelectionCheck psc, C_Payment p"
+ " WHERE psc.C_PaySelectionCheck_ID = psl.C_PaySelectionCheck_ID"
+ " AND psc.C_Payment_ID = p.C_Payment_ID"
+ " AND p.DocStatus IN ('RE','VO')))"
+ " 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 i.DocStatus IN ('CO','CL')"
+ " AND i.AD_Client_ID=?", // additional where & order in loadTableInfo()
true, "i");