IDEMPIERE-3012 - Reversed MatchPO messes up matching
This commit is contained in:
parent
cbfc3ac88f
commit
9014e90652
|
@ -345,7 +345,7 @@ public class MMatchPO extends X_M_MatchPO
|
|||
MInOutLine sLine, int C_OrderLine_ID, Timestamp dateTrx,
|
||||
BigDecimal qty, String trxName) {
|
||||
MMatchPO retValue = null;
|
||||
String sql = "SELECT * FROM M_MatchPO WHERE C_OrderLine_ID=? ORDER BY M_MatchPO_ID";
|
||||
String sql = "SELECT * FROM M_MatchPO WHERE C_OrderLine_ID=? and Reversal_ID IS NULL ORDER BY M_MatchPO_ID";
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
|
@ -932,13 +932,13 @@ public class MMatchPO extends X_M_MatchPO
|
|||
if (validateOrderedQty)
|
||||
{
|
||||
MOrderLine line = new MOrderLine(getCtx(), getC_OrderLine_ID(), get_TrxName());
|
||||
BigDecimal invoicedQty = DB.getSQLValueBD(get_TrxName(), "SELECT Coalesce(SUM(Qty),0) FROM M_MatchPO WHERE C_InvoiceLine_ID > 0 and C_OrderLine_ID=?" , getC_OrderLine_ID());
|
||||
BigDecimal invoicedQty = DB.getSQLValueBD(get_TrxName(), "SELECT Coalesce(SUM(Qty),0) FROM M_MatchPO WHERE C_InvoiceLine_ID > 0 and C_OrderLine_ID=? AND Reversal_ID IS NULL" , getC_OrderLine_ID());
|
||||
if (invoicedQty != null && invoicedQty.compareTo(line.getQtyOrdered()) > 0)
|
||||
{
|
||||
throw new IllegalStateException("Total matched invoiced qty > ordered qty. MatchedInvoicedQty="+invoicedQty+", OrderedQty="+line.getQtyOrdered()+", Line="+line);
|
||||
}
|
||||
|
||||
BigDecimal deliveredQty = DB.getSQLValueBD(get_TrxName(), "SELECT Coalesce(SUM(Qty),0) FROM M_MatchPO WHERE M_InOutLine_ID > 0 and C_OrderLine_ID=?" , getC_OrderLine_ID());
|
||||
BigDecimal deliveredQty = DB.getSQLValueBD(get_TrxName(), "SELECT Coalesce(SUM(Qty),0) FROM M_MatchPO WHERE M_InOutLine_ID > 0 and C_OrderLine_ID=? AND Reversal_ID IS NULL" , getC_OrderLine_ID());
|
||||
if (deliveredQty != null && deliveredQty.compareTo(line.getQtyOrdered()) > 0)
|
||||
{
|
||||
throw new IllegalStateException("Total matched delivered qty > ordered qty. MatchedDeliveredQty="+deliveredQty+", OrderedQty="+line.getQtyOrdered()+", Line="+line);
|
||||
|
|
Loading…
Reference in New Issue