diff --git a/org.adempiere.base/src/org/compiere/acct/Doc.java b/org.adempiere.base/src/org/compiere/acct/Doc.java index d03d1cde87..47ebcc98fa 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc.java @@ -260,8 +260,25 @@ public abstract class Doc Trx trx = Trx.get(Trx.createTrxName("ManulPosting"), true); try { - error = postImmediate(ass, AD_Table_ID, Record_ID, force, trx.getTrxName()); - //Average Costing: Post MatchPO and MatchInv together with MR and Invoice + //Costing: Post MatchPO before MR + if (AD_Table_ID == MInOut.Table_ID) + { + MMatchPO[] matchPos = MMatchPO.getInOut(Env.getCtx(), Record_ID, trx.getTrxName()); + for (MMatchPO matchPo : matchPos) + { + if (!matchPo.isPosted()) + { + error = postImmediate(ass, matchPo.get_Table_ID(), matchPo.get_ID(), force, matchPo.get_TrxName()); + if (!Util.isEmpty(error)) + break; + } + } + } + if (Util.isEmpty(error)) + { + error = postImmediate(ass, AD_Table_ID, Record_ID, force, trx.getTrxName()); + } + //Costing: Post MatchInv after Invoice if (Util.isEmpty(error)) { if (AD_Table_ID == MInvoice.Table_ID) @@ -276,20 +293,6 @@ public abstract class Doc break; } } - - } - else if (AD_Table_ID == MInOut.Table_ID) - { - MMatchPO[] matchPos = MMatchPO.getInOut(Env.getCtx(), Record_ID, trx.getTrxName()); - for (MMatchPO matchPo : matchPos) - { - if (!matchPo.isPosted()) - { - error = postImmediate(ass, matchPo.get_Table_ID(), matchPo.get_ID(), force, matchPo.get_TrxName()); - if (!Util.isEmpty(error)) - break; - } - } } } if (Util.isEmpty(error))