Solution for Purchase Invoice Error : Insufficient stock transactions with Status Purchased.
Recently I faced “Insufficient stock transactions with Status Purchased.” error in AX 2012 R2 CU7 while invoicing partially received PO’s.
Each line of PurchLine Table have two records in InventTrans table one with status received another with status ordered which is causing error.
I went in to details and found that error (“Insufficient stock transactions with Status Purchased.”) is coming from checkLineAfterPosting method of PurchInvoiceJournalPost class.
I was able to solved it by just adding one more condition to ignore Ordered status as well.
New Code
if (purchLine.RemainPurchFinancial == 0 && purchLine.RemainPurchPhysical == 0)
{
select firstonly RecId from inventTrans
where ((purchLine.PurchQty >= 0
&& inventTrans.StatusReceipt != StatusReceipt::Purchased
&& inventTrans.StatusReceipt != StatusReceipt::None
&& inventTrans.StatusReceipt != StatusReceipt::Ordered)
|| (purchLine.PurchQty < 0 && inventTrans.StatusIssue != StatusIssue::Sold && inventTrans.StatusIssue != StatusIssue::None))
exists join inventTransOriginPurchLine
where inventTransOriginPurchLine.InventTransOrigin == inventTrans.InventTransOrigin
&& inventTransOriginPurchLine.PurchLineDataAreaId == purchLine.DataAreaId
&& inventTransOriginPurchLine.PurchLineInventTransId == purchLine.InventTransId;
if (inventTrans.RecId)
{
if (purchLine.PurchQty < 0)
{
ok = checkFailed(strFmt(“@SYS54028”, StatusIssue::Sold));
}
else
{
ok = checkFailed(strFmt(“@SYS54028”, StatusReceipt::Purchased));
}
ok = checkFailed(“@SYS115807”);
}
}
This was originally posted here.
*This post is locked for comments