IDEMPIERE-3431 Posting error for Matched PO if invoice posted while MR is not posted. / integrating fixes from Heng Sin AP2-825

This commit is contained in:
Carlos Ruiz 2019-01-09 22:38:08 +01:00
parent 949c2b02cf
commit df55d4649c
7 changed files with 49 additions and 9 deletions

View File

@ -0,0 +1,11 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Dec 18, 2018 10:50:26 AM MYT
-- AP2-825 Match PO | M_MatchPO unposted in Prod
INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Ref_List_UU,Name,IsActive,CreatedBy,UpdatedBy,AD_Client_ID,Created,Updated,EntityType,AD_Reference_ID,Value,AD_Org_ID) VALUES (200448,'0630b5d2-0fe4-4ef8-9d2f-a14791c02c7d','Deferred','Y',100,100,0,TO_DATE('2018-12-18 10:50:25','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2018-12-18 10:50:25','YYYY-MM-DD HH24:MI:SS'),'D',234,'d',0)
;
SELECT register_migration_script('201812181500_Ticket_AP2-825.sql') FROM dual
;

View File

@ -0,0 +1,8 @@
-- Dec 18, 2018 10:50:26 AM MYT
-- AP2-825 Match PO | M_MatchPO unposted in Prod
INSERT INTO AD_Ref_List (AD_Ref_List_ID,AD_Ref_List_UU,Name,IsActive,CreatedBy,UpdatedBy,AD_Client_ID,Created,Updated,EntityType,AD_Reference_ID,Value,AD_Org_ID) VALUES (200448,'0630b5d2-0fe4-4ef8-9d2f-a14791c02c7d','Deferred','Y',100,100,0,TO_TIMESTAMP('2018-12-18 10:50:25','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2018-12-18 10:50:25','YYYY-MM-DD HH24:MI:SS'),'D',234,'d',0)
;
SELECT register_migration_script('201812181500_Ticket_AP2-825.sql') FROM dual
;

View File

@ -148,7 +148,7 @@ public class ClientAcctProcessor extends SvrProcess
StringBuilder sql = new StringBuilder("SELECT DISTINCT ProcessedOn FROM ").append(TableName) StringBuilder sql = new StringBuilder("SELECT DISTINCT ProcessedOn FROM ").append(TableName)
.append(" WHERE AD_Client_ID=? AND ProcessedOn<?") .append(" WHERE AD_Client_ID=? AND ProcessedOn<?")
.append(" AND Processed='Y' AND Posted='N' AND IsActive='Y'"); .append(" AND Processed='Y' AND Posted IN ('N','d') AND IsActive='Y'");
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try
@ -202,7 +202,7 @@ public class ClientAcctProcessor extends SvrProcess
sql.append("=?"); sql.append("=?");
else else
sql.append(" IS NULL OR ProcessedOn=0"); sql.append(" IS NULL OR ProcessedOn=0");
sql.append(") AND Processed='Y' AND Posted='N' AND IsActive='Y'") sql.append(") AND Processed='Y' AND Posted IN ('N','d') AND IsActive='Y'")
.append(" ORDER BY Created"); .append(" ORDER BY Created");
// //
PreparedStatement pstmt = null; PreparedStatement pstmt = null;

View File

@ -199,6 +199,8 @@ public abstract class Doc
public static final String STATUS_Posted = "Y"; public static final String STATUS_Posted = "Y";
/** Document Status */ /** Document Status */
public static final String STATUS_Error = "E"; public static final String STATUS_Error = "E";
/** Document Status */
public static final String STATUS_Deferred = "d";
/** /**
@ -539,7 +541,7 @@ public abstract class Doc
if (!force) if (!force)
sql.append(" AND (Processing='N' OR Processing IS NULL)"); sql.append(" AND (Processing='N' OR Processing IS NULL)");
if (!repost) if (!repost)
sql.append(" AND Posted='N'"); sql.append(" AND Posted IN ('N','d')");
if (DB.executeUpdate(sql.toString(), trxName) == 1) { if (DB.executeUpdate(sql.toString(), trxName) == 1) {
if (log.isLoggable(Level.INFO)) log.info("Locked: " + get_TableName() + "_ID=" + get_ID()); if (log.isLoggable(Level.INFO)) log.info("Locked: " + get_TableName() + "_ID=" + get_ID());
} else { } else {
@ -558,7 +560,7 @@ public abstract class Doc
if (isDeferPosting()) if (isDeferPosting())
{ {
unlock(); unlock();
p_Status = STATUS_NotPosted; p_Status = STATUS_Deferred;
return null; return null;
} }
@ -648,7 +650,7 @@ public abstract class Doc
} }
// Create Note // Create Note
if (!p_Status.equals(STATUS_Posted)) if (!p_Status.equals(STATUS_Posted) && !p_Status.equals(STATUS_Deferred))
{ {
// Insert Note // Insert Note
String AD_MessageValue = "PostingError-" + p_Status; String AD_MessageValue = "PostingError-" + p_Status;

View File

@ -41,6 +41,7 @@ import org.compiere.model.MProduct;
import org.compiere.model.MTax; import org.compiere.model.MTax;
import org.compiere.model.ProductCost; import org.compiere.model.ProductCost;
import org.compiere.model.X_M_InOut; import org.compiere.model.X_M_InOut;
import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Util; import org.compiere.util.Util;
@ -60,7 +61,7 @@ public class Doc_MatchPO extends Doc
* @param as accounting schemata * @param as accounting schemata
* @param rs record * @param rs record
* @param trxName trx * @param trxName trx
*/ */
public Doc_MatchPO (MAcctSchema as, ResultSet rs, String trxName) public Doc_MatchPO (MAcctSchema as, ResultSet rs, String trxName)
{ {
super(as, MMatchPO.class, rs, DOCTYPE_MatMatchPO, trxName); super(as, MMatchPO.class, rs, DOCTYPE_MatMatchPO, trxName);
@ -122,6 +123,24 @@ public class Doc_MatchPO extends Doc
{ {
m_deferPosting = true; m_deferPosting = true;
} }
else
{
String posted = DB.getSQLValueStringEx(getTrxName(), "SELECT Posted FROM M_MatchPO WHERE M_MatchPO_ID=?", m_matchPO.getM_MatchPO_ID());
if (STATUS_Deferred.equals(posted))
{
int M_InOut_ID = DB.getSQLValueEx(getTrxName(), "SELECT M_InOut_ID FROM M_InOutLine WHERE M_InOutLine_ID=?", m_M_InOutLine_ID);
MInOut inout = new MInOut(getCtx(), M_InOut_ID, getTrxName());
if (inout.getDateAcct().after(m_matchPO.getDateAcct()))
{
m_matchPO.setDateAcct(inout.getDateAcct());
m_matchPO.setDateTrx(inout.getDateAcct());
setDateAcct(inout.getDateAcct());
setDateDoc(inout.getDateAcct());
m_matchPO.saveEx();
}
}
}
return null; return null;
} // loadDocumentDetails } // loadDocumentDetails

View File

@ -1867,7 +1867,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
return DocAction.STATUS_Invalid; return DocAction.STATUS_Invalid;
} }
matchPO++; matchPO++;
if (!po.isPosted() && po.getM_InOutLine_ID() > 0) // match po don't post if receipt is not assigned, and it doesn't create avg po record if (!po.isPosted())
addDocsPostProcess(po); addDocsPostProcess(po);
MMatchInv[] matchInvoices = MMatchInv.getInvoiceLine(getCtx(), line.getC_InvoiceLine_ID(), get_TrxName()); MMatchInv[] matchInvoices = MMatchInv.getInvoiceLine(getCtx(), line.getC_InvoiceLine_ID(), get_TrxName());

View File

@ -157,7 +157,7 @@ public class AcctProcessor extends AdempiereServer
StringBuffer sql = new StringBuffer ("SELECT DISTINCT ProcessedOn FROM ").append(TableName) StringBuffer sql = new StringBuffer ("SELECT DISTINCT ProcessedOn FROM ").append(TableName)
.append(" WHERE AD_Client_ID=? AND ProcessedOn<?") .append(" WHERE AD_Client_ID=? AND ProcessedOn<?")
.append(" AND Processed='Y' AND Posted='N' AND IsActive='Y'"); .append(" AND Processed='Y' AND Posted IN ('N','d') AND IsActive='Y'");
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try
@ -211,7 +211,7 @@ public class AcctProcessor extends AdempiereServer
sql.append("=?"); sql.append("=?");
else else
sql.append(" IS NULL OR ProcessedOn=0"); sql.append(" IS NULL OR ProcessedOn=0");
sql.append(") AND Processed='Y' AND Posted='N' AND IsActive='Y'") sql.append(") AND Processed='Y' AND Posted IN ('N','d') AND IsActive='Y'")
.append(" ORDER BY Created"); .append(" ORDER BY Created");
// //
PreparedStatement pstmt = null; PreparedStatement pstmt = null;