Unreserve sales order lines / transfer orders [X++]

5
(3)
//Loops on inventory transactions of Reserved and Reserved ordered and unreserves them
while select inventTrans
where inventTrans.StatusReceipt == StatusReceipt::None
   && (inventTrans.StatusIssue  == StatusIssue::ReservPhysical
   ||  inventTrans.StatusIssue  == StatusIssue::ReservOrdered)
   && inventTrans.ItemId        == itemId
exists join inventTransOrigin
	where inventTransOrigin.RecId == inventTrans.InventTransOrigin
exists join salesLine
	where salesLine.InventTransId == inventTransOrigin.InventTransId
{
	
	if (inventTrans.MarkingRefInventTransOrigin)
	{
		InventTransOrigin::deleteMarking(inventTrans.MarkingRefInventTransOrigin, inventTrans.InventTransOrigin, -inventTrans.Qty, true);
		InventTransOrigin::deleteMarking(inventTrans.InventTransOrigin, inventTrans.MarkingRefInventTransOrigin, inventTrans.Qty, true);
	}


	if (inventTrans.StatusIssue == StatusIssue::ReservPhysical || inventTrans.StatusIssue == StatusIssue::ReservOrdered)
	{
		inventMovement = inventTrans.inventMovement(true);
		inventUpd_Reservation = InventUpd_Reservation::newInventDim(inventMovement, inventTrans.inventDim(), -1 * inventTrans.Qty, false);
		inventUpd_Reservation.updateNow();
	}
	
}

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 3

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Scroll to Top