IDEMPIERE-3669 Drop shipment - Accounting processor posts customer shipment before MR resulting in posting error

This commit is contained in:
Heng Sin Low 2019-05-04 17:25:39 +08:00
parent b357b4c13c
commit 5e0f504a6c
1 changed files with 30 additions and 4 deletions

View File

@ -22,20 +22,21 @@ import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.logging.Level;
import org.compiere.model.I_C_OrderLine;
import org.compiere.model.I_M_InOutLine;
import org.compiere.model.I_M_RMALine;
import org.compiere.model.MConversionRate;
import org.compiere.model.MOrderLandedCostAllocation;
import org.compiere.model.MTax;
import org.compiere.model.MCurrency;
import org.compiere.model.MAccount;
import org.compiere.model.MAcctSchema;
import org.compiere.model.MConversionRate;
import org.compiere.model.MCostDetail;
import org.compiere.model.MCurrency;
import org.compiere.model.MInOut;
import org.compiere.model.MInOutLine;
import org.compiere.model.MInOutLineMA;
import org.compiere.model.MOrderLandedCostAllocation;
import org.compiere.model.MOrderLine;
import org.compiere.model.MProduct;
import org.compiere.model.MTax;
import org.compiere.model.ProductCost;
import org.compiere.util.DB;
import org.compiere.util.Env;
@ -69,6 +70,7 @@ public class Doc_InOut extends Doc
private int m_Reversal_ID = 0;
@SuppressWarnings("unused")
private String m_DocStatus = "";
private boolean m_deferPosting = false;
/**
* Load Document Details
@ -84,6 +86,25 @@ public class Doc_InOut extends Doc
// Contained Objects
p_lines = loadLines(inout);
if (log.isLoggable(Level.FINE)) log.fine("Lines=" + p_lines.length);
if (inout.isSOTrx()) {
MInOutLine[] lines = inout.getLines();
for (MInOutLine line : lines) {
I_C_OrderLine orderLine = line.getC_OrderLine();
if (orderLine != null) {
if (orderLine.getLink_OrderLine_ID() > 0) {
// Defer posting if found the linked MR is not posted
String sql = "SELECT COUNT(*) FROM M_InOutLine iol WHERE iol.C_OrderLine_ID=? AND EXISTS (SELECT * FROM M_InOut io WHERE io.M_InOut_ID=iol.M_InOut_ID AND io.IsSOTrx='N' AND io.Posted<>'Y')";
int count = DB.getSQLValueEx(getTrxName(), sql, orderLine.getLink_OrderLine_ID());
if (count > 0) {
m_deferPosting = true;
break;
}
}
}
}
}
return null;
} // loadDocumentDetails
@ -959,4 +980,9 @@ public class Doc_InOut extends Doc
}
return "";
}
@Override
public boolean isDeferPosting() {
return m_deferPosting;
}
} // Doc_InOut