IDEMPIERE-3388 Manual posting of MR break Average PO costing. Should post MatchPO before MR.

This commit is contained in:
Heng Sin Low 2017-06-19 17:07:46 +08:00
parent fb372535e3
commit bf13e34476
1 changed files with 19 additions and 16 deletions

View File

@ -260,8 +260,25 @@ public abstract class Doc
Trx trx = Trx.get(Trx.createTrxName("ManulPosting"), true); Trx trx = Trx.get(Trx.createTrxName("ManulPosting"), true);
try try
{ {
error = postImmediate(ass, AD_Table_ID, Record_ID, force, trx.getTrxName()); //Costing: Post MatchPO before MR
//Average Costing: Post MatchPO and MatchInv together with MR and Invoice 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 (Util.isEmpty(error))
{ {
if (AD_Table_ID == MInvoice.Table_ID) if (AD_Table_ID == MInvoice.Table_ID)
@ -276,20 +293,6 @@ public abstract class Doc
break; 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)) if (Util.isEmpty(error))